natiny_render_text

C
void natiny_render_text(
    NatinyFont font,
    float x, float y,
    const char* text
);

Draws text with the given font on the currently bound render target using the current draw color.

Parameters

Name Type Description
font NatinyFont Font handle from natiny_font_create
x float X position in pixels
y float Y position in pixels
text const char* UTF-8 text to draw

Example

C
natiny_render_text(font, 20.0f, 20.0f, "Score: 100");

Notes

  • text is decoded as UTF-8 and glyphs are cached by the font on demand.
  • (x, y) is the top-left of the first line; the baseline is derived from the font ascent. The current draw color tints the glyphs.
  • starts a new line and moves to the next tab stop, four spaces apart. Lines are stacked by natiny_font_get_line_height.
  • No wrapping: use natiny_render_text_box for text that has to fit a width, and natiny_render_text_ex to turn it.
  • natiny_font_measure_text measures exactly what this draws.