Graphics.TextHeight
From Xojo Documentation
Method
Gets the height of a line of text drawn with the current font.
Method
Graphics.TextHeight(value as String, wrapWidth as Double) As Double
Supported for all project types and targets.
Supported for all project types and targets.
Used to calculate the height of a line of text passed (given the wrap width passed) drawn with the current font.
Notes
TextHeight is calculated as the maximum height for the font itself and not the actual height of the text. For example, with "a" vs. "A", both return the same TextHeight even though "A" has a greater height than "a".
Sample Code
g.FontName = "Helvetica"
g.FontUnit = FontUnits.Points
g.FontSize = 32
Var height As Double
height = g.TextHeight("Hello world", 150)
g.FontUnit = FontUnits.Points
g.FontSize = 32
Var height As Double
height = g.TextHeight("Hello world", 150)
This example reports the TextHeight of the current text.
g.DrawingColor = &cff0000
g.Italic = True
g.DrawText("Hello world", 10, 10)
MessageBox(g.TextHeight.ToString)
g.Italic = True
g.DrawText("Hello world", 10, 10)
MessageBox(g.TextHeight.ToString)