Convert OTF/TTF Fonts to BDF for CircuitPython

last updated: 2020-01-28

After trying the official tutorial for creating a new BDF font for use with CircuitPython, I found a much easier way than dealing with FontForge. FontForge might be a great tool for other purposes, but for this... not so much.

In my testing I used Ubuntu via Windows Subsystem for Linux. Other systems might be different.

Install otf2bdf tool using your package manager:

sudo apt install otf2bdf

Convert font like so:

otf2bdf [fontname].(ttf|otf) -r 100 -p [point-size] -o [fontname]-[point-size].bdf

For my PyGamer, I was trying to make a custom font to use with PyBadger and found that 36 was the best point size to fit my name in the white box where your name displays. You may need to tweak this depending on the length of your name and the font you use. Be sure to set name_scale to 1. This will display your text at the native resolution of the font, rather than scaling it up. If you use a name_scale greater than 1, you will get jagged edges as the font glyphs are bitmaps and simply scaled up, not re-rendered at the larger size.

Copy your newly minted .bdf over to your CIRCUITPY device in the root directory. If you are using the example PyBadger script, you will want something like this:

from adafruit_pybadger import PyBadger

badge = PyBadger()

while True: