Simp module

prepare_text

procedureSource

Lays text out and returns its width in pixels. draw_prepared_text then draws it.

Example
font := load_font("", "Roboto-Regular.ttf", 24);
width := prepare_text(font, "Game over");
draw_prepared_text(font, (800 - width) / 2, 300);  // centred

This one is only checked to compile, not run.

prepare_text :: (
    font: *Dynamic_Font,
    text: string,
    effect_flags: Font_Effects = 0
) -> width: s64

Lays text out and returns its width in pixels. draw_prepared_text then draws it.

Parameters

font: *Dynamic_Font
the font to lay the text out in.
text: string
UTF-8.
effect_flags: Font_Effects = 0
Font_Effects flags.

Returns

width: s64
Example
font := load_font("", "Roboto-Regular.ttf", 24);
width := prepare_text(font, "Game over");
draw_prepared_text(font, (800 - width) / 2, 300);  // centred

This one is only checked to compile, not run.

See also