diff options
Diffstat (limited to 'deckit/server.py')
| -rw-r--r-- | deckit/server.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/deckit/server.py b/deckit/server.py index 2ced8dd..bd46446 100644 --- a/deckit/server.py +++ b/deckit/server.py @@ -142,10 +142,11 @@ def nerd_font(): return _font["p"] -def clock_font(): - """[tablet] clock_font's file, for the dim cover's clock; None when unset - or not installed (fc-match falls back to any font, so the family must match).""" - family = CFG.get("tablet", {}).get("clock_font", "") +def clock_font(key): + """The file of a clock font keystone's fonts.json names (theme.CLOCK_FONTS); + None when unset or not installed (fc-match falls back to any font, so the + family must match).""" + family = theme.families().get(key, "") if not family: return None out = _run(["fc-match", "-f", "%{family}\n%{file}", family]) @@ -219,8 +220,8 @@ class Handler(BaseHTTPRequestHandler): if path == "/fonts/nerd.ttf": f = nerd_font() return self._send(200, f.read_bytes(), "font/ttf", cache=True) if f else self._send(404) - if path == "/fonts/clock": - f = clock_font() + if path.startswith("/fonts/") and path[len("/fonts/"):] in theme.CLOCK_FONTS: + f = clock_font(path[len("/fonts/"):]) return self._send(200, f.read_bytes(), mimetypes.guess_type(f)[0] or "font/ttf") if f else self._send(404) if path.startswith("/api/"): if not self._authed(): |
