swarmos/unifont.py
2023-12-30 19:02:37 +07:00

17 lines
487 B
Python

import struct
with open('unifont_all-15.1.04.hex', 'rt') as f:
data = f.readlines()
ret = []
for w in data:
a, w = w.strip().split(':')
e = [int(w[i:i+2], 16) for i in range(0, len(w), 2)]
b = int(a, 16)
ret.append(bytes([len(e) // 16]))
ret.append(bytes([(b >> 16) & 0xFF]))
ret.append(bytes([(b >> 8) & 0xFF]))
ret.append(bytes([(b >> 0) & 0xFF]))
ret.append(bytes(e))
with open('src/unifont.bin', 'wb') as f:
for x in ret:
f.write(x)