natiny.render.text
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
natiny.render.text(font, 20, 20, "Score: 100")
Notes
textis 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 andmoves to the next tab stop, four spaces apart. Lines are stacked bynatiny.font.get_line_height.- No wrapping: use
natiny.render.text_boxfor text that has to fit a width, andnatiny.render.text_exto turn it. natiny.font.measure_textmeasures exactly what this draws.