UI module

text_width

procedureextensionexperimentalsince 0.31.0Source

The width in points of string drawn with style, without kerning.

Example↗
ui := headless();
defer free_ui(*ui);
assert(text_width(*ui.text, "ten chars!", .{ size = 10 }) == 60);
text_width :: (
    text: *Text_System,
    string_to_measure: string,
    style: Text_Style
) -> float

The width in points of string drawn with style, without kerning.

Parameters

text: *Text_System
the text system holding the fonts.
string_to_measure: string
the UTF-8 text to measure.
style: Text_Style
the font and size to measure with.

Returns

float
Example↗
ui := headless();
defer free_ui(*ui);
assert(text_width(*ui.text, "ten chars!", .{ size = 10 }) == 60);

See also