#!/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)
