-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.py
50 lines (45 loc) · 2.42 KB
/
script.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def convert_to_bit_matrix_and_save(hex_font, filename):
"""
Convert a list of hex values representing a font to a bit matrix and save it to a file.
Each character matrix is separated by '---'.
"""
with open(filename, 'w') as file:
for char in hex_font:
char_matrix = [f"{num:08b}" for num in char] # Convert each hex to binary string
formatted_matrix = [" ".join(row) for row in char_matrix]
file.write("\n".join(formatted_matrix) + "\n---------------\n")
hex_fonts = [
[0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00], # 0x60, `
[0x00, 0x0e, 0x01, 0x0d, 0x13, 0x13, 0x0d], # 0x61, a
[0x10, 0x10, 0x10, 0x1c, 0x12, 0x12, 0x1c], # 0x62, b
[0x00, 0x00, 0x00, 0x0e, 0x10, 0x10, 0x0e], # 0x63, c
[0x01, 0x01, 0x01, 0x07, 0x09, 0x09, 0x07], # 0x64, d
[0x00, 0x00, 0x0e, 0x11, 0x1f, 0x10, 0x0f], # 0x65, e
[0x06, 0x09, 0x08, 0x1c, 0x08, 0x08, 0x08], # 0x66, f
[0x0e, 0x11, 0x13, 0x0d, 0x01, 0x01, 0x0e], # 0x67, g
[0x10, 0x10, 0x10, 0x16, 0x19, 0x11, 0x11], # 0x68, h
[0x00, 0x04, 0x00, 0x0c, 0x04, 0x04, 0x0e], # 0x69, i
[0x02, 0x00, 0x06, 0x02, 0x02, 0x12, 0x0c], # 0x6a, j
[0x10, 0x10, 0x12, 0x14, 0x18, 0x14, 0x12], # 0x6b, k
[0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04], # 0x6c, l
[0x00, 0x00, 0x0a, 0x15, 0x15, 0x11, 0x11], # 0x6d, m
[0x00, 0x00, 0x16, 0x19, 0x11, 0x11, 0x11], # 0x6e, n
[0x00, 0x00, 0x0e, 0x11, 0x11, 0x11, 0x0e], # 0x6f, o
[0x00, 0x1c, 0x12, 0x12, 0x1c, 0x10, 0x10], # 0x70, p
[0x00, 0x07, 0x09, 0x09, 0x07, 0x01, 0x01], # 0x71, q
[0x00, 0x00, 0x16, 0x19, 0x10, 0x10, 0x10], # 0x72, r
[0x00, 0x00, 0x0f, 0x10, 0x0e, 0x01, 0x1e], # 0x73, s
[0x08, 0x08, 0x1c, 0x08, 0x08, 0x09, 0x06], # 0x74, t
[0x00, 0x00, 0x11, 0x11, 0x11, 0x13, 0x0d], # 0x75, u
[0x00, 0x00, 0x11, 0x11, 0x11, 0x0a, 0x04], # 0x76, v
[0x00, 0x00, 0x11, 0x11, 0x15, 0x15, 0x0a], # 0x77, w
[0x00, 0x00, 0x11, 0x0a, 0x04, 0x0a, 0x11], # 0x78, x
[0x00, 0x11, 0x11, 0x0f, 0x01, 0x11, 0x0e], # 0x79, y
[0x00, 0x00, 0x1f, 0x02, 0x04, 0x08, 0x1f], # 0x7a, z
[0x06, 0x08, 0x08, 0x10, 0x08, 0x08, 0x06], # 0x7b, {
[0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04], # 0x7c, |
[0x0c, 0x02, 0x02, 0x01, 0x02, 0x02, 0x0c], # 0x7d, }
[0x08, 0x15, 0x02, 0x00, 0x00, 0x00, 0x00], # 0x7e, ~
[0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f]
]
convert_to_bit_matrix_and_save(hex_fonts, "./fonts.txt")