Journey: real train/bus pictograms instead of letter badges

Vendor Font Awesome Free Solid (fonts/fa-solid-900.ttf, SIL OFL
licensed -- see fonts/FONT-AWESOME-LICENSE.txt) for its actual
train/bus glyphs. Confirmed live these stay sharp and recognizable
even at the tiny size the detail line renders at (~20px), unlike a
hand-drawn shape would be, and unlike emoji (not in DejaVu Sans,
would've rendered as tofu).

render_utils.py gets a load_icon_font() alongside the existing
load_font(), plus named ICON_BUS/ICON_TRAIN codepoint constants so
screens don't need to embed raw Private-Use-Area unicode literals.
This commit is contained in:
Honey committed 2026-07-23 10:13:59 +02:00
1 parent 7354517b22
commit 4380a62524
4 files changed
+197 -15

No files matched your search

+16
View File
@@ -23,6 +23,22 @@ def load_font(size: int, bold: bool = False) -> ImageFont.FreeTypeFont:
return _font_cache[key]
# Font Awesome Free (Solid), vendored for real pictogram icons (train, bus,
# etc.) where a hand-drawn shape or a plain letter would be less clear at a
# glance than the real thing. SIL OFL licensed -- see fonts/FONT-AWESOME-LICENSE.txt.
def load_icon_font(size: int) -> ImageFont.FreeTypeFont:
key = ("fa-solid", size)
if key not in _font_cache:
_font_cache[key] = ImageFont.truetype(str(FONTS_DIR / "fa-solid-900.ttf"), size)
return _font_cache[key]
# Font Awesome Free Solid codepoints used by screens -- named here so callers
# don't need to embed raw Private-Use-Area unicode literals.
ICON_BUS = ""
ICON_TRAIN = ""
def text_width(draw, text: str, font: ImageFont.FreeTypeFont) -> int:
left, _, right, _ = draw.textbbox((0, 0), text, font=font)
return right - left