How to reduce the size of custom fonts?


The heitit contains commonly used Chinese fonts. I used the C array method to make heiti, but the converted array size is 25M. How can I reduce the size of the self-made font? Generate bin files or other ways?

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

reducethe size of the custom font

What have you tried so far?

I made heiti using a C array method。

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

There are a few ways I can think of to reduce the font’s data size:

  • Disable subpixel rendering if you are using it.
  • Enable compression (slower).
  • Reduce the BPP.
  • Include less characters in the font.

Thank you for your reply. I’ll try it later. I see some lvgl technical forums and see that there are ways to convert fonts into bin files and place them in external storage such as SD card. Do you know how to operate this way?

I tried it some weeks ago.
I converted a chinese font range into binary format and put it on SD-card.

Since version 7.4 (I’m not quite sure) there is the ability to load binary fonts from external memory (e.g. SC-card).

  • The current implementation is reading the entire binary data into allocated memory.
    This needs a lot of heap memory. More than an embedded system might have in general.
  • It needs a lot of time to read in the binary and building up the RAM structures for this font.
  • Your app will crash, if your heap size is inadequate, as it is never checked whether memory allocation has failed.

So it seems to me the only practical method currently would be, to only include the needed glyps into a font library (binary or c-file).

ok, thanks for your suggestion.I’ll try it.