natiny_render_text_box
void natiny_render_text_box(NatinyFont font, float x, float y,
float w, float h, const char* text,
uint32_t align);
Draws wrapped UTF-8 text inside a layout rectangle on the current render target.
Parameters
| Name | Type | Description |
|---|---|---|
font |
NatinyFont |
Font handle from natiny_font_create |
x, y |
float |
Top-left corner of the rectangle in drawing units |
w |
float |
Rectangle width and wrap width in drawing units; values at or below 0.0f disable wrapping |
h |
float |
Rectangle height in drawing units, used only for vertical alignment |
text |
const char* |
Null-terminated UTF-8 text to draw |
align |
uint32_t |
Horizontal and vertical alignment flags |
Alignment flags
Combine one horizontal flag with one vertical flag using |:
| Axis | Values |
|---|---|
| Horizontal | NATINY_ALIGN_LEFT, NATINY_ALIGN_CENTER, NATINY_ALIGN_RIGHT |
| Vertical | NATINY_ALIGN_TOP, NATINY_ALIGN_MIDDLE, NATINY_ALIGN_BOTTOM |
NATINY_ALIGN_LEFT and NATINY_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.0f, 20.0f, 300.0f, 120.0f, message,
NATINY_ALIGN_CENTER | NATINY_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. - Invalid font handles and
NULLtext are ignored.