Convert non-TTF/WOFF bitmap fonts to lvgl font format

Description

I have a set of bitmap fonts that I’d like to use in an lvgl project. These fonts store the character data in a very simple uncompressed 1bpp format. Ex:

/*
 * code=65, hex=0x41, ascii="A"
 */
0x06,0x00,  /* 000001100000 */
0x06,0x00,  /* 000001100000 */
0x0F,0x00,  /* 000011110000 */
0x0F,0x00,  /* 000011110000 */
0x0F,0x00,  /* 000011110000 */
0x19,0x80,  /* 000110011000 */
0x19,0x80,  /* 000110011000 */
0x19,0x80,  /* 000110011000 */
0x30,0xC0,  /* 001100001100 */
0x3F,0xC0,  /* 001111111100 */
0x3F,0xC0,  /* 001111111100 */
0x60,0x60,  /* 011000000110 */
0x60,0x60,  /* 011000000110 */
0x60,0x60,  /* 011000000110 */
0x00,0x00,  /* 000000000000 */
0x00,0x00,  /* 000000000000 */

And when I look at lvgl fonts files, I see that the character data is stored in a completely different way. Judging by the fact that each character takes up a different number of bytes, it looks to be packed in some way. Ex:

/* U+0020 " " */
0x0,

/* U+0021 "!" */
0xff, 0xf3, 0xc0,

/* U+0022 "\"" */
0xcf, 0x3c, 0xf3, 0xcc,

/* U+0023 "#" */
0x36, 0x7f, 0xff, 0xe6, 0xc3, 0x67, 0xff, 0xfe,
0x6c, 0x36, 0x0,

I know that I could render the fonts I have myself simply enough, but I’m also using other fonts that are in the lvgl format and would really like to avoid adding complexity/rendering different types of fonts using different methods. So ideally I’d like to convert the fonts I have to lvgl format. Is this something that has been done so I can avoid reinventing a wheel? If not, where can I find details on how the lvgl font packs/stores the character data so that I can convert them?

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

NXP RT1064
MCUExpresso IDE

What LVGL version are you using?

7.8.1

What do you want to achieve?

Create lvgl compatible fonts from other bitmap fonts (not from TrueType/WOFF)

Did you ever figure out a solution to this?

Yes, but…

I couldn’t find anything that already did it, so I dug in, learned the format, and made my own converter. I’d be happy to share it; the only snag is I did it on company time and it’s sitting in a company git rep, so I’m not sure I can just make it public. It’s not a product, just a simple in-house tool, so I’m guessing they won’t mind, but I do need to ask them first. I have a meeting with people that have that authority Monday morning. Maybe if they don’t want me to release the converter, they may be OK with me just converting some fonts for you with it?

If they DO say no, I could help you put together a converter yourself. The worst part about converting is figuring out the lvgl font format. It’s not overly-complicated, just not not immediately intuitive and I could at least give you a head start with that.

LvglBitmapFontConverter.zip (581.3 KB)

I got the OK, so here you go. It’s a .net app written in c#. The documentation is slightly behind, and a little bit app specific, but should still get you going. Just let me know if you need any help with it.

Oh and if you go digging into the code, please remember this was a quick throw-together tool and the code kinda reflects that.