From 863f7453f9e136cadc93db9f3f0b8f257f798ce8 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 13 Nov 2026 14:06:41 +0100 Subject: feat(tablet): a font of the PC's for the dim cover's clock [tablet] clock_font names a font family installed on the PC; the server finds its file with fc-match and serves it at /fonts/clock, and the cover's clock uses it, the date too while clock_font_date is on (default). fc-match falls back to any font, so the route answers only when the returned family is the one named; otherwise the page font stays. The font file never enters the repo, so a personal-use font can be used on one's own tablet without redistributing it. Co-Authored-By: Claude Opus 5.5 --- tests/test_server.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/test_server.py b/tests/test_server.py index 522b781..8f82e9f 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -137,6 +137,21 @@ class Server(unittest.TestCase): self.assertEqual(self.req("GET", "/fonts/nerd.ttf", HOST)[0], 404) srv._font.clear() + def test_clock_font(self): + from unittest import mock + import tempfile + from pathlib import Path + f = Path(tempfile.mkdtemp()) / "Graffiti.ttf" + f.write_bytes(b"\x00\x01\x00\x00clock") + with mock.patch.dict(srv.CFG, {"tablet": {"clock_font": "a Graffiti"}}): + with mock.patch.object(srv, "_run", return_value=f"a Graffiti\n{f}"): + self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0:2], (200, b"\x00\x01\x00\x00clock")) + # fc-match's fallback for a font that is not installed + with mock.patch.object(srv, "_run", return_value="DejaVu Sans\n/usr/share/fonts/DejaVuSans.ttf"): + self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0], 404) + with mock.patch.dict(srv.CFG, {"tablet": {}}): + self.assertEqual(self.req("GET", "/fonts/clock", HOST)[0], 404) + def test_assets_and_api(self): self.assertEqual(self.req("GET", "/", HOST)[0], 200) self.assertEqual(self.req("GET", "/theme.css", HOST)[0], 200) -- cgit v1.2.3