natiny.render.text

Lua
natiny.render.text(font, x, y, text)

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

Parameters

Name Type Description
font number Font handle from natiny.font.create
x number X position in pixels
y number Y position in pixels
text string UTF-8 text to draw

Example

Lua
natiny.render.text(font, 20, 20, "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.