mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
For the fb driver to have a font before loading from disk is available, create a hard-coded font as a byte array. To create this, added a new scripts/psf_to_cpp.py which also refactored out much of scripts/parse_font.py into a new shared module scripts/fontpsf.py.
31 lines
717 B
Python
Executable File
31 lines
717 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from fontpsf import PSF2
|
|
|
|
def print_glyph(header, data):
|
|
bw = (header.width + 7) // 8
|
|
fmt = "{:08b}" * bw
|
|
for y in range(header.height):
|
|
b = data[y*bw:(y+1)*bw]
|
|
s = fmt.format(*b).replace("0", " ").replace("1", "*")
|
|
print(s)
|
|
print("")
|
|
|
|
|
|
def display_font(filename):
|
|
font = PSF2.load(filename)
|
|
print(font.header)
|
|
|
|
for glyph in font:
|
|
if glyph.empty():
|
|
print("{}: BLANK".format(glyph.description()))
|
|
else:
|
|
print("{}:".format(glyph.description()))
|
|
print_glyph(font.header, glyph.data)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
for filename in sys.argv[1:]:
|
|
display_font(filename)
|