-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont8.py
More file actions
113 lines (99 loc) · 5.21 KB
/
font8.py
File metadata and controls
113 lines (99 loc) · 5.21 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Code generated by font_to_py.py.
# Font: lcd-dot-matrix-hd44780u.ttf
# Cmd: ./font_to_py.py ./lcd-dot-matrix-hd44780u.ttf 7 myfont.py
version = '0.42'
def height():
return 8
def baseline():
return 7
def max_width():
return 6
def hmap():
return True
def reverse():
return False
def monospaced():
return False
def min_ch():
return 32
def max_ch():
return 126
_font =\
b'\x06\x00\x70\x88\x08\x10\x20\x00\x20\x06\x00\x00\x00\x00\x00\x00'\
b'\x00\x00\x06\x00\x20\x20\x20\x20\x20\x00\x20\x06\x00\x50\x50\x50'\
b'\x00\x00\x00\x00\x06\x00\x50\x50\xf8\x50\xf8\x50\x50\x06\x00\x20'\
b'\x78\xa0\x70\x28\xf0\x20\x06\x00\xc0\xc8\x10\x20\x40\x98\x18\x06'\
b'\x00\x60\x90\xa0\x40\xa8\x90\x68\x06\x00\x20\x20\x00\x00\x00\x00'\
b'\x00\x06\x00\x10\x20\x40\x40\x40\x20\x10\x06\x00\x40\x20\x10\x10'\
b'\x10\x20\x40\x06\x00\x00\x20\xa8\x70\xa8\x20\x00\x06\x00\x00\x20'\
b'\x20\xf8\x20\x20\x00\x06\x00\x00\x00\x00\x00\x60\x20\x40\x06\x00'\
b'\x00\x00\x00\xf8\x00\x00\x00\x06\x00\x00\x00\x00\x00\x00\x60\x60'\
b'\x06\x00\x00\x08\x10\x20\x40\x80\x00\x06\x00\x70\x88\x98\xa8\xc8'\
b'\x88\x70\x06\x00\x20\x60\x20\x20\x20\x20\x70\x06\x00\x70\x88\x08'\
b'\x10\x20\x40\xf8\x06\x00\xf8\x10\x20\x10\x08\x88\x70\x06\x00\x10'\
b'\x30\x50\x90\xf8\x10\x10\x06\x00\xf8\x80\xf0\x08\x08\x88\x70\x06'\
b'\x00\x30\x40\x80\xf0\x88\x88\x70\x06\x00\xf8\x88\x10\x20\x40\x40'\
b'\x40\x06\x00\x70\x88\x88\x70\x88\x88\x70\x06\x00\x70\x88\x88\x78'\
b'\x08\x10\x60\x06\x00\x00\x60\x60\x00\x60\x60\x00\x06\x00\x00\x60'\
b'\x60\x00\x60\x20\x40\x06\x00\x10\x20\x40\x80\x40\x20\x10\x06\x00'\
b'\x00\x00\xf8\x00\xf8\x00\x00\x06\x00\x40\x20\x10\x08\x10\x20\x40'\
b'\x06\x00\x70\x88\x08\x10\x20\x00\x20\x06\x00\x70\x88\x08\x68\xa8'\
b'\xa8\x70\x06\x00\x70\x88\x88\x88\xf8\x88\x88\x06\x00\xf0\x88\x88'\
b'\xf0\x88\x88\xf0\x06\x00\x70\x88\x80\x80\x80\x88\x70\x06\x00\xf0'\
b'\x88\x88\x88\x88\x88\xf0\x06\x00\xf8\x80\x80\xf0\x80\x80\xf8\x06'\
b'\x00\xf8\x80\x80\xf0\x80\x80\x80\x06\x00\x70\x88\x80\x98\x88\x88'\
b'\x78\x06\x00\x88\x88\x88\xf8\x88\x88\x88\x06\x00\x70\x20\x20\x20'\
b'\x20\x20\x70\x06\x00\x38\x10\x10\x10\x10\x90\x60\x06\x00\x88\x90'\
b'\xa0\xc0\xa0\x90\x88\x06\x00\x80\x80\x80\x80\x80\x80\xf8\x06\x00'\
b'\x88\xd8\xa8\xa8\x88\x88\x88\x06\x00\x88\x88\xc8\xa8\x98\x88\x88'\
b'\x06\x00\x70\x88\x88\x88\x88\x88\x70\x06\x00\xf0\x88\x88\xf0\x80'\
b'\x80\x80\x06\x00\x70\x88\x88\x88\xa8\x90\x68\x06\x00\xf0\x88\x88'\
b'\xf0\xa0\x90\x88\x06\x00\x70\x80\x80\x70\x08\x08\x70\x06\x00\xf8'\
b'\x20\x20\x20\x20\x20\x20\x06\x00\x88\x88\x88\x88\x88\x88\x70\x06'\
b'\x00\x88\x88\x88\x88\x88\x50\x20\x06\x00\x88\x88\x88\xa8\xa8\xa8'\
b'\x50\x06\x00\x88\x88\x50\x20\x50\x88\x88\x06\x00\x88\x88\x88\x50'\
b'\x20\x20\x20\x06\x00\xf8\x08\x10\x20\x40\x80\xf8\x06\x00\x70\x40'\
b'\x40\x40\x40\x40\x70\x06\x00\x00\x80\x40\x20\x10\x08\x00\x06\x00'\
b'\x70\x10\x10\x10\x10\x10\x70\x06\x00\x20\x50\x88\x00\x00\x00\x00'\
b'\x06\x00\x00\x00\x00\x00\x00\x00\xf8\x06\x00\x40\x20\x10\x00\x00'\
b'\x00\x00\x06\x00\x00\x00\x70\x08\x78\x88\x78\x06\x00\x80\x80\xb0'\
b'\xc8\x88\x88\xf0\x06\x00\x00\x00\x70\x80\x80\x88\x70\x06\x00\x08'\
b'\x08\x68\x98\x88\x88\x78\x06\x00\x00\x00\x70\x88\xf8\x80\x70\x06'\
b'\x00\x30\x48\x40\xe0\x40\x40\x40\x06\x00\x00\x00\x78\x88\x78\x08'\
b'\x70\x06\x00\x80\x80\xb0\xc8\x88\x88\x88\x06\x00\x20\x00\x20\x60'\
b'\x20\x20\x70\x06\x00\x10\x00\x30\x10\x10\x90\x60\x06\x00\x80\x80'\
b'\x90\xa0\xc0\xa0\x90\x06\x00\x60\x20\x20\x20\x20\x20\x70\x06\x00'\
b'\x00\x00\xd0\xa8\xa8\xa8\xa8\x06\x00\x00\x00\xb0\xc8\x88\x88\x88'\
b'\x06\x00\x00\x00\x70\x88\x88\x88\x70\x06\x00\x00\x00\xf0\x88\xf0'\
b'\x80\x80\x06\x00\x00\x00\x68\x98\x78\x08\x08\x06\x00\x00\x00\xb0'\
b'\xc8\x80\x80\x80\x06\x00\x00\x00\x70\x80\x70\x08\xf0\x06\x00\x40'\
b'\x40\xe0\x40\x40\x48\x30\x06\x00\x00\x00\x88\x88\x88\x98\x68\x06'\
b'\x00\x00\x00\x88\x88\x88\x50\x20\x06\x00\x00\x00\x88\x88\xa8\xa8'\
b'\x50\x06\x00\x00\x00\x88\x50\x20\x50\x88\x06\x00\x00\x00\x88\x88'\
b'\x78\x08\x70\x06\x00\x00\x00\xf8\x10\x20\x40\xf8\x06\x00\x10\x20'\
b'\x20\x40\x20\x20\x10\x06\x00\x20\x20\x20\x20\x20\x20\x20\x06\x00'\
b'\x40\x20\x20\x10\x20\x20\x40\x06\x00\x00\x00\x00\x68\x90\x00\x00'\
_index =\
b'\x00\x00\x09\x00\x12\x00\x1b\x00\x24\x00\x2d\x00\x36\x00\x3f\x00'\
b'\x48\x00\x51\x00\x5a\x00\x63\x00\x6c\x00\x75\x00\x7e\x00\x87\x00'\
b'\x90\x00\x99\x00\xa2\x00\xab\x00\xb4\x00\xbd\x00\xc6\x00\xcf\x00'\
b'\xd8\x00\xe1\x00\xea\x00\xf3\x00\xfc\x00\x05\x01\x0e\x01\x17\x01'\
b'\x20\x01\x29\x01\x32\x01\x3b\x01\x44\x01\x4d\x01\x56\x01\x5f\x01'\
b'\x68\x01\x71\x01\x7a\x01\x83\x01\x8c\x01\x95\x01\x9e\x01\xa7\x01'\
b'\xb0\x01\xb9\x01\xc2\x01\xcb\x01\xd4\x01\xdd\x01\xe6\x01\xef\x01'\
b'\xf8\x01\x01\x02\x0a\x02\x13\x02\x1c\x02\x25\x02\x2e\x02\x37\x02'\
b'\x40\x02\x49\x02\x52\x02\x5b\x02\x64\x02\x6d\x02\x76\x02\x7f\x02'\
b'\x88\x02\x91\x02\x9a\x02\xa3\x02\xac\x02\xb5\x02\xbe\x02\xc7\x02'\
b'\xd0\x02\xd9\x02\xe2\x02\xeb\x02\xf4\x02\xfd\x02\x06\x03\x0f\x03'\
b'\x18\x03\x21\x03\x2a\x03\x33\x03\x3c\x03\x45\x03\x4e\x03\x57\x03'\
b'\x60\x03'
_mvfont = memoryview(_font)
_mvi = memoryview(_index)
ifb = lambda l : l[0] | (l[1] << 8)
def get_ch(ch):
oc = ord(ch)
ioff = 2 * (oc - 32 + 1) if oc >= 32 and oc <= 126 else 0
doff = ifb(_mvi[ioff : ])
width = ifb(_mvfont[doff : ])
next_offs = doff + 2 + ((width - 1)//8 + 1) * 7
return _mvfont[doff + 2:next_offs], 7, width