diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-16 18:44:24 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-16 18:44:24 +0100 |
| commit | c074a085cca9d97d9b4eb18f21004fb41f7857f6 (patch) | |
| tree | ffb3a91c7efd8788f58b669991127e08b0e1c034 | |
| parent | 573ad65a8eee9173256c860f46204e584169c749 (diff) | |
| download | deck-it-c074a085cca9d97d9b4eb18f21004fb41f7857f6.tar.gz deck-it-c074a085cca9d97d9b4eb18f21004fb41f7857f6.zip | |
fix(ui): serve the Propo Nerd Font so icons centre
The plain Inconsolata Nerd Font gives each icon a 500 unit advance while
its ink is up to twice that wide, so every Nerd Font button sat right of
centre. The Propo variant's advance is the ink, so centring works for all
of them; the VM power button's padding workaround goes. The URL becomes
/fonts/nerd-propo.ttf because the font is cached for a day.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | AGENTS.md | 6 | ||||
| -rw-r--r-- | deckit/server.py | 8 | ||||
| -rw-r--r-- | static/deck.css | 7 | ||||
| -rw-r--r-- | tests/test_server.py | 4 |
4 files changed, 13 insertions, 12 deletions
@@ -118,8 +118,10 @@ Keep the server dependency-free apart from that one package. `qs -p <[assistant] shell> ipc call assistant catalog`. Files are picked on the PC with qarma, never named by the tablet. Voice is a WAV upload (`Module.uploads`, a raw body with its own size limit) written to the run - dir and asked with `audio`. The tab's icons are the Nerd Font the server - serves at `/fonts/nerd.ttf`; Markdown goes through `static/md.js` + dir and asked with `audio`. The tab's icons are the Nerd Font (Propo, so + a glyph's advance is its ink and centring works) the server serves at + `/fonts/nerd-propo.ttf`, cached a day: rename the URL when the font + changes; Markdown goes through `static/md.js` (vendored `marked`, HTML escaped, images never fetched). - The page holds a Screen Wake Lock while visible, so the tablet never sleeps over the dashboard. After `[tablet] dim_after` seconds untouched, `app.js` diff --git a/deckit/server.py b/deckit/server.py index bd46446..8f6a39f 100644 --- a/deckit/server.py +++ b/deckit/server.py @@ -131,9 +131,11 @@ _font = {} def nerd_font(): - """The Nerd Font the canvas draws its icons with, for the tablet.""" + """The Nerd Font the canvas draws its icons with, for the tablet. Propo: + each icon's advance is its ink, so a centred glyph is centred (the plain + variant's icons overflow their advance to the right).""" if "p" not in _font: - out = _run(["fc-match", "-f", "%{file}", "Inconsolata Nerd Font:style=Regular"]) + out = _run(["fc-match", "-f", "%{file}", "Inconsolata Nerd Font Propo:style=Regular"]) # fc-match falls back to any font; only a Nerd Font has the glyphs. found = "NerdFont" in out.replace(" ", "") and Path(out).is_file() if not found: @@ -217,7 +219,7 @@ class Handler(BaseHTTPRequestHandler): name = path[len("/icons/"):].removesuffix(".svg") icon = icon_path(name) return self._send(200, icon.read_bytes(), "image/svg+xml") if icon else self._send(404) - if path == "/fonts/nerd.ttf": + if path == "/fonts/nerd-propo.ttf": f = nerd_font() return self._send(200, f.read_bytes(), "font/ttf", cache=True) if f else self._send(404) if path.startswith("/fonts/") and path[len("/fonts/"):] in theme.CLOCK_FONTS: diff --git a/static/deck.css b/static/deck.css index 5ddf0f7..042e6e1 100644 --- a/static/deck.css +++ b/static/deck.css @@ -502,7 +502,7 @@ select { /* Assistant tab. Icons are the Nerd Font glyphs the canvas uses, served by deck-it from the PC; every control is at least 48px for a finger. */ -@font-face { font-family: "deckit-nerd"; src: url("/fonts/nerd.ttf") format("truetype"); font-display: block; } +@font-face { font-family: "deckit-nerd"; src: url("/fonts/nerd-propo.ttf") format("truetype"); font-display: block; } .nf { font-family: "deckit-nerd"; font-style: normal; } .assistant { display: flex; flex-direction: column; height: calc(100dvh - 120px); } @@ -853,10 +853,7 @@ select { .vm-bar { display: flex; align-items: center; gap: 12px; } .vm .ib, .vm-sheet .ib { min-width: 56px; min-height: 56px; font-size: 1.5rem; border-radius: 14px; padding: 0 12px; } .vm-more { margin-left: auto; } -/* The power glyph's ink is 865 units wide on a 500 advance (Nerd Font, not - Mono), so centring the advance leaves it 0.18em right; a right padding of - twice that centres the ink. */ -.vm-power { width: 72px; height: 72px; border-radius: 50%; font-size: 2rem; padding: 0 .36em 0 0; } +.vm-power { width: 72px; height: 72px; border-radius: 50%; font-size: 2rem; padding: 0; } .vm-power.go { background: color-mix(in srgb, var(--udt-green) 30%, transparent); border-color: var(--udt-green); } .vm-sshb.ready { border-color: var(--udt-accent); color: var(--udt-accent); } .vm .hold, .vm-sheet .hold { position: relative; overflow: hidden; isolation: isolate; touch-action: none; } diff --git a/tests/test_server.py b/tests/test_server.py index 4d734b4..beaeab4 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -131,10 +131,10 @@ class Server(unittest.TestCase): f.write_bytes(b"\x00\x01\x00\x00font") srv._font.clear() with mock.patch.object(srv, "_run", return_value=str(f)): - self.assertEqual(self.req("GET", "/fonts/nerd.ttf", HOST), (200, b"\x00\x01\x00\x00font")) + self.assertEqual(self.req("GET", "/fonts/nerd-propo.ttf", HOST), (200, b"\x00\x01\x00\x00font")) srv._font.clear() with mock.patch.object(srv, "_run", return_value="/usr/share/fonts/DejaVuSans.ttf"): - self.assertEqual(self.req("GET", "/fonts/nerd.ttf", HOST)[0], 404) + self.assertEqual(self.req("GET", "/fonts/nerd-propo.ttf", HOST)[0], 404) srv._font.clear() def test_clock_font(self): |
