feat(text-display): auto font mode via adaptive layout system (v1.1.1)#185
feat(text-display): auto font mode via adaptive layout system (v1.1.1)#185ChuckBuilds wants to merge 3 commits into
Conversation
Add font_mode config option: 'manual' (default, unchanged behavior) or 'auto', which picks the largest crisp font that fits the panel — static text is fitted to both dimensions (ellipsized only as a last resort), scrolling text is fitted to the panel height. Uses the new core adaptive-layout ladder API (TTF-only rungs: press_start 32/24/16/8, 5by7.regular@8, 4x6-font@6) since this plugin renders via PIL draw.text. Declares display.design_size 128x32 in the manifest. Requires a core with src/adaptive_layout.py for auto mode; falls back to manual on older cores. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…o (v1.1.1) measure_font_crispness (added to LEDMatrix core's adaptive_layout.py) found that two of the three AUTO_FONT_LADDER rungs were never actually crisp: - '5by7.regular' renders 36-79% antialiased at every size from 5px to 24px tested — it isn't a true pixel-grid font in PIL's TTF rasterizer and should never have been in a 'crisp' ladder. Dropped entirely. - '4x6-font' at 6px (the size used) is ~33% antialiased; 7px is its only genuinely crisp size (0% antialiased) despite reporting the same ink height via measure_ink. Corrected 6 -> 7. PressStart2P (LADDER_ARCADE's 32/24/16/8 rungs) was already correct — crisp only at exact multiples of its 8px design grid, confirmed by the same measurement. Added test_font_mode_auto.py asserting every ladder rung measures 0% antialiased, so a future ladder change can't silently regress this. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Text Display plugin adds ChangesText Display auto font sizing
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TextDisplayManager
participant AdaptiveLayout
participant FontManager
TextDisplayManager->>AdaptiveLayout: select largest fitting crisp font
AdaptiveLayout->>FontManager: load ladder font
FontManager-->>TextDisplayManager: fitted font and dimensions
TextDisplayManager->>TextDisplayManager: measure and render render_text
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 25 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
plugins/text-display/manager.py (1)
41-43: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer tuple unpacking over concatenation.
Ruff flags
LADDER_ARCADE + (FontStep(...))as RUF005. Unpacking avoids creating an intermediate tuple.♻️ Use unpacking instead of concatenation
- AUTO_FONT_LADDER = LADDER_ARCADE + ( - FontStep("4x6-font", 7), - ) + AUTO_FONT_LADDER = (*LADDER_ARCADE, FontStep("4x6-font", 7))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/text-display/manager.py` around lines 41 - 43, Update the AUTO_FONT_LADDER definition to use tuple unpacking for LADDER_ARCADE and the appended FontStep instead of tuple concatenation, resolving Ruff RUF005 while preserving the existing ladder order and values.Source: Linters/SAST tools
plugins/text-display/README.md (1)
60-62: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding
font_modeto the example configuration.The example JSON block (lines 32-48) doesn't include the new
font_modekey. Adding it would improve discoverability of the auto mode feature for users who copy the example as a starting point.📝 Add font_mode to example config
"enabled": true, "text": "Subscribe to ChuckBuilds!", + "font_mode": "manual", "font_path": "assets/fonts/PressStart2P-Regular.ttf", "font_size": 8,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@plugins/text-display/README.md` around lines 60 - 62, Add the new font_mode configuration key to the example JSON block in README.md, using the documented default or an appropriate example value so users can discover and enable auto sizing. Keep the existing font_path and font_size example entries unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@plugins/text-display/manager.py`:
- Around line 41-43: Update the AUTO_FONT_LADDER definition to use tuple
unpacking for LADDER_ARCADE and the appended FontStep instead of tuple
concatenation, resolving Ruff RUF005 while preserving the existing ladder order
and values.
In `@plugins/text-display/README.md`:
- Around line 60-62: Add the new font_mode configuration key to the example JSON
block in README.md, using the documented default or an appropriate example value
so users can discover and enable auto sizing. Keep the existing font_path and
font_size example entries unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 49491168-29a1-47f1-874b-f239684a0c5e
📒 Files selected for processing (6)
plugins.jsonplugins/text-display/README.mdplugins/text-display/config_schema.jsonplugins/text-display/manager.pyplugins/text-display/manifest.jsonplugins/text-display/test_font_mode_auto.py
Addresses CodeRabbit review on #185 — the example is what users copy, so the new key should be visible there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FqzC1nzTWL4kaqgMaQZFam
|
Addressed the review nitpicks:
|
Summary
Opt-in `font_mode: "auto"` — picks the largest verified-crisp font for the panel via the core adaptive layout system (ChuckBuilds/LEDMatrix#393). Default stays `manual`, rendering byte-identical to v1.0.x. v1.1.1 drops antialiased ladder rungs (5by7.regular is never crisp; 4x6 is crisp at 7px, not 6) after measuring every rung with the core's `measure_font_crispness`.
Falls back silently to manual mode on cores without the adaptive system.
Verification
Auto-picked press_start@32 on a real 192x48 panel; goldens + crispness regression test included.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FqzC1nzTWL4kaqgMaQZFam
Summary by CodeRabbit
New Features
font_modesetting with manual and automatic options.Documentation
Release Updates