Home

Awesome

Fonts and Font Writer for the MicroPython framebuffer

This is a set of fonts and a tool to use them, inspired by the u8g2 project, and made for devices with small displays running MicroPython.

Demo Examples on two different displays

These font packs work with my Font Writer and Marquee classes (explained below).

Additionally, these font packs also work with Peter Hinche's writer class and nano-gui, and the EZFont class from Brad Barnett's mpdisplay.

The font packs here were created using my bdf2dict font module creator (see below).


Latin-1 and Symbol Font Packs

The font files are in the Latin-1 and Symbols folders.

These font packs are based on the default U8G2 fonts. They include common X11 fonts, the 'spleen' small font set, OpenIconic icons, tiny fonts, and other symbol/icon fonts.

They come from 112 open and shareable .bdf font definition files covering 11 font families. These have been turned into .py font modules based on the character set(s) they include.

Fonts are organized by font family, then character set and size.

All font modules keep the original copyright notices from the source '.bdf' files. Most fonts are very 'free', but the proportional X11 fonts need extra attention. For more details, check the documentation on the font index pages.

Unicode font packs?

It's not practical to group general Unicode fonts into small enough packs for MicroPython devices. The common Unicode blocks have thousands of characters, and the resulting files would be too large.

Instead, tools and examples are provided to help you make a custom font pack with only the characters you need.


Font Writer: ezFBfont.py

The ezFBfont.py writer class works with these fonts. It takes a string and X, Y position, then writes the string at that position using the selected font. It has options for color, transparency, spacing, and positioning, and can provide info about the written area and support multi-line strings.

For more details, see the documentation in WRITER.md, and check out the examples in the examples folder.

Marquee: ezFBmarquee.py

A simple scrolling banner display that uses the fonts from this repo. You can define an output 'box' and the string will scroll inside it. It supports different scroll modes, adjustable character spacing, and step rates.

For more information, see MARQUEE.md, and check the examples folder for examples of driving the animation with an IRQ timer loop.

Font module creator: bdf2dict.py

All the font packs were made using this tool. It is a simple-to-use CPython (not MicroPython!) script that can import and process a .bdf font file and extract only the characters you need into a .py font module file. It works with Unicode characters and fonts.

For more documentation and usage instructions, see BDF2DICT.md and the Unicode readme for some Unicode fonts and an example of how to use this tool to create a custom font pack.

Display Drivers

The font writer and marquee work with any display that has a MicroPython framebuffer compatible driver.

Drivers for popular monochrome ssd1306 and st7567 displays are in the drivers folder. There is also documentation for finding and using drivers for other displays in the README there.

I have my own version of the ST7789 color TFT display driver that has been tested with the Writer and Marquee classes.

Running on my color driver

If you find a driver that works but is not listed, please let me know by submitting an issue!

Alternatives

If you're building a full 'GUI' or have a large color display, consider the alternatives below. They support bigger displays, full color, have GUI elements, are faster, and use less memory.

The fonts in this repo work with Peter Hinch’s writer and nano-gui classes:

Also from Peter are these display drivers:

Another useful resource for display drivers and GUI elements is Brad Barnett’s mpdisplay:

Finally, for those building fast GUIs on color displays, there is LVGL:


Status

I created ezFBfont, the font packs, and tools to support a project I am working on, as well as several others.

PrintPy, still under development..

This is a 3D printer status and progress display, driven by a Seeedstudio XIAO RP2040, and using my fonts, writer, and marquee.

The fonts, writer, and marquee have been tested on SSD1306 OLED displays and a ST7567 LCD module using I2C, as well as several ST7789 color TFT displays using SPI and i80 busses. Tested MCU's include ESP8266, ESP32, ESP32-S3, ESP32-C3 and RP2040 development boards.