From 93d10f74fb6802297b3c379aeb8a53341aca5533 Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Thu, 11 Jun 2020 20:36:47 +0100 Subject: [PATCH] fonts: Add sans28 (numerals only) --- wasp/boards/pinetime/manifest.py | 1 + wasp/fonts/__init__.py | 1 + wasp/fonts/sans28.py | 107 +++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 wasp/fonts/sans28.py diff --git a/wasp/boards/pinetime/manifest.py b/wasp/boards/pinetime/manifest.py index 61cc24a..073e1a0 100644 --- a/wasp/boards/pinetime/manifest.py +++ b/wasp/boards/pinetime/manifest.py @@ -24,6 +24,7 @@ freeze('../..', 'fonts/__init__.py', 'fonts/clock.py', 'fonts/sans24.py', + 'fonts/sans28.py', 'fonts/sans36.py', 'icons.py', 'shell.py', diff --git a/wasp/fonts/__init__.py b/wasp/fonts/__init__.py index 917fb00..a65ada3 100644 --- a/wasp/fonts/__init__.py +++ b/wasp/fonts/__init__.py @@ -2,6 +2,7 @@ # Copyright (C) 2020 Daniel Thompson import fonts.sans24 as sans24 +import fonts.sans28 as sans28 import fonts.sans36 as sans36 def height(font): diff --git a/wasp/fonts/sans28.py b/wasp/fonts/sans28.py new file mode 100644 index 0000000..9a123f3 --- /dev/null +++ b/wasp/fonts/sans28.py @@ -0,0 +1,107 @@ +# Code generated by font_to_py.py. +# Font: DejaVuSans.ttf +# Cmd: ./tools/micropython-font-to-py/font_to_py.py /usr/share/fonts/dejavu/DejaVuSans.ttf --xmap 28 -e 58 -s 48 -l 58 wasp/fonts/sans28.py +version = '0.33' + +def height(): + return 27 + +def baseline(): + return 27 + +def max_width(): + return 24 + +def hmap(): + return True + +def reverse(): + return False + +def monospaced(): + return False + +def min_ch(): + return 48 + +def max_ch(): + return 58 + +_font =\ +b'\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\ +b'\x00\x00\x0f\x00\x0f\x00\x0f\x00\x0f\x00\x0f\x00\x00\x00\x00\x00'\ +b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00'\ +b'\x0f\x00\x0f\x00\x0f\x00\x0f\x00\x18\x00\x00\xfe\x00\x03\xff\x80'\ +b'\x07\xff\xc0\x0f\x83\xe0\x0f\x01\xe0\x1e\x00\xf0\x1e\x00\xf0\x1e'\ +b'\x00\xf0\x3c\x00\x78\x3c\x00\x78\x3c\x00\x78\x3c\x00\x78\x3c\x00'\ +b'\x78\x3c\x00\x78\x3c\x00\x78\x3c\x00\x78\x3c\x00\x78\x3c\x00\x78'\ +b'\x3c\x00\x78\x1e\x00\xf0\x1e\x00\xf0\x1e\x00\xf0\x0f\x01\xe0\x0f'\ +b'\x83\xe0\x07\xff\xc0\x03\xff\x80\x00\xfe\x00\x18\x00\x00\xfe\x00'\ +b'\x07\xfe\x00\x07\xfe\x00\x07\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00'\ +b'\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e'\ +b'\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00'\ +b'\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00\x1e\x00\x00'\ +b'\x1e\x00\x00\x1e\x00\x07\xff\xf8\x07\xff\xf8\x07\xff\xf8\x18\x00'\ +b'\x01\xfc\x00\x0f\xff\x80\x1f\xff\xc0\x1f\x07\xe0\x18\x01\xe0\x10'\ +b'\x01\xf0\x00\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00\x01'\ +b'\xf0\x00\x01\xe0\x00\x03\xe0\x00\x07\xc0\x00\x0f\x80\x00\x1f\x00'\ +b'\x00\x3e\x00\x00\x7e\x00\x00\xfc\x00\x01\xf8\x00\x03\xf0\x00\x07'\ +b'\xe0\x00\x0f\xc0\x00\x1f\x80\x00\x1f\xff\xf0\x1f\xff\xf0\x1f\xff'\ +b'\xf0\x18\x00\x03\xfe\x00\x0f\xff\x80\x0f\xff\xc0\x0c\x03\xe0\x00'\ +b'\x01\xf0\x00\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00\x01'\ +b'\xe0\x00\x03\xc0\x00\xff\x80\x00\xfe\x00\x00\xff\xc0\x00\x03\xe0'\ +b'\x00\x00\xf0\x00\x00\xf8\x00\x00\x78\x00\x00\x78\x00\x00\x78\x00'\ +b'\x00\x78\x00\x00\xf8\x00\x01\xf0\x18\x03\xf0\x1f\xff\xe0\x1f\xff'\ +b'\x80\x07\xfe\x00\x18\x00\x00\x07\xc0\x00\x0f\xc0\x00\x0f\xc0\x00'\ +b'\x1f\xc0\x00\x3b\xc0\x00\x3b\xc0\x00\x73\xc0\x00\xf3\xc0\x00\xe3'\ +b'\xc0\x01\xc3\xc0\x03\xc3\xc0\x03\x83\xc0\x07\x03\xc0\x07\x03\xc0'\ +b'\x0e\x03\xc0\x1e\x03\xc0\x1c\x03\xc0\x38\x03\xc0\x3f\xff\xfc\x3f'\ +b'\xff\xfc\x3f\xff\xfc\x00\x03\xc0\x00\x03\xc0\x00\x03\xc0\x00\x03'\ +b'\xc0\x00\x03\xc0\x00\x03\xc0\x18\x00\x0f\xff\xc0\x0f\xff\xc0\x0f'\ +b'\xff\xc0\x0f\x00\x00\x0f\x00\x00\x0f\x00\x00\x0f\x00\x00\x0f\x00'\ +b'\x00\x0f\x00\x00\x0f\xfc\x00\x0f\xff\x00\x0f\xff\xc0\x0c\x0f\xc0'\ +b'\x00\x03\xe0\x00\x01\xe0\x00\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00'\ +b'\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00\x01\xe0\x00\x03\xe0\x18\x07'\ +b'\xc0\x1f\xff\xc0\x1f\xff\x00\x07\xfc\x00\x18\x00\x00\x3f\x80\x00'\ +b'\xff\xe0\x03\xff\xe0\x07\xe0\x60\x0f\x80\x00\x0f\x00\x00\x1f\x00'\ +b'\x00\x1e\x00\x00\x1e\x00\x00\x3c\x00\x00\x3c\x7f\x00\x3c\xff\xc0'\ +b'\x3d\xff\xe0\x3f\x83\xf0\x3e\x00\xf0\x3e\x00\xf8\x3c\x00\x78\x3c'\ +b'\x00\x78\x3c\x00\x78\x1c\x00\x78\x1c\x00\x78\x1e\x00\xf8\x0e\x00'\ +b'\xf0\x0f\x83\xf0\x07\xff\xe0\x03\xff\x80\x00\xfe\x00\x18\x00\x1f'\ +b'\xff\xf0\x1f\xff\xf0\x1f\xff\xf0\x00\x01\xe0\x00\x01\xe0\x00\x03'\ +b'\xe0\x00\x03\xc0\x00\x03\xc0\x00\x07\xc0\x00\x07\x80\x00\x07\x80'\ +b'\x00\x0f\x80\x00\x0f\x00\x00\x0f\x00\x00\x1f\x00\x00\x1e\x00\x00'\ +b'\x1e\x00\x00\x3e\x00\x00\x3c\x00\x00\x3c\x00\x00\x78\x00\x00\x78'\ +b'\x00\x00\x78\x00\x00\xf0\x00\x00\xf0\x00\x00\xf0\x00\x01\xe0\x00'\ +b'\x18\x00\x00\xfe\x00\x03\xff\x80\x0f\xff\xe0\x0f\x83\xe0\x1f\x01'\ +b'\xf0\x1e\x00\xf0\x1e\x00\xf0\x1e\x00\xf0\x1e\x00\xf0\x0f\x01\xe0'\ +b'\x07\x83\xc0\x03\xff\x80\x00\xfe\x00\x07\xff\xc0\x0f\x83\xe0\x1e'\ +b'\x00\xf0\x3e\x00\xf0\x3c\x00\x78\x3c\x00\x78\x3c\x00\x78\x3c\x00'\ +b'\x78\x3e\x00\xf8\x1e\x00\xf0\x1f\x83\xf0\x0f\xff\xe0\x07\xff\xc0'\ +b'\x00\xfe\x00\x18\x00\x00\xfe\x00\x03\xff\x00\x0f\xff\xc0\x1f\x83'\ +b'\xe0\x1e\x00\xe0\x3e\x00\xf0\x3c\x00\x70\x3c\x00\x70\x3c\x00\x78'\ +b'\x3c\x00\x78\x3c\x00\x78\x3e\x00\xf8\x1e\x00\xf8\x1f\x83\xf8\x0f'\ +b'\xff\x78\x07\xfe\x78\x01\xfc\x78\x00\x00\xf8\x00\x00\xf0\x00\x00'\ +b'\xf0\x00\x01\xf0\x00\x01\xe0\x00\x03\xe0\x0c\x0f\xc0\x0f\xff\x80'\ +b'\x0f\xfe\x00\x03\xf8\x00\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00'\ +b'\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x0f\x00\x0f\x00\x0f\x00'\ +b'\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'\ +b'\x00\x00\x00\x00\x0f\x00\x0f\x00\x0f\x00\x0f\x00\x0f\x00' + +_index =\ +b'\x00\x00\x38\x00\x8b\x00\xde\x00\x31\x01\x84\x01\xd7\x01\x2a\x02'\ +b'\x7d\x02\xd0\x02\x23\x03\x76\x03\xae\x03' + +_mvfont = memoryview(_font) +_mvi = memoryview(_index) +ifb = lambda l : l[0] | (l[1] << 8) + +def get_ch(ch): + oc = ord(ch) + ioff = 2 * (oc - 48 + 1) if oc >= 48 and oc <= 58 else 0 + doff = ifb(_mvi[ioff : ]) + width = ifb(_mvfont[doff : ]) + + next_offs = doff + 2 + ((width - 1)//8 + 1) * 27 + return _mvfont[doff + 2:next_offs], 27, width +