mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[fb] Add default hard-coded font
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.
This commit is contained in:
27
scripts/psf_to_cpp.py
Executable file
27
scripts/psf_to_cpp.py
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user