diff options
Diffstat (limited to 'tools/font8.py')
| -rw-r--r-- | tools/font8.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/font8.py b/tools/font8.py new file mode 100644 index 0000000..fb2f384 --- /dev/null +++ b/tools/font8.py @@ -0,0 +1,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 |
