natiny.render.text_ex

Lua
natiny.render.text_ex(font, x, y, text [, origin_x, origin_y, rotation])

Draws an unwrapped UTF-8 text block with a local origin and rotation.

Parameters

Name Type Default Description
font number Font handle from natiny.font.create
x, y number Position of the local origin on the current target, in drawing units
text string UTF-8 text to draw
origin_x number 0 Horizontal origin offset from the block's left edge, in drawing units
origin_y number 0 Vertical origin offset from the block's top edge, in drawing units
rotation number 0 Clockwise rotation around (x, y), in degrees

Example

Lua
local text = "SPIN"
local w, h = natiny.font.measure_text(font, text)

natiny.render.text_ex(font, 400, 300, text, w / 2, h / 2, angle)

Notes

  • (origin_x, origin_y) selects the point in the unrotated text block placed at (x, y). The block rotates around that target position.
  • Omitting all optional arguments is equivalent to natiny.render.text.
  • Rotated glyphs are not snapped to the target's pixel grid. At 0 degrees, normal text snapping is preserved.
  • \n starts a new line; all lines rotate together as one block. This function does not perform word wrapping.
  • Glyphs use the color set by natiny.render.set_color.