# -*- coding: utf-8 -*- """ Generate 100% authentic, pixel-perfect 8x8 IBM VGA bitmap font for CP1251 in font8x8.inc. Extracts official IBM VGA 8x8 font resources directly from C:\\Windows\\Fonts\\app866.fon, mapping CP1251 characters to the corresponding CP866 Cyrillic glyphs. """ import struct from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[2] FONT_INC = REPO_ROOT / 'font8x8.inc' # Load authentic 8x8 font from app866.fon (Resource at offset 8784: 8x8, 256 glyphs) with open('C:/Windows/Fonts/app866.fon', 'rb') as f: fon_data = f.read() font_res = fon_data[8784:8784+3211] raw_glyphs = {} for ch in range(256): entry_off = 0x76 + ch * 4 w, off = struct.unpack('