natiny.render.text_box
natiny.render.text_box(font, x, y, w, h, text [, align])
Draws wrapped UTF-8 text inside a layout rectangle on the current render target.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
font |
number |
Font handle from natiny.font.create |
|
x, y |
number |
Top-left corner of the rectangle in drawing units | |
w |
number |
Rectangle width and wrap width in drawing units; values at or below 0 disable wrapping |
|
h |
number |
Rectangle height in drawing units, used only for vertical alignment | |
text |
string |
UTF-8 text to draw | |
align |
number |
natiny.render.ALIGN_LEFT \| natiny.render.ALIGN_TOP |
Horizontal and vertical alignment flags |
Alignment flags
Combine one horizontal flag with one vertical flag using |:
| Axis | Values |
|---|---|
| Horizontal | natiny.render.ALIGN_LEFT, natiny.render.ALIGN_CENTER, natiny.render.ALIGN_RIGHT |
| Vertical | natiny.render.ALIGN_TOP, natiny.render.ALIGN_MIDDLE, natiny.render.ALIGN_BOTTOM |
natiny.render.ALIGN_LEFT and natiny.render.ALIGN_TOP are both 0.
Horizontal alignment is applied to each line separately; vertical alignment
positions the complete text block.
Example
natiny.render.text_box(font, 20, 20, 300, 120, message,
natiny.render.ALIGN_CENTER | natiny.render.ALIGN_MIDDLE)
Notes
- The rectangle controls wrapping and alignment but does not clip. Text may
extend beyond any edge; use
natiny.render.scissor_beginwhen clipping is required. - Wrapping matches
natiny.font.measure_wrapped. - Lines break at spaces and tabs, at
\n, and between Han, kana, and Hangul characters. A word wider thanwis cut where it stops fitting. - Font spacing settings affect both layout and drawing. Glyphs use the color
set by
natiny.render.set_color.