-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfont4x5.py
More file actions
83 lines (69 loc) · 3.15 KB
/
font4x5.py
File metadata and controls
83 lines (69 loc) · 3.15 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
# Code generated by font_to_py.py.
# Font: 4x5.otf
# Cmd: ./font_to_py.py 4x5.otf 5 font4x5.py
version = '0.42'
def height():
return 1
def baseline():
return 1
def max_width():
return 9
def hmap():
return True
def reverse():
return False
def monospaced():
return False
def min_ch():
return 32
def max_ch():
return 126
_font =\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
b'\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00\x09\x00\x00\x00'\
_index =\
b'\x00\x00\x04\x00\x08\x00\x0c\x00\x10\x00\x14\x00\x18\x00\x1c\x00'\
b'\x20\x00\x24\x00\x28\x00\x2c\x00\x30\x00\x34\x00\x38\x00\x3c\x00'\
b'\x40\x00\x44\x00\x48\x00\x4c\x00\x50\x00\x54\x00\x58\x00\x5c\x00'\
b'\x60\x00\x64\x00\x68\x00\x6c\x00\x70\x00\x74\x00\x78\x00\x7c\x00'\
b'\x80\x00\x84\x00\x88\x00\x8c\x00\x90\x00\x94\x00\x98\x00\x9c\x00'\
b'\xa0\x00\xa4\x00\xa8\x00\xac\x00\xb0\x00\xb4\x00\xb8\x00\xbc\x00'\
b'\xc0\x00\xc4\x00\xc8\x00\xcc\x00\xd0\x00\xd4\x00\xd8\x00\xdc\x00'\
b'\xe0\x00\xe4\x00\xe8\x00\xec\x00\xf0\x00\xf4\x00\xf8\x00\xfc\x00'\
b'\x00\x01\x04\x01\x08\x01\x0c\x01\x10\x01\x14\x01\x18\x01\x1c\x01'\
b'\x20\x01\x24\x01\x28\x01\x2c\x01\x30\x01\x34\x01\x38\x01\x3c\x01'\
b'\x40\x01\x44\x01\x48\x01\x4c\x01\x50\x01\x54\x01\x58\x01\x5c\x01'\
b'\x60\x01\x64\x01\x68\x01\x6c\x01\x70\x01\x74\x01\x78\x01\x7c\x01'\
b'\x80\x01'
_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) * 1
return _mvfont[doff + 2:next_offs], 1, width