fix(display): draw text 1-bit, so glyphs stay crisp on the LED grid - #521
fix(display): draw text 1-bit, so glyphs stay crisp on the LED grid#521ChuckBuilds wants to merge 1 commit into
Conversation
An LED panel has no partial brightness. PIL defaults ImageDraw's fontmode to "L", which anti-aliases TrueType glyphs into a grey fringe the panel can only round off -- a 4px glyph arrives smeared into 3px. DisplayManager creates its shared `draw` in six places and set fontmode at none of them, while _load_fonts loads extra_small_font as 4x6-font.ttf at size 6. Measured at draw time, that face at that size puts 74% of its lit pixels at partial coverage. Every plugin drawing small text through the shared draw inherited the blur; geochron was the case that surfaced it. The harness's VisualDisplayManager had the same gap, which mattered more than it looks: goldens were recording anti-aliased text that production would not produce, so the harness could not have caught this. Fixing only production left geochron still blurry under the harness -- that is how the second site was found. Both are set to "1" so the harness renders what the panel renders. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014RRtqXDCnvnY6EQwhT5CV9
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
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.
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change sets Changes1-bit text rendering alignment
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to Text rendering now uses 1-bit glyphs in production and visual test canvases, eliminating partial-brightness text on LED panels while keeping visual test rendering aligned. The change is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
@coderabbitai review |
|
The bug
An LED panel has no partial brightness. PIL defaults
ImageDraw'sfontmodeto"L", which anti-aliases TrueType glyphs into a grey fringe the panel can only round off — a 4px glyph arrives smeared into 3px.DisplayManagercreates its shareddrawin six places and setfontmodeat none of them, while_load_fontsloadsextra_small_fontas 4x6-font.ttf at size 6. Measured at draw time, that face at that size puts 74% of its lit pixels at partial coverage. Every plugin that draws small text through the shareddrawinherited the blur.The harness had the same gap, and that mattered more
src/plugin_system/testing/visual_display_manager.pycreates its owndrawin five places, also at the default. So the harness was recording anti-aliased goldens that production would never produce — it structurally could not have caught this.That is not a theoretical point. After the production fix,
geochronwas still rendering anti-aliased under the harness; tracing the draw object's creation stack led tovisual_display_manager.py:72. Fixing only production would have left the harness disagreeing with the panel.Both are now
"1", so the harness renders what the panel renders.Verification
A probe hooked
ImageDraw.textand recorded, for every real draw, thefontmodein effect, the font and size, the call site, and theDraw()object's creation site.Companion plugin-side PR: ChuckBuilds/ledmatrix-plugins#417.
🤖 Generated with Claude Code
https://claude.ai/code/session_014RRtqXDCnvnY6EQwhT5CV9
Summary by CodeRabbit