mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04: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.
28 lines
813 B
Python
Executable File
28 lines
813 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from fontpsf import PSF2
|
|
|
|
def print_header(filename):
|
|
font = PSF2.load(filename)
|
|
|
|
print("#pragma once")
|
|
print(f"// This file was autogenerated by psf_to_cpp.py from {font.filename}\n")
|
|
|
|
print(f"const uint8_t font_glyph_size = {font.charsize};")
|
|
print(f"const uint8_t font_glyph_width = {font.dimension[0]};")
|
|
print(f"const uint8_t font_glyph_height = {font.dimension[1]};")
|
|
print(f"const uint16_t font_glyph_count = {font.count};\n")
|
|
|
|
print('const uint8_t font_glyph_data[] = {')
|
|
|
|
for glyph in font:
|
|
print(" ", "".join([f"0x{b:02x}," for b in glyph.data]), end="")
|
|
print(" // {}".format(glyph.description()))
|
|
|
|
print("};")
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
for filename in sys.argv[1:]:
|
|
print_header(filename)
|