Graphics.TextHeight

From Xojo Documentation

Revision as of 15:31, 7 October 2019 by PLefebvre (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Method

Graphics.TextHeight() As Double

Supported for all project types and targets.


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.


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)

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)