Graphics.DrawText

From Xojo Documentation

Method

Graphics.DrawText(str As String, x As Double, y As Double [, wrapWidth As Double = 0] [, condense As Boolean = False])

New in 2019r2

Supported for all project types and targets.

Draws the text at the specified location and in the current color. The current color is set with the DrawingColor property.

Notes

The X parameter specifies the distance from the left of the Graphics object in pixels. The Y parameter specifies the baseline for the text. The optional WrapWidth parameter specifies the width at which text should wrap. The text will wrap if WrapWidth is provided and Condense is False (The default is False). If WrapWidth is omitted, then text will print on one line, even if the window or RectControl is too narrow to contain the text. If the optional Condense property is True, DrawText truncates the text to fit into the space specified by WrapWidth and uses an ellipsis ("...") to indicate that there is additional text that is not shown. The default values of WrapWidth and Condense are zero and False, respectively. The default behavior is to print the text on one line.

Sample Code

This code draws text in red Helvetica 16-point:

g.DrawingColor = &cff0000
g.FontName = "Helvetica"
g.FontUnit = FontUnits.Point
g.FontSize = 16
g.DrawText("Hello world", 10, 130)