mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-13 10:36:35 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
+38
-33
@@ -12,10 +12,28 @@
|
|||||||
The enhanced FontManager provides comprehensive font management for the LEDMatrix application with support for:
|
The enhanced FontManager provides comprehensive font management for the LEDMatrix application with support for:
|
||||||
- Manager font registration and detection
|
- Manager font registration and detection
|
||||||
- Plugin font management
|
- Plugin font management
|
||||||
- Manual font overrides via web interface
|
- Programmatic per-element font overrides
|
||||||
- Performance monitoring and caching
|
- Performance monitoring and caching
|
||||||
- Dynamic font discovery
|
- 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
|
## Architecture
|
||||||
|
|
||||||
### Manager-Centric Design
|
### Manager-Centric Design
|
||||||
@@ -40,8 +58,9 @@ Manager requests font → Check manual overrides → Apply manager choice → Ca
|
|||||||
from src.font_manager import FontManager
|
from src.font_manager import FontManager
|
||||||
|
|
||||||
class MyManager:
|
class MyManager:
|
||||||
def __init__(self, config, display_manager, cache_manager):
|
def __init__(self, config, display_manager, cache_manager, plugin_manager):
|
||||||
self.font_manager = display_manager.font_manager # Access shared FontManager
|
self.display_manager = display_manager
|
||||||
|
self.font_manager = plugin_manager.font_manager # Shared FontManager
|
||||||
self.manager_id = "my_manager"
|
self.manager_id = "my_manager"
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
@@ -80,8 +99,9 @@ class MyManager:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
class AdvancedManager:
|
class AdvancedManager:
|
||||||
def __init__(self, config, display_manager, cache_manager):
|
def __init__(self, config, display_manager, cache_manager, plugin_manager):
|
||||||
self.font_manager = display_manager.font_manager
|
self.display_manager = display_manager
|
||||||
|
self.font_manager = plugin_manager.font_manager
|
||||||
self.manager_id = "advanced_manager"
|
self.manager_id = "advanced_manager"
|
||||||
|
|
||||||
# Define your font specifications
|
# Define your font specifications
|
||||||
@@ -152,19 +172,13 @@ font = self.font_manager.resolve_font(
|
|||||||
> URIs documented below are resolved relative to the plugin's
|
> URIs documented below are resolved relative to the plugin's
|
||||||
> install directory.
|
> install directory.
|
||||||
>
|
>
|
||||||
> The **Fonts** tab in the web UI that lists detected
|
> The web UI's **Fonts** tab lists, uploads, previews and deletes the
|
||||||
> manager-registered fonts is still a **placeholder
|
> font files in `assets/fonts/`. It does not show fonts registered
|
||||||
> implementation** — fonts that managers register through
|
> through `register_manager_font()` and has no override editor (the
|
||||||
> `register_manager_font()` do not yet appear there. The
|
> override panels and `/api/v3/fonts/overrides` endpoints were removed).
|
||||||
> programmatic per-element override workflow described in
|
> The programmatic override workflow in
|
||||||
> [Manual Font Overrides](#manual-font-overrides) below
|
> [Manual Font Overrides](#manual-font-overrides) below still works.
|
||||||
> (`set_override()` / `remove_override()` / the
|
> Let users pick fonts through your plugin's own config schema.
|
||||||
> `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.
|
|
||||||
|
|
||||||
### Plugin Font Registration
|
### Plugin Font Registration
|
||||||
|
|
||||||
@@ -200,10 +214,10 @@ In your plugin's `manifest.json`:
|
|||||||
### Using Plugin Fonts
|
### Using Plugin Fonts
|
||||||
|
|
||||||
```python
|
```python
|
||||||
class PluginManager:
|
class MyPlugin(BasePlugin):
|
||||||
def __init__(self, config, display_manager, cache_manager, plugin_id):
|
def __init__(self, plugin_id, config, display_manager, cache_manager, plugin_manager):
|
||||||
self.font_manager = display_manager.font_manager
|
super().__init__(plugin_id, config, display_manager, cache_manager, plugin_manager)
|
||||||
self.plugin_id = plugin_id
|
self.font_manager = self._get_font_manager()
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
# Use plugin font (automatically namespaced)
|
# Use plugin font (automatically namespaced)
|
||||||
@@ -219,17 +233,8 @@ class PluginManager:
|
|||||||
|
|
||||||
## Manual Font Overrides
|
## Manual Font Overrides
|
||||||
|
|
||||||
Users can override any font through the web interface:
|
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.
|
||||||
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.
|
|
||||||
|
|
||||||
### Programmatic Overrides
|
### Programmatic Overrides
|
||||||
|
|
||||||
|
|||||||
@@ -206,11 +206,11 @@ Manage fonts for your display:
|
|||||||
- See font previews
|
- See font previews
|
||||||
- Check font sizes and styles
|
- Check font sizes and styles
|
||||||
|
|
||||||
**Font Overrides:**
|
**Font Preview:**
|
||||||
- Overrides are set per display *element* (e.g. a specific score or
|
- Render sample text in any TTF/OTF font at a chosen size
|
||||||
clock text element), not per plugin
|
|
||||||
- Override default font choices for individual elements
|
Fonts used by a plugin are chosen in that plugin's own settings tab; the
|
||||||
- Preview font changes
|
Fonts tab has no per-element override editor.
|
||||||
|
|
||||||
**Delete Fonts:**
|
**Delete Fonts:**
|
||||||
- Remove unused 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
|
http://your-pi-ip:5000/api/v3
|
||||||
```
|
```
|
||||||
|
|
||||||
The API blueprint mounts at `/api/v3` (see
|
The API blueprint (`web_interface/blueprints/api_v3/`) is registered at
|
||||||
`web_interface/app.py:199`). All endpoints below are relative to that
|
`/api/v3` in `web_interface/app.py`.
|
||||||
base.
|
|
||||||
|
|
||||||
**Common Endpoints:**
|
**Common Endpoints:**
|
||||||
- `GET /api/v3/config/main` — Get main configuration
|
- `GET /api/v3/config/main` — Get main configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user