summaryrefslogtreecommitdiff
path: root/include/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-11-29 22:08:28 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-11-29 22:08:28 +0100
commite54cf737b446355b5863a7f31fe4d5d89d037ea4 (patch)
tree3bfc88dd2ac97cfe6906937926879925e03780ae /include/lib
parent131f82839404f176a82330ac7fda20445a97cd88 (diff)
Add Terminus 16-pixel font
Diffstat (limited to 'include/lib')
-rw-r--r--include/lib/pixelfont/terminus16.h209
-rwxr-xr-xinclude/lib/pixelfont/ttf-to-font.py36
2 files changed, 245 insertions, 0 deletions
diff --git a/include/lib/pixelfont/terminus16.h b/include/lib/pixelfont/terminus16.h
new file mode 100644
index 0000000..0f1a581
--- /dev/null
+++ b/include/lib/pixelfont/terminus16.h
@@ -0,0 +1,209 @@
+#pragma once
+/*
+ * Terminus Font
+ *
+ * Copyright 2010 Dimitar Toshkov Zhekov
+ * Copyright 2011 Tilman Blumenbach
+ *
+ * SPDX-License-Identifier: OFL-1.1
+ */
+
+#ifdef MULTIPASS_ARCH_arduino_nano
+#include <avr/pgmspace.h>
+#define GLYPH_ATTR PROGMEM
+#else
+#define GLYPH_ATTR
+#endif
+glyph_line_t GLYPH_ATTR chr_032[] = {0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; // <spac>
+glyph_line_t GLYPH_ATTR chr_033[] = {0x1b,0xf8}; // !
+glyph_line_t GLYPH_ATTR chr_034[] = {0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x1c}; // "
+glyph_line_t GLYPH_ATTR chr_035[] = {0x02,0x40,0x1f,0xf8,0x02,0x40,0x02,0x40,0x1f,0xf8,0x02,0x40}; // #
+glyph_line_t GLYPH_ATTR chr_036[] = {0x08,0xe0,0x11,0x10,0x11,0x10,0x7f,0xfc,0x11,0x10,0x11,0x10,0x0e,0x20}; // $
+glyph_line_t GLYPH_ATTR chr_037[] = {0x00,0x10,0x18,0x28,0x06,0x28,0x09,0x90,0x14,0x60,0x14,0x18,0x08,0x00}; // %
+glyph_line_t GLYPH_ATTR chr_038[] = {0x0f,0x00,0x10,0xb0,0x10,0xc8,0x11,0x48,0x0e,0x30,0x11,0x00}; // &
+glyph_line_t GLYPH_ATTR chr_039[] = {0x00,0x1c}; // '
+glyph_line_t GLYPH_ATTR chr_040[] = {0x07,0xe0,0x08,0x10,0x10,0x08}; // (
+glyph_line_t GLYPH_ATTR chr_041[] = {0x10,0x08,0x08,0x10,0x07,0xe0}; // )
+glyph_line_t GLYPH_ATTR chr_042[] = {0x01,0x00,0x05,0x40,0x03,0x80,0x03,0x80,0x05,0x40,0x01,0x00}; // *
+glyph_line_t GLYPH_ATTR chr_043[] = {0x01,0x00,0x01,0x00,0x07,0xc0,0x01,0x00,0x01,0x00}; // +
+glyph_line_t GLYPH_ATTR chr_044[] = {0x20,0x00,0x18,0x00}; // ,
+glyph_line_t GLYPH_ATTR chr_045[] = {0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00}; // -
+glyph_line_t GLYPH_ATTR chr_046[] = {0x18,0x00}; // .
+glyph_line_t GLYPH_ATTR chr_047[] = {0x18,0x00,0x06,0x00,0x01,0x80,0x00,0x60,0x00,0x18}; // /
+glyph_line_t GLYPH_ATTR chr_048[] = {0x0f,0xf0,0x12,0x08,0x11,0x08,0x10,0x88,0x10,0x48,0x0f,0xf0}; // 0
+glyph_line_t GLYPH_ATTR chr_049[] = {0x10,0x20,0x10,0x10,0x1f,0xf8,0x10,0x00,0x10,0x00}; // 1
+glyph_line_t GLYPH_ATTR chr_050[] = {0x18,0x30,0x14,0x08,0x12,0x08,0x11,0x08,0x10,0x88,0x10,0x70}; // 2
+glyph_line_t GLYPH_ATTR chr_051[] = {0x0c,0x30,0x10,0x08,0x10,0x88,0x10,0x88,0x10,0x88,0x0f,0x70}; // 3
+glyph_line_t GLYPH_ATTR chr_052[] = {0x03,0x00,0x02,0x80,0x02,0x40,0x02,0x20,0x02,0x10,0x1f,0xf8}; // 4
+glyph_line_t GLYPH_ATTR chr_053[] = {0x08,0xf8,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x0f,0x08}; // 5
+glyph_line_t GLYPH_ATTR chr_054[] = {0x0f,0xe0,0x10,0x90,0x10,0x88,0x10,0x88,0x10,0x88,0x0f,0x00}; // 6
+glyph_line_t GLYPH_ATTR chr_055[] = {0x00,0x08,0x00,0x08,0x1c,0x08,0x03,0x08,0x00,0xc8,0x00,0x38}; // 7
+glyph_line_t GLYPH_ATTR chr_056[] = {0x0f,0x70,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x0f,0x70}; // 8
+glyph_line_t GLYPH_ATTR chr_057[] = {0x00,0xf0,0x11,0x08,0x11,0x08,0x11,0x08,0x09,0x08,0x07,0xf0}; // 9
+glyph_line_t GLYPH_ATTR chr_058[] = {0x18,0xc0}; // :
+glyph_line_t GLYPH_ATTR chr_059[] = {0x20,0x00,0x18,0xc0}; // ;
+glyph_line_t GLYPH_ATTR chr_060[] = {0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x10,0x10}; // <
+glyph_line_t GLYPH_ATTR chr_061[] = {0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40}; // =
+glyph_line_t GLYPH_ATTR chr_062[] = {0x10,0x10,0x08,0x20,0x04,0x40,0x02,0x80,0x01,0x00}; // >
+glyph_line_t GLYPH_ATTR chr_063[] = {0x00,0x70,0x00,0x08,0x00,0x08,0x1b,0x08,0x00,0x88,0x00,0x70}; // ?
+glyph_line_t GLYPH_ATTR chr_064[] = {0x0f,0xf0,0x10,0x08,0x13,0xc8,0x14,0x28,0x14,0x28,0x12,0x28,0x17,0xf0}; // @
+glyph_line_t GLYPH_ATTR chr_065[] = {0x1f,0xf0,0x01,0x08,0x01,0x08,0x01,0x08,0x01,0x08,0x1f,0xf0}; // A
+glyph_line_t GLYPH_ATTR chr_066[] = {0x1f,0xf8,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x0f,0x70}; // B
+glyph_line_t GLYPH_ATTR chr_067[] = {0x0f,0xf0,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x0c,0x30}; // C
+glyph_line_t GLYPH_ATTR chr_068[] = {0x1f,0xf8,0x10,0x08,0x10,0x08,0x10,0x08,0x08,0x10,0x07,0xe0}; // D
+glyph_line_t GLYPH_ATTR chr_069[] = {0x1f,0xf8,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x08,0x10,0x08}; // E
+glyph_line_t GLYPH_ATTR chr_070[] = {0x1f,0xf8,0x00,0x88,0x00,0x88,0x00,0x88,0x00,0x08,0x00,0x08}; // F
+glyph_line_t GLYPH_ATTR chr_071[] = {0x0f,0xf0,0x10,0x08,0x10,0x08,0x11,0x08,0x11,0x08,0x0f,0x30}; // G
+glyph_line_t GLYPH_ATTR chr_072[] = {0x1f,0xf8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x1f,0xf8}; // H
+glyph_line_t GLYPH_ATTR chr_073[] = {0x10,0x08,0x1f,0xf8,0x10,0x08}; // I
+glyph_line_t GLYPH_ATTR chr_074[] = {0x0c,0x00,0x10,0x00,0x10,0x00,0x10,0x08,0x0f,0xf8,0x00,0x08}; // J
+glyph_line_t GLYPH_ATTR chr_075[] = {0x1f,0xf8,0x01,0x80,0x02,0x40,0x04,0x20,0x08,0x10,0x10,0x08}; // K
+glyph_line_t GLYPH_ATTR chr_076[] = {0x1f,0xf8,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00}; // L
+glyph_line_t GLYPH_ATTR chr_077[] = {0x1f,0xf8,0x00,0x10,0x00,0x20,0x00,0xc0,0x00,0x20,0x00,0x10,0x1f,0xf8}; // M
+glyph_line_t GLYPH_ATTR chr_078[] = {0x1f,0xf8,0x00,0x40,0x00,0x80,0x01,0x00,0x02,0x00,0x1f,0xf8}; // N
+glyph_line_t GLYPH_ATTR chr_079[] = {0x0f,0xf0,0x10,0x08,0x10,0x08,0x10,0x08,0x10,0x08,0x0f,0xf0}; // O
+glyph_line_t GLYPH_ATTR chr_080[] = {0x1f,0xf8,0x01,0x08,0x01,0x08,0x01,0x08,0x01,0x08,0x00,0xf0}; // P
+glyph_line_t GLYPH_ATTR chr_081[] = {0x0f,0xf0,0x10,0x08,0x10,0x08,0x18,0x08,0x10,0x08,0x2f,0xf0}; // Q
+glyph_line_t GLYPH_ATTR chr_082[] = {0x1f,0xf8,0x01,0x08,0x03,0x08,0x05,0x08,0x09,0x08,0x10,0xf0}; // R
+glyph_line_t GLYPH_ATTR chr_083[] = {0x0c,0x70,0x10,0x88,0x10,0x88,0x10,0x88,0x10,0x88,0x0f,0x10}; // S
+glyph_line_t GLYPH_ATTR chr_084[] = {0x00,0x08,0x00,0x08,0x00,0x08,0x1f,0xf8,0x00,0x08,0x00,0x08,0x00,0x08}; // T
+glyph_line_t GLYPH_ATTR chr_085[] = {0x0f,0xf8,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x0f,0xf8}; // U
+glyph_line_t GLYPH_ATTR chr_086[] = {0x00,0xf8,0x07,0x00,0x18,0x00,0x18,0x00,0x07,0x00,0x00,0xf8}; // V
+glyph_line_t GLYPH_ATTR chr_087[] = {0x1f,0xf8,0x08,0x00,0x04,0x00,0x03,0x00,0x04,0x00,0x08,0x00,0x1f,0xf8}; // W
+glyph_line_t GLYPH_ATTR chr_088[] = {0x18,0x18,0x06,0x60,0x01,0x80,0x01,0x80,0x06,0x60,0x18,0x18}; // X
+glyph_line_t GLYPH_ATTR chr_089[] = {0x00,0x18,0x00,0x60,0x00,0x80,0x1f,0x00,0x00,0x80,0x00,0x60,0x00,0x18}; // Y
+glyph_line_t GLYPH_ATTR chr_090[] = {0x1c,0x08,0x12,0x08,0x11,0x08,0x10,0x88,0x10,0x48,0x10,0x38}; // Z
+glyph_line_t GLYPH_ATTR chr_091[] = {0x1f,0xf8,0x10,0x08,0x10,0x08}; // [
+glyph_line_t GLYPH_ATTR chr_092[] = {0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00}; // \
+glyph_line_t GLYPH_ATTR chr_093[] = {0x10,0x08,0x10,0x08,0x1f,0xf8}; // ]
+glyph_line_t GLYPH_ATTR chr_094[] = {0x00,0x10,0x00,0x08,0x00,0x04,0x00,0x08,0x00,0x10}; // ^
+glyph_line_t GLYPH_ATTR chr_095[] = {0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00}; // _
+glyph_line_t GLYPH_ATTR chr_096[] = {0x00,0x02,0x00,0x04}; // `
+glyph_line_t GLYPH_ATTR chr_097[] = {0x0e,0x00,0x11,0x40,0x11,0x40,0x11,0x40,0x11,0x40,0x1f,0x80}; // a
+glyph_line_t GLYPH_ATTR chr_098[] = {0x1f,0xf8,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0x0f,0x80}; // b
+glyph_line_t GLYPH_ATTR chr_099[] = {0x0f,0x80,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0x08,0x80}; // c
+glyph_line_t GLYPH_ATTR chr_100[] = {0x0f,0x80,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0x1f,0xf8}; // d
+glyph_line_t GLYPH_ATTR chr_101[] = {0x0f,0x80,0x12,0x40,0x12,0x40,0x12,0x40,0x12,0x40,0x03,0x80}; // e
+glyph_line_t GLYPH_ATTR chr_102[] = {0x00,0x40,0x00,0x40,0x1f,0xf0,0x00,0x48,0x00,0x48,0x00,0x08}; // f
+glyph_line_t GLYPH_ATTR chr_103[] = {0x0f,0x80,0x50,0x40,0x50,0x40,0x50,0x40,0x50,0x40,0x3f,0xc0}; // g
+glyph_line_t GLYPH_ATTR chr_104[] = {0x1f,0xf8,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x1f,0x80}; // h
+glyph_line_t GLYPH_ATTR chr_105[] = {0x10,0x40,0x1f,0xd8,0x10,0x00}; // i
+glyph_line_t GLYPH_ATTR chr_106[] = {0x30,0x00,0x40,0x00,0x40,0x00,0x40,0x40,0x3f,0xd8}; // j
+glyph_line_t GLYPH_ATTR chr_107[] = {0x1f,0xf8,0x02,0x00,0x02,0x00,0x05,0x00,0x08,0x80,0x10,0x40}; // k
+glyph_line_t GLYPH_ATTR chr_108[] = {0x10,0x08,0x1f,0xf8,0x10,0x00}; // l
+glyph_line_t GLYPH_ATTR chr_109[] = {0x1f,0xc0,0x00,0x40,0x00,0x40,0x1f,0xc0,0x00,0x40,0x00,0x40,0x1f,0x80}; // m
+glyph_line_t GLYPH_ATTR chr_110[] = {0x1f,0xc0,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x1f,0x80}; // n
+glyph_line_t GLYPH_ATTR chr_111[] = {0x0f,0x80,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0x0f,0x80}; // o
+glyph_line_t GLYPH_ATTR chr_112[] = {0x7f,0xc0,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0x0f,0x80}; // p
+glyph_line_t GLYPH_ATTR chr_113[] = {0x0f,0x80,0x10,0x40,0x10,0x40,0x10,0x40,0x10,0x40,0x7f,0xc0}; // q
+glyph_line_t GLYPH_ATTR chr_114[] = {0x1f,0xc0,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40}; // r
+glyph_line_t GLYPH_ATTR chr_115[] = {0x11,0x80,0x12,0x40,0x12,0x40,0x12,0x40,0x12,0x40,0x0c,0x40}; // s
+glyph_line_t GLYPH_ATTR chr_116[] = {0x00,0x40,0x00,0x40,0x0f,0xf8,0x10,0x40,0x10,0x40,0x10,0x00}; // t
+glyph_line_t GLYPH_ATTR chr_117[] = {0x0f,0xc0,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x1f,0xc0}; // u
+glyph_line_t GLYPH_ATTR chr_118[] = {0x01,0xc0,0x06,0x00,0x18,0x00,0x18,0x00,0x06,0x00,0x01,0xc0}; // v
+glyph_line_t GLYPH_ATTR chr_119[] = {0x0f,0xc0,0x10,0x00,0x10,0x00,0x1f,0x00,0x10,0x00,0x10,0x00,0x0f,0xc0}; // w
+glyph_line_t GLYPH_ATTR chr_120[] = {0x18,0xc0,0x05,0x00,0x02,0x00,0x02,0x00,0x05,0x00,0x18,0xc0}; // x
+glyph_line_t GLYPH_ATTR chr_121[] = {0x0f,0xc0,0x50,0x00,0x50,0x00,0x50,0x00,0x50,0x00,0x3f,0xc0}; // y
+glyph_line_t GLYPH_ATTR chr_122[] = {0x18,0x40,0x14,0x40,0x12,0x40,0x11,0x40,0x10,0xc0,0x10,0x40}; // z
+glyph_line_t GLYPH_ATTR chr_123[] = {0x00,0x80,0x0f,0x70,0x10,0x08,0x10,0x08}; // {
+glyph_line_t GLYPH_ATTR chr_124[] = {0x1f,0xf8}; // |
+glyph_line_t GLYPH_ATTR chr_125[] = {0x10,0x08,0x10,0x08,0x0f,0x70,0x00,0x80}; // }
+glyph_line_t GLYPH_ATTR chr_126[] = {0x00,0x18,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x0c}; // ~
+
+const glyph_t terminus16[] GLYPH_ATTR = {
+ chr_032,
+ chr_033,
+ chr_034,
+ chr_035,
+ chr_036,
+ chr_037,
+ chr_038,
+ chr_039,
+ chr_040,
+ chr_041,
+ chr_042,
+ chr_043,
+ chr_044,
+ chr_045,
+ chr_046,
+ chr_047,
+ chr_048,
+ chr_049,
+ chr_050,
+ chr_051,
+ chr_052,
+ chr_053,
+ chr_054,
+ chr_055,
+ chr_056,
+ chr_057,
+ chr_058,
+ chr_059,
+ chr_060,
+ chr_061,
+ chr_062,
+ chr_063,
+ chr_064,
+ chr_065,
+ chr_066,
+ chr_067,
+ chr_068,
+ chr_069,
+ chr_070,
+ chr_071,
+ chr_072,
+ chr_073,
+ chr_074,
+ chr_075,
+ chr_076,
+ chr_077,
+ chr_078,
+ chr_079,
+ chr_080,
+ chr_081,
+ chr_082,
+ chr_083,
+ chr_084,
+ chr_085,
+ chr_086,
+ chr_087,
+ chr_088,
+ chr_089,
+ chr_090,
+ chr_091,
+ chr_092,
+ chr_093,
+ chr_094,
+ chr_095,
+ chr_096,
+ chr_097,
+ chr_098,
+ chr_099,
+ chr_100,
+ chr_101,
+ chr_102,
+ chr_103,
+ chr_104,
+ chr_105,
+ chr_106,
+ chr_107,
+ chr_108,
+ chr_109,
+ chr_110,
+ chr_111,
+ chr_112,
+ chr_113,
+ chr_114,
+ chr_115,
+ chr_116,
+ chr_117,
+ chr_118,
+ chr_119,
+ chr_120,
+ chr_121,
+ chr_122,
+ chr_123,
+ chr_124,
+ chr_125,
+ chr_126
+};
diff --git a/include/lib/pixelfont/ttf-to-font.py b/include/lib/pixelfont/ttf-to-font.py
new file mode 100755
index 0000000..50297e5
--- /dev/null
+++ b/include/lib/pixelfont/ttf-to-font.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import PIL
+import PIL.ImageDraw
+import PIL.ImageFont
+
+if __name__ == "__main__":
+ font = PIL.ImageFont.truetype(
+ "/usr/share/fonts/truetype/terminus/TerminusTTF-4.46.0.ttf", size=14
+ )
+
+ for char in range(0x20, 0x7F):
+ fontimg = PIL.Image.new("1", (16, 16))
+ draw = PIL.ImageDraw.Draw(fontimg)
+ draw.text((0, 0), chr(char), font=font, fill=255)
+
+ bbox = fontimg.getbbox()
+
+ if bbox is None:
+ print(
+ "glyph_line_t GLYPH_ATTR chr_032[] = {0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; // <spac>"
+ )
+ continue
+
+ left, upper, right, lower = bbox
+ fontimg = fontimg.crop((left, 0, right, 15))
+
+ fontimg = fontimg.transpose(PIL.Image.ROTATE_270)
+ fontbytes = fontimg.tobytes()
+
+ glyph_len = len(fontbytes)
+ glyph_data = "{" + ",".join(map(lambda x: f"0x{x:02x}", fontbytes)) + "}"
+
+ print(
+ f"glyph_line_t GLYPH_ATTR chr_{char:03d}[] = {glyph_data}; // {chr(char)}"
+ )