Skip to content

fix(fonts): load bitmap faces at their own size in the last two plugins - #374

Open
ChuckBuilds wants to merge 1 commit into
mainfrom
fix/bitmap-fonts-sweep
Open

fix(fonts): load bitmap faces at their own size in the last two plugins#374
ChuckBuilds wants to merge 1 commit into
mainfrom
fix/bitmap-fonts-sweep

Conversation

@ChuckBuilds

Copy link
Copy Markdown
Owner

Completes the bitmap-font sweep you asked about. mqtt-notifications and youtube-stats were the last two carrying this loader.

The bug, once more

A .bdf exists at exactly one pixel size and FreeType rejects any other with invalid pixel size. Every bitmap face in these pickers failed at the configured font_size and silently fell back to the default — the setting appeared to do nothing, with only a log warning nobody reads.

Bitmap faces are now retried at the size the file's PIXEL_SIZE header declares. cozette.bdf is also dropped from mqtt-notifications' picker: shipped by neither the core nor the plugin, so it could only ever fall back. youtube-stats never listed it.

That's five plugins with one bug (clock-simple #362, news #369, tide-display #370, plus these two). I've filed the root cause against the core as ChuckBuilds/LEDMatrix#517FontManager.resolve_font degrades to the default face for any .bdf without signalling it, which is why each plugin had to work around it separately. If that lands, these five copies can drop their workarounds.

Verification is unit-level here, deliberately

Neither plugin draws text without credentials — mqtt-notifications needs a broker, youtube-stats an API key — so the hash-comparison I've used elsewhere produces identical "no data" screens whatever font is set. It would have looked like a pass while proving nothing.

Instead the loader's own path is exercised directly:

5x7.bdf: PIXEL_SIZE=7  | at 8: fails (invalid pixel size) | at 7: loads
4x6.bdf: PIXEL_SIZE=6  | at 8: fails (invalid pixel size) | at 6: loads

That is exactly the branch the fix takes.

A side finding

mqtt-notifications could not be harnessed at all before this. It fails to instantiate without paho-mqtt — which is in its requirements.txt, but not in the core's environment — so check_plugin.py returns eight load errors rather than a result:

[FAIL] 128x32 <load> error=PluginError('Failed to instantiate plugin mqtt-notifications:
       paho-mqtt is required. Install with: pip install paho-mqtt')

I installed it locally and the plugin then passes 8/8. Worth knowing if CI runs the harness without installing plugin requirements first — that plugin would be failing silently in the same way.

Verification

  • check_plugin.py8/8 PASS for both (mqtt after installing paho-mqtt)
  • check_module_collisions.py — OK across 43 plugins
  • manifests bumped 1.1.1 → 1.2.0 each, plugins.json regenerated

Issues filed alongside this

Per your request, findings I'm not fixing here are now tracked rather than left in PR descriptions:

🤖 Generated with Claude Code

Completes the sweep. A .bdf exists at exactly one pixel size and FreeType
rejects any other with "invalid pixel size", so every bitmap face in these two
pickers failed at the configured font_size and silently fell back to the
default -- choosing one appeared to do nothing, with only a log warning nobody
reads. Bitmap faces are now retried at the size the file's PIXEL_SIZE header
declares.

cozette.bdf is also removed from mqtt-notifications' picker. The file is
shipped by neither the core nor the plugin, so selecting it could only ever
fall back. youtube-stats never listed it.

Same fix already landed for clock-simple (#362), news (#369) and tide-display
(#370), which carry copies of this loader. That is five plugins with one bug,
so the root cause is filed against the core as ChuckBuilds/LEDMatrix#517:
FontManager.resolve_font degrades to the default face for any .bdf without
signalling it, which is why each plugin had to work around it separately.

Verification is unit-level rather than by render, because neither plugin draws
text without credentials -- mqtt-notifications needs a broker and youtube-stats
an API key, so the hash-comparison used on the other plugins produces identical
"no data" screens either way. Instead the loader's own path is exercised
directly: _bdf_pixel_size returns 7 for 5x7.bdf and 6 for 4x6.bdf,
ImageFont.truetype fails for both at size 8, and succeeds at the reported
native size. That is exactly the branch the fix takes.

The harness passes 8/8 for both. mqtt-notifications could not be harnessed at
all before this: it fails to instantiate without paho-mqtt, which is in its
requirements.txt but not in the core's environment, so anyone running
check_plugin without installing it first sees eight load errors rather than a
result.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 0ff1fa88-d2be-4135-8e0b-6a5a8a91e762


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

Not up to standards ⛔

🔴 Issues 1 medium

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
Security 1 medium

View in Codacy

🟢 Metrics 17 complexity

Metric Results
Complexity 17

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.

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