Graphics.StringHeight

From Xojo Documentation

Method

Graphics.StringHeight(text As String, wrapWidth As Double) As Double

Supported for all project types and targets.

Returns as a Double the height of the text based on the current font and font size and the passed wrapWidth (in display points).

Notes

The wrapWidth parameter specifies the width (in pixels) at which text should wrap.

StringHeight 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 StringHeight even though "A" has a greater height than "a".

Sample Code

g.TextFont = "Helvetica"
g.TextUnit = FontUnits.Pixel
g.TextSize = 32

Dim i As Double
i = g.StringHeight("Hello world", 150)