badterm-core 0.3.4

Terminal emulation, telnet protocol and dialing directory for the BadTerm BBS client
Documentation
#!/usr/bin/env python3
"""BadTerm's 6x6 font, for IGS's smallest text (the Atari ST's 8-point
system font size): ASCII 0x20-0x7E, drawn for BadTerm, five pixels wide and
caps five high in a 6x6 cell. Writes font6x6.bin next to this script: 256
glyphs x 6 bytes, the top six bits of each byte, most significant leftmost
(glyphs outside ASCII are blank; IGS falls back to the 8x8 font for them).

    python3 make_font6.py
"""

from pathlib import Path

G = {
    ' ': ".....|.....|.....|.....|.....|.....",
    '!': "..#..|..#..|..#..|.....|..#..|.....",
    '"': ".#.#.|.#.#.|.....|.....|.....|.....",
    '#': ".#.#.|#####|.#.#.|#####|.#.#.|.....",
    '$': ".####|#.#..|.###.|..#.#|####.|.....",
    '%': "##..#|##.#.|..#..|.#.##|#..##|.....",
    '&': ".##..|#..#.|.##.#|#..#.|.##.#|.....",
    "'": "..#..|..#..|.....|.....|.....|.....",
    '(': "...#.|..#..|..#..|..#..|...#.|.....",
    ')': ".#...|..#..|..#..|..#..|.#...|.....",
    '*': ".....|.#.#.|..#..|.#.#.|.....|.....",
    '+': ".....|..#..|.###.|..#..|.....|.....",
    ',': ".....|.....|.....|..#..|..#..|.#...",
    '-': ".....|.....|.###.|.....|.....|.....",
    '.': ".....|.....|.....|.....|..#..|.....",
    '/': "....#|...#.|..#..|.#...|#....|.....",
    '0': ".###.|#..##|#.#.#|##..#|.###.|.....",
    '1': "..#..|.##..|..#..|..#..|.###.|.....",
    '2': ".###.|#...#|..##.|.#...|#####|.....",
    '3': "####.|....#|.###.|....#|####.|.....",
    '4': "...#.|..##.|.#.#.|#####|...#.|.....",
    '5': "#####|#....|####.|....#|####.|.....",
    '6': ".###.|#....|####.|#...#|.###.|.....",
    '7': "#####|...#.|..#..|.#...|.#...|.....",
    '8': ".###.|#...#|.###.|#...#|.###.|.....",
    '9': ".###.|#...#|.####|....#|.###.|.....",
    ':': ".....|..#..|.....|..#..|.....|.....",
    ';': ".....|..#..|.....|..#..|..#..|.#...",
    '<': "...#.|..#..|.#...|..#..|...#.|.....",
    '=': ".....|.###.|.....|.###.|.....|.....",
    '>': ".#...|..#..|...#.|..#..|.#...|.....",
    '?': ".###.|#...#|..##.|.....|..#..|.....",
    '@': ".###.|#.###|#.#.#|#.###|.##..|.....",
    'A': ".###.|#...#|#####|#...#|#...#|.....",
    'B': "####.|#...#|####.|#...#|####.|.....",
    'C': ".####|#....|#....|#....|.####|.....",
    'D': "####.|#...#|#...#|#...#|####.|.....",
    'E': "#####|#....|####.|#....|#####|.....",
    'F': "#####|#....|####.|#....|#....|.....",
    'G': ".####|#....|#..##|#...#|.###.|.....",
    'H': "#...#|#...#|#####|#...#|#...#|.....",
    'I': ".###.|..#..|..#..|..#..|.###.|.....",
    'J': "..###|...#.|...#.|#..#.|.##..|.....",
    'K': "#..#.|#.#..|##...|#.#..|#..#.|.....",
    'L': "#....|#....|#....|#....|#####|.....",
    'M': "#...#|##.##|#.#.#|#...#|#...#|.....",
    'N': "#...#|##..#|#.#.#|#..##|#...#|.....",
    'O': ".###.|#...#|#...#|#...#|.###.|.....",
    'P': "####.|#...#|####.|#....|#....|.....",
    'Q': ".###.|#...#|#.#.#|#..#.|.##.#|.....",
    'R': "####.|#...#|####.|#..#.|#...#|.....",
    'S': ".####|#....|.###.|....#|####.|.....",
    'T': "#####|..#..|..#..|..#..|..#..|.....",
    'U': "#...#|#...#|#...#|#...#|.###.|.....",
    'V': "#...#|#...#|#...#|.#.#.|..#..|.....",
    'W': "#...#|#...#|#.#.#|##.##|#...#|.....",
    'X': "#...#|.#.#.|..#..|.#.#.|#...#|.....",
    'Y': "#...#|.#.#.|..#..|..#..|..#..|.....",
    'Z': "#####|...#.|..#..|.#...|#####|.....",
    '[': ".###.|.#...|.#...|.#...|.###.|.....",
    '\\': "#....|.#...|..#..|...#.|....#|.....",
    ']': ".###.|...#.|...#.|...#.|.###.|.....",
    '^': "..#..|.#.#.|#...#|.....|.....|.....",
    '_': ".....|.....|.....|.....|.....|#####",
    '`': ".#...|..#..|.....|.....|.....|.....",
    'a': ".....|.###.|....#|.####|.####|.....",
    'b': "#....|#....|####.|#...#|####.|.....",
    'c': ".....|.####|#....|#....|.####|.....",
    'd': "....#|....#|.####|#...#|.####|.....",
    'e': ".....|.###.|#####|#....|.###.|.....",
    'f': "..##.|.#...|###..|.#...|.#...|.....",
    'g': ".....|.####|#...#|.####|....#|.###.",
    'h': "#....|#....|####.|#...#|#...#|.....",
    'i': "..#..|.....|.##..|..#..|.###.|.....",
    'j': "...#.|.....|..##.|...#.|...#.|.##..",
    'k': "#....|#..#.|###..|#..#.|#...#|.....",
    'l': ".##..|..#..|..#..|..#..|.###.|.....",
    'm': ".....|##.#.|#.#.#|#.#.#|#...#|.....",
    'n': ".....|####.|#...#|#...#|#...#|.....",
    'o': ".....|.###.|#...#|#...#|.###.|.....",
    'p': ".....|####.|#...#|####.|#....|#....",
    'q': ".....|.####|#...#|.####|....#|....#",
    'r': ".....|#.##.|##...|#....|#....|.....",
    's': ".....|.####|.##..|...##|####.|.....",
    't': ".#...|###..|.#...|.#...|..##.|.....",
    'u': ".....|#...#|#...#|#...#|.####|.....",
    'v': ".....|#...#|#...#|.#.#.|..#..|.....",
    'w': ".....|#...#|#.#.#|#.#.#|.#.#.|.....",
    'x': ".....|#...#|.###.|.###.|#...#|.....",
    'y': ".....|#...#|#...#|.####|....#|.###.",
    'z': ".....|#####|..##.|.##..|#####|.....",
    '{': "...##|..#..|.##..|..#..|...##|.....",
    '|': "..#..|..#..|..#..|..#..|..#..|.....",
    '}': "##...|..#..|..##.|..#..|##...|.....",
    '~': ".....|.#..#|#.##.|.....|.....|.....",
}

out = bytearray(256 * 6)
for ch, art in G.items():
    rows = art.split("|")
    assert len(rows) == 6 and all(len(r) == 5 for r in rows), ch
    for y, row in enumerate(rows):
        out[ord(ch) * 6 + y] = sum(0x80 >> x for x, c in enumerate(row) if c == "#")
assert len(G) == 95
(Path(__file__).resolve().parent / "font6x6.bin").write_bytes(bytes(out))