UI module

draw_text

procedureextensionexperimentalsince 0.31.0Source

Draw one line of text with its top left at (x, y) and return its width in points.

Example↗
ui := headless();
defer free_ui(*ui);
width := draw_text(*ui, 10, 10, "hello", .{ size = 10 });
assert(width == 30);
draw_text :: (
    ui: *UI_State,
    x: float,
    y: float,
    text: string,
    style: Text_Style
) -> float

Draw one line of text with its top left at (x, y) and return its width in points.

Parameters

ui: *UI_State
the UI whose display list gets the glyphs.
x: float
left edge of the line.
y: float
top edge of the line.
text: string
the UTF-8 text. Control characters other than tab are skipped.
style: Text_Style
font, size and colour.

Returns

float
Example↗
ui := headless();
defer free_ui(*ui);
width := draw_text(*ui, 10, 10, "hello", .{ size = 10 });
assert(width == 30);

See also