natiny_font_measure_text

C
void natiny_font_measure_text(NatinyFont font, const char* text,
                              float* width, float* height);

Writes the width and height of an unwrapped text block to optional output pointers.

Parameters

Name Type Description
font NatinyFont Font handle from natiny_font_create
text const char* Null-terminated UTF-8 text
width float* Receives the widest-line width in drawing units; may be NULL
height float* Receives the block height in drawing units; may be NULL

Example

C
float width = 0.0f;
float height = 0.0f;

natiny_font_measure_text(font, "Hello!", &width, &height);
natiny_render_text(font,
                   (800.0f - width) * 0.5f,
                   (600.0f - height) * 0.5f,
                   "Hello!");