# Tiny TTF Font Engine (/libs/font_support/tiny_ttf)



The lv\_tiny\_ttf extension allows using TrueType fonts in LVGL using the
[stb\_truetype 3rd-Party Library](https://github.com/nothings/stb).

For a detailed introduction, see:  [https://github.com/nothings/stb](https://github.com/nothings/stb).

Usage [#usage]

When enabled in `lv_conf.h` by setting <ApiLink name="LV_USE_TINY_TTF" /> to `1`,
<ApiLink name="lv_tiny_ttf_create_data" display="lv_tiny_ttf_create_data(data, data_size, font_size)" /> can be used to
create a TTF font instance with the specified line height.  You can then
use that font anywhere <ApiLink name="lv_font_t" /> is accepted.

By default, the TTF or OTF file must be embedded as an array, either in
a header, or loaded into RAM in order to function.

However, if <ApiLink name="LV_TINY_TTF_FILE_SUPPORT" /> is enabled (i.e. `1`),
<ApiLink name="lv_tiny_ttf_create_file" display="lv_tiny_ttf_create_file(path, font_size)" /> will also be available,
allowing tiny\_ttf to stream from a file. The file must remain open the
entire time the font is being used.

After a font is created, you can change the font size in pixels by using
<ApiLink name="lv_tiny_ttf_set_size" display="lv_tiny_ttf_set_size(font, font_size)" />.

By default, a font will cache data for up to 256 glyph elements to speed up rendering.
This maximum can be changed by using

<ApiLink name="lv_tiny_ttf_create_data_ex" display="lv_tiny_ttf_create_data_ex(data, data_size, font_size, kerning, cache_size)" />

or <ApiLink name="lv_tiny_ttf_create_file_ex" display="lv_tiny_ttf_create_file_ex(path, font_size, kerning, cache_size)" /> (when
available). The cache size is indicated in number of entries.  The `kerning`
argument will be one of the `LV_FONT_KERNING_...` values, indicating whether to
allow kerning, if supported, or disable.

Examples [#examples]

Open a font with Tiny TTF from data array [#open-a-font-with-tiny-ttf-from-data-array]

<LvglExample name="lv_example_tiny_ttf_1" path="libs/tiny_ttf/lv_example_tiny_ttf_1" />

Load a font with Tiny_TTF from file [#load-a-font-with-tiny_ttf-from-file]

<LvglExample name="lv_example_tiny_ttf_2" path="libs/tiny_ttf/lv_example_tiny_ttf_2" />

Change font size with Tiny_TTF [#change-font-size-with-tiny_ttf]

<LvglExample name="lv_example_tiny_ttf_3" path="libs/tiny_ttf/lv_example_tiny_ttf_3" />

API [#api]
