![]() |
Font von 'text' in einem Listboxitem mit style herausfinden
Weiß jemand wie man den font (size, name, usw. ) von dem "Text" teil in einem LisboxItem herausfinden kann ohne das styling zu deaktivieren?
Delphi-Quellcode:
aListbox.ListItems[0].TextSettings.Font ist offensichtlich nicht der Font der benutzt wird
//Maxwidth ermitteln
var aMaxTextWidth:Extended := 0.0; var aTextWidth : Extended := 0.0; var Bmp:FMX.Graphics.TBitmap := FMX.Graphics.TBitmap.Create; try Bmp.canvas.Font.Assign(aListbox.ListItems[0].TextSettings.Font); For var i:Integer := 0 to aListbox.Items.Count-1 do Begin aTextWidth := Bmp.canvas.TextWidth(aListbox.ListItems[i].Text); if aTextWidth > aMaxTextWidth then aMaxTextWidth := aTextWidth; End; finally Bmp.Free; end; aListbox.StylesData['text.font.size'] oder so? Ich will nicht das Styling des fonts deaktivieren oder bestimmen, sondern den tatsächlich verwendeten Font ermitteln. |
AW: Font von 'text' in einem Listboxitem mit style herausfinden
Ich habe jetzt mal ein bisschen rausbekommen
Folgender code funktioniert anscheinend
Delphi-Quellcode:
wie mache ich das mit den TFontStyles? Ist das richtig?
//Maxwidth ermitteln
var aMaxTextWidth:Extended := 0.0; var aTextWidth : Extended := 0.0; var Bmp:FMX.Graphics.TBitmap := FMX.Graphics.TBitmap.Create; var aFont:TFont := tfont.create; var b:byte; try aFont.Family := aListbox.ListItems[0].StylesData['text.font.family'].asString; aFont.Size := aListbox.ListItems[0].StylesData['text.font.size'].AsExtended; aListbox.ListItems[0].StylesData['text.font.style'].ExtractRawData(@b);// <-------------ist das richtig afont.Style := tFontstyles(b);// <-------------ist das richtig Bmp.canvas.Font.Assign(aFont); For var i:Integer := 0 to aListbox.Items.Count-1 do Begin aTextWidth := Bmp.canvas.TextWidth(aListbox.ListItems[i].Text); if aTextWidth > aMaxTextWidth then aMaxTextWidth := aTextWidth; End; finally Bmp.Free; aFont.Free; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz