With this free online font converter tool you can create C array from any TTF or WOFF font. You can select ranges of Unicode characters and speficy the bpp (bit-per-pixel).
The font converter is designed to be compatible with LVGL but with minor modification you can make it compatible with other graphics libraries.
The offline version of the converter is available here
How to use the font converter?
- Give name to the output font. E.g. "arial_40"
- Specify the height in px
- Set the bpp (bit-per-piel). Higher value results smoother (anti-aliased) font
- Choose a TTF or WOFF font
- Set a range of Unicode character to include in your font or list the characters in the Symbols field
- Optionally choose and other font too and specify the ranges and/or symbols for it as well. The characters will be merged into the final C file.
- Click the Convert button to download the result C file.
How to use the generated fonts in LVGL?
- Copy the result C file into your LVGL project
- In a C file of your application declare the font as:
extern lv_font_t my_font_name;
or simply LV_FONT_DECLARE(my_font_name);
- Set the font in a style:
style.text.font = &my_font_name;