natiny_font_create

C
NatinyFont natiny_font_create(NatinyResource resource, float size);

Creates a font from loaded font data.

Parameters

Name Type Description
resource NatinyResource Resource handle containing TrueType font data
size float Font size in drawing units; values at or below 0.0f use 16.0f

Returns

Type Description
NatinyFont Font handle, or 0 if the resource is invalid, the data is not a supported font, or allocation fails

Example

C
NatinyResource res = natiny_resource_load("data/fonts/roboto.ttf");
NatinyFont font = natiny_font_create(res, 24.0f);

Notes

  • Load resource with natiny_resource_load. The font copies its data, so the resource may be destroyed after this call.
  • Text is decoded as UTF-8. Glyphs are cached in the font atlas on demand, and unsupported code points use the font's missing-glyph symbol.
  • In NATINY_SCALE_MODE_HIDPI, glyphs are rasterized at the display scale while font metrics remain in drawing units.
  • Changing a window's scale mode may rebuild live font atlases. The spacings, the fallback and the filtering set on a font survive that rebuild.
  • Destroy the handle with natiny_font_destroy.