Using old BDF fonts in LVGL

Hi, first time here. New to LVGL the last few months but making great progress and driving a variety of displays. Using LVGL v9.2.0 and ESP32-IDF v5.3.1.

I have used the lvgl online font converter to create fonts from ttf quite easily, and this all works well.

Now I am experimenting with some old BFD bitmap fonts for smallish fonts on smaller displays – some successes, some fails. I am converting from BDF bitmap fonts to LVGL C format using bdf2lvgl: bdf2lvgl · PyPI (modified a bit to tweak the output).

But my question is not about the BDF-to-C conversion, but why LVGL fails to load what looks like a good C font and simply drops to fallback. I am likely missing something obvious.

Here are two example fonts:

  1. Spleen is a nice clean font family (Spleen - Monospaced bitmap fonts | Frederic Cambus) and this BDF converts properly to LVGL C and displays well.

  1. An “Apple II” font for nostalgic fun, that I created in the ancient Fony program, and exported as BDF. It converts to LVGL C and compiles fine. However, when it displays, it fails on every char to the fallback (lv_font_montserrat_14).

I have poked around the lvgl source a bit but it is unclear to me just where the decision is made to load the fallback font, or just what in the font C file is causing it to fail.

Can anyone point me in the correct direction? There is something in the C font file that needs to change to let it load properly, which in turn implies something in the BDF is incorrect. The BDF and LVGL C files are attached.
bdf-font-test.zip (874.8 KB)

thx

BTW, the Apple II font I built in Fony (starting from some X11 bdf), also looks like this in FontForge:

I pulled the uppercase etc straight from the Signetics 2513 character generator rom used by the Apple I, the first Apple ][, TV Typewriter, ADM-3… Lowercase pulled from later apple docs.

There are also lots of BDF fonts available for IBM PC and other early computers – guess I am just on a nostalic bent right now :slight_smile: Would love to pull these fonts into LVGL.

I refined the Apple II bdf file in FontForge, which found Bad Glyph Names (that it corrected on export), and I removed glyphs above 0x7F to trim it down, then saved a new bdf. I then ran it through my modified bdf2lvgl script.

However, I still had the same only-displays-fallback-font issue. I then realized the c file had 0 cmap entries (a bdf with just the printable ascii range should have one cmap, and larger unicode fonts have more).

Then I noticed it also hade codepoints for the control chars (0x00 to 0x1F). I removed these in FontForge and tweaked the bdf a bit in a text editor to simplify the properties and verify glyphs were only defined for 0x20 to 0x7F and that is has a single cmap entry.

Finally it converted properly and displayed in lvgl and a double-sized version as well:
bmfont_9px_6x9_apple_II

So I am pretty happy that I got it running.

Attached is my modified bdf2lvgl python script:
gil-modified-bdf2lvgl-0.1.0.zip (31.3 KB)

And some bitmap (1bbp) font files:
gil-master-bdf-fonts.zip (39.2 KB)
gil-master-lvgl-c-fonts-from-bdf2lvgl.zip (52.8 KB)

1 Like

And some screenshots:
gil-font-screenshots.zip (3.2 MB)