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.
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)
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 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:
just a note of thanks for this. Many are using LVGL with smaller monochrome OLED’s and it’s an absolute PITA to try to find and convert TTF pixel fonts that will display properly. I’ve literally spent the equivalent of weeks just trying to recreate simple pixel font styles such as you find in the u8g2 library. The bdf converter is exactly what I was searching for. To give other a jump start I will add that the best TTF fonts I found so far out of hundreds I’ve tried with the font converter are RPG_System, Pixellari, m5x7 and m6 x 11. Set the size to 16 in the LVGL font converter tool. Hopefully I will find a few more nice ones using the bdf converter.
Glad someone found it useful. It was a journey that was frustrating at first but rewarding when I finally got it right. I could not get decent-looking small fonts from a ttf conversion, which is why I started looking at old bitmap fonts. There are a lot that were designed for the original X-Window-System, and it was fun creating the original apple ii font from scratch.
Before I found lvgl, I extracted the salient parts of the adafruit graphics library, and created a small driver for the common 128x64 oled with the ssd3106 controller. I have not tried an lvgl implementation for that same application but I suspect that the rom size will be way-way larger (I was using it on small stm chips).
I don’t expect to use lvgl for that little monochrome display, though I have used lvgl down to little 1.8" 128x160 color displays with the st7735 (but those are crappy-color and no touch). I like the little generic color 1.28" round 240x240 non-touch display (using gc9a01). Waveshare has a nice little 1.69" 240x280 non-touch display (st7789) which has great IPS colors.
While the allure of larger displays is appealing, they invariably use an rbg interface and I quite dislike having to dedicate a giant chunk of system ram for screen buffer(s) and the constant streaming of data consuming cpu/dma time. So for now I am quite happy with the sweet spot of 320x480 and smaller displays which have their own frame buffer and simple spi or i80 interface.
yes LVGL is in general too much for small monochrome OLED’s. It actually doesn’t really natively support anything less than one-byte per pixel so you have to get cute with your flush function. In my case we are trying to use one display library for everything, from a 320x240 full color TFT touch screen to an SH1106 128x64 1.3" monochrome OLED I’m using here. As you say and I reiterated (along with I’m sure thousands of others!) with the small OLED’s it’s super annoying getting good pixel fonts, especially trying to convert from TTF with the LVGL tool. Libraries such as u8g2 and Adafruit GFX have done the heavy-lifting and are geared towards these small displays.
I have you tool setup and have successfully converted a few fonts. I may reply again with my favorites when all said in done - just in case others find this useful.