-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont6.py
More file actions
101 lines (87 loc) · 4.37 KB
/
font6.py
File metadata and controls
101 lines (87 loc) · 4.37 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
# Code generated by font_to_py.py.
# Font: 5x5-sans.ttf
# Cmd: ./font_to_py.py 5x5-sans.ttf 5 font5.py
version = '0.42'
def height():
return 6
def baseline():
return 5
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\xf0\x08\x30\x00\x20\x06\x00\x00\x00\x00\x00\x00\x06\x00'\
b'\x20\x20\x20\x00\x20\x06\x00\x50\x50\x00\x00\x00\x06\x00\x50\xf8'\
b'\x50\xf8\x50\x06\x00\x10\x38\x20\xe0\x40\x06\x00\xc8\xd0\x20\x58'\
b'\x98\x06\x00\x40\xa0\x68\x90\x68\x06\x00\x20\x20\x00\x00\x00\x06'\
b'\x00\x20\x40\x40\x40\x20\x06\x00\x40\x20\x20\x20\x40\x06\x00\x50'\
b'\x20\x50\x00\x00\x06\x00\x20\x20\xf8\x20\x20\x06\x00\x00\x00\x00'\
b'\x20\x20\x06\x00\x00\x00\x70\x00\x00\x06\x00\x00\x00\x00\x00\x20'\
b'\x06\x00\x08\x10\x20\x40\x80\x06\x00\x70\x98\xa8\xc8\x70\x06\x00'\
b'\x20\xe0\x20\x20\xf8\x06\x00\x70\x88\x30\x40\xf8\x06\x00\x70\x88'\
b'\x30\x88\x70\x06\x00\x30\x50\x90\xf8\x10\x06\x00\xf8\x80\xf0\x08'\
b'\xf0\x06\x00\x78\x80\xf0\x88\x70\x06\x00\xf8\x10\x20\x40\x40\x06'\
b'\x00\x70\x88\x70\x88\x70\x06\x00\x70\x88\x78\x08\xf0\x06\x00\x00'\
b'\x20\x00\x20\x00\x06\x00\x00\x20\x00\x20\x20\x06\x00\x08\x10\x20'\
b'\x10\x08\x06\x00\x00\x70\x00\x70\x00\x06\x00\x80\x40\x20\x40\x80'\
b'\x06\x00\xf0\x08\x30\x00\x20\x06\x00\x70\xb8\x98\x80\x78\x06\x00'\
b'\x70\x88\xf8\x88\x88\x06\x00\xf0\x88\xf0\x88\xf0\x06\x00\x78\x80'\
b'\x80\x80\x78\x06\x00\xf0\x88\x88\x88\xf0\x06\x00\xf8\x80\xf0\x80'\
b'\xf8\x06\x00\xf8\x80\xf0\x80\x80\x06\x00\x78\x80\xb8\x88\x78\x06'\
b'\x00\x88\x88\xf8\x88\x88\x06\x00\xf8\x20\x20\x20\xf8\x06\x00\x78'\
b'\x10\x10\x90\x60\x06\x00\x88\x90\xe0\x90\x88\x06\x00\x80\x80\x80'\
b'\x80\xf8\x06\x00\x88\xd8\xa8\x88\x88\x06\x00\x88\xc8\xa8\x98\x88'\
b'\x06\x00\x70\x88\x88\x88\x70\x06\x00\xf0\x88\xf0\x80\x80\x06\x00'\
b'\x70\x88\xa8\x90\x68\x06\x00\xf0\x88\xf0\x88\x88\x06\x00\x78\x80'\
b'\x70\x08\xf0\x06\x00\xf8\x20\x20\x20\x20\x06\x00\x88\x88\x88\x88'\
b'\x70\x06\x00\x88\x88\x88\x50\x20\x06\x00\x88\x88\xa8\xd8\x88\x06'\
b'\x00\x88\x50\x20\x50\x88\x06\x00\x88\x88\x70\x20\x20\x06\x00\xf8'\
b'\x10\x20\x40\xf8\x06\x00\x60\x40\x40\x40\x60\x06\x00\x80\x40\x20'\
b'\x10\x08\x06\x00\x30\x10\x10\x10\x30\x06\x00\x20\x50\x00\x00\x00'\
b'\x06\x00\x00\x00\x00\x00\xf8\x06\x00\x40\x20\x00\x00\x00\x06\x00'\
b'\x00\x78\x88\x98\x68\x06\x00\x80\x80\xf0\x88\xf0\x06\x00\x00\x78'\
b'\x80\x80\x78\x06\x00\x08\x08\x78\x88\x78\x06\x00\x70\x88\xf8\x80'\
b'\x78\x06\x00\x18\x20\xf8\x20\x20\x06\x00\x78\x88\x78\x08\xf0\x06'\
b'\x00\x80\x80\xf0\x88\x88\x06\x00\x20\x00\x60\x20\x70\x06\x00\x10'\
b'\x00\x30\x10\xe0\x06\x00\x80\x88\x90\xf0\x88\x06\x00\x60\x20\x20'\
b'\x20\x70\x06\x00\x00\xd0\xa8\xa8\xa8\x06\x00\x00\xf0\x88\x88\x88'\
b'\x06\x00\x00\x70\x88\x88\x70\x06\x00\x00\xf0\x88\xf0\x80\x06\x00'\
b'\x00\x70\x90\x70\x18\x06\x00\x00\xb8\xc0\x80\x80\x06\x00\x00\x18'\
b'\x20\x10\xe0\x06\x00\x20\xf8\x20\x20\x18\x06\x00\x00\x88\x88\x88'\
b'\x78\x06\x00\x00\x88\x88\x50\x20\x06\x00\x00\xa8\xa8\xa8\x50\x06'\
b'\x00\x00\x88\x70\x88\x88\x06\x00\x00\x88\x78\x08\xf0\x06\x00\x00'\
b'\xf8\x10\x60\xf8\x06\x00\x10\x20\x60\x20\x10\x06\x00\x20\x20\x20'\
b'\x20\x20\x06\x00\x40\x20\x30\x20\x40\x06\x00\x00\x48\xb0\x00\x00'\
_index =\
b'\x00\x00\x07\x00\x0e\x00\x15\x00\x1c\x00\x23\x00\x2a\x00\x31\x00'\
b'\x38\x00\x3f\x00\x46\x00\x4d\x00\x54\x00\x5b\x00\x62\x00\x69\x00'\
b'\x70\x00\x77\x00\x7e\x00\x85\x00\x8c\x00\x93\x00\x9a\x00\xa1\x00'\
b'\xa8\x00\xaf\x00\xb6\x00\xbd\x00\xc4\x00\xcb\x00\xd2\x00\xd9\x00'\
b'\xe0\x00\xe7\x00\xee\x00\xf5\x00\xfc\x00\x03\x01\x0a\x01\x11\x01'\
b'\x18\x01\x1f\x01\x26\x01\x2d\x01\x34\x01\x3b\x01\x42\x01\x49\x01'\
b'\x50\x01\x57\x01\x5e\x01\x65\x01\x6c\x01\x73\x01\x7a\x01\x81\x01'\
b'\x88\x01\x8f\x01\x96\x01\x9d\x01\xa4\x01\xab\x01\xb2\x01\xb9\x01'\
b'\xc0\x01\xc7\x01\xce\x01\xd5\x01\xdc\x01\xe3\x01\xea\x01\xf1\x01'\
b'\xf8\x01\xff\x01\x06\x02\x0d\x02\x14\x02\x1b\x02\x22\x02\x29\x02'\
b'\x30\x02\x37\x02\x3e\x02\x45\x02\x4c\x02\x53\x02\x5a\x02\x61\x02'\
b'\x68\x02\x6f\x02\x76\x02\x7d\x02\x84\x02\x8b\x02\x92\x02\x99\x02'\
b'\xa0\x02'
_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) * 5
return _mvfont[doff + 2:next_offs], 5, width