From 04aaf39ae2a9077745d636379dadc781b16ea596 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Thu, 17 Sep 2026 08:52:58 -0400 Subject: [PATCH] docs(fonts): point plugins at plugin_manager.font_manager; drop removed overrides UI FONT_MANAGER.md told plugins to read display_manager.font_manager, which does not exist, so a plugin following it failed to load with AttributeError. The shared FontManager lives on the PluginManager and BasePlugin._get_font_manager() returns it (with a fallback for harnesses). Also removes the Fonts-tab override workflow and element-override panels that #566 deleted, from FONT_MANAGER.md and WEB_INTERFACE_GUIDE.md. Co-Authored-By: Claude Opus 5 --- docs/FONT_MANAGER.md | 71 ++++++++++++++++++++----------------- docs/WEB_INTERFACE_GUIDE.md | 15 ++++---- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/docs/FONT_MANAGER.md b/docs/FONT_MANAGER.md index e6691dd7..3678e955 100644 --- a/docs/FONT_MANAGER.md +++ b/docs/FONT_MANAGER.md @@ -12,10 +12,28 @@ The enhanced FontManager provides comprehensive font management for the LEDMatrix application with support for: - Manager font registration and detection - Plugin font management -- Manual font overrides via web interface +- Programmatic per-element font overrides - Performance monitoring and caching - Dynamic font discovery +## Getting the FontManager + +There is one shared FontManager per display process. The display controller +creates it and hands it to the `PluginManager`, so a plugin reaches it +through its `plugin_manager`: + +```python +class MyPlugin(BasePlugin): + def __init__(self, plugin_id, config, display_manager, cache_manager, plugin_manager): + super().__init__(plugin_id, config, display_manager, cache_manager, plugin_manager) + self.font_manager = self._get_font_manager() +``` + +`BasePlugin._get_font_manager()` returns `plugin_manager.font_manager`, or a +standalone FontManager when none is available (test harnesses, mocks). +`DisplayManager` has **no** `font_manager` attribute — +`display_manager.font_manager` raises `AttributeError`. + ## Architecture ### Manager-Centric Design @@ -40,8 +58,9 @@ Manager requests font → Check manual overrides → Apply manager choice → Ca from src.font_manager import FontManager class MyManager: - def __init__(self, config, display_manager, cache_manager): - self.font_manager = display_manager.font_manager # Access shared FontManager + def __init__(self, config, display_manager, cache_manager, plugin_manager): + self.display_manager = display_manager + self.font_manager = plugin_manager.font_manager # Shared FontManager self.manager_id = "my_manager" def display(self): @@ -80,8 +99,9 @@ class MyManager: ```python class AdvancedManager: - def __init__(self, config, display_manager, cache_manager): - self.font_manager = display_manager.font_manager + def __init__(self, config, display_manager, cache_manager, plugin_manager): + self.display_manager = display_manager + self.font_manager = plugin_manager.font_manager self.manager_id = "advanced_manager" # Define your font specifications @@ -152,19 +172,13 @@ font = self.font_manager.resolve_font( > URIs documented below are resolved relative to the plugin's > install directory. > -> The **Fonts** tab in the web UI that lists detected -> manager-registered fonts is still a **placeholder -> implementation** — fonts that managers register through -> `register_manager_font()` do not yet appear there. The -> programmatic per-element override workflow described in -> [Manual Font Overrides](#manual-font-overrides) below -> (`set_override()` / `remove_override()` / the -> `config/font_overrides.json` store) **does** work today and is -> the supported way to override a font for an element until the -> Fonts tab is wired up. If you can't wait and need a workaround -> right now, you can also just load the font directly with PIL -> (or `freetype-py` for BDF) inside your plugin's `manager.py` -> and skip the override system entirely. +> The web UI's **Fonts** tab lists, uploads, previews and deletes the +> font files in `assets/fonts/`. It does not show fonts registered +> through `register_manager_font()` and has no override editor (the +> override panels and `/api/v3/fonts/overrides` endpoints were removed). +> The programmatic override workflow in +> [Manual Font Overrides](#manual-font-overrides) below still works. +> Let users pick fonts through your plugin's own config schema. ### Plugin Font Registration @@ -200,10 +214,10 @@ In your plugin's `manifest.json`: ### Using Plugin Fonts ```python -class PluginManager: - def __init__(self, config, display_manager, cache_manager, plugin_id): - self.font_manager = display_manager.font_manager - self.plugin_id = plugin_id +class MyPlugin(BasePlugin): + def __init__(self, plugin_id, config, display_manager, cache_manager, plugin_manager): + super().__init__(plugin_id, config, display_manager, cache_manager, plugin_manager) + self.font_manager = self._get_font_manager() def display(self): # Use plugin font (automatically namespaced) @@ -219,17 +233,8 @@ class PluginManager: ## Manual Font Overrides -Users can override any font through the web interface: - -1. Navigate to **Fonts** tab -2. View **Detected Manager Fonts** to see what's currently in use -3. In **Element Overrides** section: - - Select the element (e.g., "nfl.live.score") - - Choose a different font family - - Choose a different size - - Click **Add Override** - -Overrides are stored in `config/font_overrides.json` and persist across restarts. +Overrides are set in code (there is no web UI or REST endpoint for them). +They are stored in `config/font_overrides.json` and persist across restarts. ### Programmatic Overrides diff --git a/docs/WEB_INTERFACE_GUIDE.md b/docs/WEB_INTERFACE_GUIDE.md index 10ef082b..64b51ba3 100644 --- a/docs/WEB_INTERFACE_GUIDE.md +++ b/docs/WEB_INTERFACE_GUIDE.md @@ -206,11 +206,11 @@ Manage fonts for your display: - See font previews - Check font sizes and styles -**Font Overrides:** -- Overrides are set per display *element* (e.g. a specific score or - clock text element), not per plugin -- Override default font choices for individual elements -- Preview font changes +**Font Preview:** +- Render sample text in any TTF/OTF font at a chosen size + +Fonts used by a plugin are chosen in that plugin's own settings tab; the +Fonts tab has no per-element override editor. **Delete Fonts:** - Remove unused fonts @@ -327,9 +327,8 @@ The web interface is built on a REST API that you can access programmatically: http://your-pi-ip:5000/api/v3 ``` -The API blueprint mounts at `/api/v3` (see -`web_interface/app.py:199`). All endpoints below are relative to that -base. +The API blueprint (`web_interface/blueprints/api_v3/`) is registered at +`/api/v3` in `web_interface/app.py`. **Common Endpoints:** - `GET /api/v3/config/main` — Get main configuration