I want to make a custom 3x11 font containing just numbers and a colon (for a clock). Is this possible, or do I need to make an entire character set? I’ve had a go with this png:
![]()
and this setup in mkfont.py:
FONT_FILE = "3x11-font.png"
SHEET_WIDTH = 11
SHEET_HEIGHT = 1
FONT_WIDTH = 3
FONT_HEIGHT = 11
CHAR_SPACING_X = 0
CHAR_SPACING_Y = 0
MARGIN_X = 0
MARGIN_Y = 0
CHAR_START = 0x30
CHAR_END = 0x3a
But all I get from python mkfont.py > 3x11-font.py is a zero-byte output file and this error:
Traceback (most recent call last):
File "mkfont.py", line 110, in <module>
font = kern_font(load_font(FONT_FILE))
File "mkfont.py", line 73, in load_font
font[char] = get_char_data(font_image, px, py)
File "mkfont.py", line 57, in get_char_data
palette_index = font_image.getpixel((o_x + x, o_y + y))
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1333, in getpixel
return self.im.getpixel(xy)
IndexError: image index out of range
This is on Raspbian Buster Lite. Python Pillow is installed via pip. The mkfont.py and 3x11-font.png files are in the ~/Pimoroni/scrollphathd/tools folder. Any help appreciated, thanks.