font454.py — a tiny 4x5 pixel antialiased font for low-resolution displays
Posted: Mon Sep 25, 2017 1:50 pm
Hello micro pythonistas!
MicroPython's famebuf module comes with a built-in font which is fine most of the time, but not always suitable for all use cases. For one, it's pretty large, at 8x8 pixels per character, furthermore, it's monochrome. With microcontrollers, we often have to deal with low-resolution displays, such as small OLED modules or LED matrices. It would be nice to have a font that is smaller and more legible at small sizes.
So I designed this font: https://bitbucket.org/thesheep/font454/src
The characters are only 4×6 pixels (and most of them are actually 5 pixels high), and the font has 4 colors, which you can set while rendering it. The rendering works on any object that has a "pixel" method that takes x, y and color — so you can use a framebuf or a display directly.
I have drawn the letters by hand, trying to make them look friendly (since I'm using them for a game console project), but also legible — that means large x-height, squarish shapes, etc. It contains all standard ASCII characters.
The repository also contains the image and code used to generate the font, and a simple test program that generates the above PNG file. It requires pygame and python3 to run.
MicroPython's famebuf module comes with a built-in font which is fine most of the time, but not always suitable for all use cases. For one, it's pretty large, at 8x8 pixels per character, furthermore, it's monochrome. With microcontrollers, we often have to deal with low-resolution displays, such as small OLED modules or LED matrices. It would be nice to have a font that is smaller and more legible at small sizes.
So I designed this font: https://bitbucket.org/thesheep/font454/src
The characters are only 4×6 pixels (and most of them are actually 5 pixels high), and the font has 4 colors, which you can set while rendering it. The rendering works on any object that has a "pixel" method that takes x, y and color — so you can use a framebuf or a display directly.
I have drawn the letters by hand, trying to make them look friendly (since I'm using them for a game console project), but also legible — that means large x-height, squarish shapes, etc. It contains all standard ASCII characters.
The repository also contains the image and code used to generate the font, and a simple test program that generates the above PNG file. It requires pygame and python3 to run.