aboutsummaryrefslogtreecommitdiff
path: root/tools/font8.py
blob: fb2f384f0717a4a7cbcb267a5f390352fe8ec407 (plain)
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
"""Crisp 5x7 bitmap font, centred in an 8x8 cell."""

P = {
'A':"01110 10001 10001 11111 10001 10001 10001",
'B':"11110 10001 10001 11110 10001 10001 11110",
'C':"01110 10001 10000 10000 10000 10001 01110",
'D':"11110 10001 10001 10001 10001 10001 11110",
'E':"11111 10000 10000 11110 10000 10000 11111",
'F':"11111 10000 10000 11110 10000 10000 10000",
'G':"01110 10001 10000 10111 10001 10001 01110",
'H':"10001 10001 10001 11111 10001 10001 10001",
'I':"11111 00100 00100 00100 00100 00100 11111",
'J':"00111 00010 00010 00010 00010 10010 01100",
'K':"10001 10010 10100 11000 10100 10010 10001",
'L':"10000 10000 10000 10000 10000 10000 11111",
'M':"10001 11011 10101 10101 10001 10001 10001",
'N':"10001 11001 10101 10011 10001 10001 10001",
'O':"01110 10001 10001 10001 10001 10001 01110",
'P':"11110 10001 10001 11110 10000 10000 10000",
'Q':"01110 10001 10001 10001 10101 10010 01101",
'R':"11110 10001 10001 11110 10100 10010 10001",
'S':"01111 10000 10000 01110 00001 00001 11110",
'T':"11111 00100 00100 00100 00100 00100 00100",
'U':"10001 10001 10001 10001 10001 10001 01110",
'V':"10001 10001 10001 10001 10001 01010 00100",
'W':"10001 10001 10001 10101 10101 11011 10001",
'X':"10001 10001 01010 00100 01010 10001 10001",
'Y':"10001 10001 01010 00100 00100 00100 00100",
'Z':"11111 00001 00010 00100 01000 10000 11111",
'0':"01110 10001 10011 10101 11001 10001 01110",
'1':"00100 01100 00100 00100 00100 00100 01110",
'2':"01110 10001 00001 00010 00100 01000 11111",
'3':"11111 00010 00100 00010 00001 10001 01110",
'4':"00010 00110 01010 10010 11111 00010 00010",
'5':"11111 10000 11110 00001 00001 10001 01110",
'6':"00110 01000 10000 11110 10001 10001 01110",
'7':"11111 00001 00010 00100 01000 01000 01000",
'8':"01110 10001 10001 01110 10001 10001 01110",
'9':"01110 10001 10001 01111 00001 00010 01100",
'.':"00000 00000 00000 00000 00000 00110 00110",
',':"00000 00000 00000 00000 00110 00110 01100",
'!':"00100 00100 00100 00100 00100 00000 00100",
'?':"01110 10001 00001 00010 00100 00000 00100",
'-':"00000 00000 00000 11111 00000 00000 00000",
"'":"00100 00100 01000 00000 00000 00000 00000",
'(':"00010 00100 01000 01000 01000 00100 00010",
')':"01000 00100 00010 00010 00010 00100 01000",
':':"00000 00110 00110 00000 00110 00110 00000",
'/':"00001 00010 00010 00100 01000 01000 10000",
'<':"00010 00100 01000 10000 01000 00100 00010",
'>':"01000 00100 00010 00001 00010 00100 01000",
' ':"00000 00000 00000 00000 00000 00000 00000",
}

def glyph(ch):
    rows = P.get(ch.upper(), P[' ']).split()
    out = [[0] * 8 for _ in range(8)]
    for y, row in enumerate(rows):
        for x, bit in enumerate(row):
            if bit == '1':
                out[y][x + 1] = 1
    return out