"""Tests for tools/fontgen.py — the VT1200 font delivery harness. Covers: PCF table-of-contents parsing, reading/patching the BITMAPS num_chars field (our exploit primitive), BDF generation that bdftopcf accepts, and the TFTP server the terminal will fetch fonts from. """ import os import socket import struct import subprocess import sys import tempfile import unittest HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(HERE, "tools")) import fontgen PCF_MAGIC = b"\x01fcp" BITMAPS = 0x8 BASE_PCF = os.path.join(HERE, "reference", "fonts", "system-10x20.pcf") def build_pcf(entries): """Build a minimal PCF: entries = [(label, format, payload), ...].""" header = PCF_MAGIC + struct.pack("