Inkplate 2 custom fonts in Python

Customer:

How do I use a custom font in Python on Inkplate 2? I’m translating the Arduino Google Calendar example to Python and everything works except the font handling. The Arduino library uses SourceSansPro_Regular8pt7b.h from the Adafruit GFX font format, but I don’t understand how to represent this in Python. Looking at gfx_standard_font_01.py in the micropython repository, the format isn’t clear to me. Can you explain how the Python font representation works?

Originally submitted via email support on 3 October 2023. Migrated to the forum for community visibility.

Soldered Support:

The gfx_standard_font_01.py file shows the font format in its comments. Each letter is defined with a height and width in the first two bytes, followed by a bitmap where ‘1’ represents a drawn pixel and ‘0’ represents empty space. For example, the letter ‘A’ uses pairs of hex digits that convert to binary to create the character bitmap. You can visualize this by converting the hex values to binary and seeing which pixels are set.

If you’re interested in writing a translator to convert Adafruit GFX .h font files to the micropython format, that would be a useful contribution to the project.

Attachment omitted in migration: image.png