"""Checks src/RynthCore.Engine/ImGui/PhosphorIcons.cs against the Phosphor font. - every constant's code point is in the font's cmap; - its name matches the font's own name for that code point (the font's ligature table spells each icon's kebab-case name; single-letter names such as "x" have no ligature and are only checked by code point); - Baked holds every constant the ImGui code uses (PhosphorIcons.Name), so no icon draws as nothing because it isn't in the atlas. Needs fontTools (pip install fonttools). Exit code 1 on any problem. Usage: python tools/check_phosphor_icons.py """ import os import re import sys from fontTools.ttLib import TTFont ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ENGINE = os.path.join(ROOT, 'src', 'RynthCore.Engine') FONT = os.path.join(ENGINE, 'Assets', 'Fonts', 'Phosphor.ttf') ICONS = os.path.join(ENGINE, 'ImGui', 'PhosphorIcons.cs') IMGUI = os.path.join(ENGINE, 'ImGui') def ligature_names(font): """{kebab-name: code point} from the font's GSUB ligatures.""" cmap = font.getBestCmap() by_glyph = {} for cp, glyph in cmap.items(): by_glyph.setdefault(glyph, cp) letters = {g: chr(cp) for g, cp in by_glyph.items() if cp < 0x80} names = {} for lookup in font['GSUB'].table.LookupList.Lookup: for sub in lookup.SubTable: if sub.LookupType == 7: sub = sub.ExtSubTable for first, ligs in getattr(sub, 'ligatures', {}).items(): for lig in ligs: name = ''.join(letters.get(g, '?') for g in [first] + list(lig.Component)) if lig.LigGlyph in by_glyph: names[name] = by_glyph[lig.LigGlyph] return names def kebab(pascal): return re.sub(r'(?