-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_bdf.py
More file actions
33 lines (27 loc) · 841 Bytes
/
read_bdf.py
File metadata and controls
33 lines (27 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
_charname = None
_bitmap = False
characters = {}
for line in open("terminus-font-4.48/ter-u32b.bdf", mode="rt"):
line = line.strip()
# look for control sequences
if line.startswith("STARTCHAR"):
if _charname:
raise Exception("startchar before endchar")
_charname = line.split(' ', 1)[1]
characters[_charname] = []
continue
if line.startswith("BITMAP"):
if not _charname:
raise Exception("bitmap outside a char definition")
_bitmap = True
continue
if line.startswith("ENDCHAR"):
_charname = None
_bitmap = False
continue
# look for data if in the correct state
if _bitmap:
characters[_charname].append(bytes.fromhex(line))
continue
if __name__ == "__main__":
print(characters.keys())