Skip to content

feat(text-display): auto font mode via adaptive layout system (v1.1.1)#185

Open
ChuckBuilds wants to merge 3 commits into
mainfrom
feat/text-display-auto-font
Open

feat(text-display): auto font mode via adaptive layout system (v1.1.1)#185
ChuckBuilds wants to merge 3 commits into
mainfrom
feat/text-display-auto-font

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Jul 11, 2026

Copy link
Copy Markdown
Owner

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

    • Added automatic font sizing for Text Display content, selecting the largest crisp font that fits.
    • Added a font_mode setting with manual and automatic options.
    • Improved handling of text fitting, scrolling, alignment, and display-size changes in automatic mode.
    • Added the selected font mode to web interface information.
  • Documentation

    • Updated configuration guidance for automatic and manual font sizing.
  • Release Updates

    • Released Text Display version 1.1.1 with updated plugin metadata and changelog.

Chuck and others added 2 commits July 11, 2026 10:21
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>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ChuckBuilds, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5796f8b-b424-4f7a-bfa3-583ea813d34a

📥 Commits

Reviewing files that changed from the base of the PR and between de20b98 and 9fb1f0a.

📒 Files selected for processing (1)
  • plugins/text-display/README.md
📝 Walkthrough

Walkthrough

The Text Display plugin adds manual and auto font modes, integrates adaptive font fitting, updates rendering and configuration handling, documents the new options, bumps release metadata, and adds crispness tests.

Changes

Text Display auto font sizing

Layer / File(s) Summary
Configuration and release metadata
plugins/text-display/config_schema.json, plugins/text-display/README.md, plugins/text-display/manifest.json, plugins.json
Adds the font_mode configuration, documents manual and automatic sizing, records a 1.1.1 release, and updates catalog dates.
Adaptive font resolution and rendering
plugins/text-display/manager.py
Integrates the adaptive font ladder, resolves fitting fonts, tracks rendered text and fit dimensions, updates rendering and runtime configuration paths, and exposes font_mode metadata.
Auto font crispness validation
plugins/text-display/test_font_mode_auto.py
Adds tests for a non-empty font ladder and crispness within the configured tolerance, with skips when adaptive layout support is unavailable.

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately highlights the main change: adding auto font mode for text display using the adaptive layout system.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/text-display-auto-font

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 25 complexity

Metric Results
Complexity 25

View in Codacy

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.

@ChuckBuilds

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
plugins/text-display/manager.py (1)

41-43: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer 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 value

Consider adding font_mode to the example configuration.

The example JSON block (lines 32-48) doesn't include the new font_mode key. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5c84118 and de20b98.

📒 Files selected for processing (6)
  • plugins.json
  • plugins/text-display/README.md
  • plugins/text-display/config_schema.json
  • plugins/text-display/manager.py
  • plugins/text-display/manifest.json
  • plugins/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
@ChuckBuilds

Copy link
Copy Markdown
Owner Author

Addressed the review nitpicks:

  • font_mode added to the README example config.
  • Skipping the RUF005 tuple-unpacking suggestion: the LADDER + (FontStep(...),) concatenation pattern is used identically in football-scoreboard and ledmatrix-music's adaptive ladders — keeping the three consistent beats a one-off style change; happy to convert all three in a follow-up if preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant