#!/usr/bin/env python3 import struct PATH = '/path/to/pf/ParavisGrub/theme/paravis.pf2' d = open(PATH, 'rb').read() pos = 12 sec = {} while pos + 8 <= len(d): name = d[pos:pos+4] if not all(65 <= c <= 90 for c in name): break length = struct.unpack('>I', d[pos+4:pos+8])[0] body_start = pos + 8 if length == 0xFFFFFFFF: body = d[body_start:] pos = len(d) else: body = d[body_start:body_start + length] pos = body_start + length sec[name] = body chix, data = sec[b'CHIX'], sec[b'DATA'] print('chix', len(chix), 'data', len(data), 'entries', len(chix) / 9) def parse(order): widths = {} for i in range(len(chix) // 9): e = chix[i * 9:(i + 1) * 9] code = int.from_bytes(e[0:4], order) off = int.from_bytes(e[5:9], 'big') rec = data[off:off + 16] if len(rec) < 16: continue w, h, xo, yo, dw, dh, dxo, dyo = struct.unpack('>HHhhhhhh', rec) widths[chr(code) if code < 0x110000 else '?'] = dw return widths for order in ('big', 'little'): w = parse(order) sample = {c: w.get(c) for c in ' A1('} codes = sorted(ord(c) for c in w if c != '?') print(order, 'glyphs', len(w), 'sample', sample, 'range', hex(codes[0]) if codes else '-', hex(codes[-1]) if codes else '-')