Add civic font

This commit is contained in:
2026-05-16 15:30:58 -04:00
parent 07289358ca
commit 0a358a3e44
16 changed files with 1444 additions and 28 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
from bdfparser import Font
from PIL import Image
font = Font("civic-segments.bdf")
print(
f"This font's global size is "
f"{font.headers['fbbx']} x {font.headers['fbby']} (pixel), "
f"it contains {len(font)} glyphs."
)
chars_to_export = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
for char_str in chars_to_export:
char = font.glyph(char_str)
bitmap = char.draw()
im = Image.frombytes(
"RGBA",
(bitmap.width(), bitmap.height()),
bitmap.tobytes(
"RGBA",
bytesdict={
0: b"\x00\x00\x00\x00", # transparent background
1: b"\xff\xff\xff\xff", # white glyph
},
),
)
im.save(f"../resources/{char_str}.png", "PNG")