fix(baseball-scoreboard): measure odds placement with the card's on-grid fonts (1.57.2) - #617
Merged
Merged
Conversation
…rid fonts (1.57.1)
test_odds_placement.py failed two checks on Windows ("64x32 stays at the
top when the O/U is short", "a narrow panel with short strings still uses
the top edge": y=8) while passing in CI and on the Pi. Nothing in the
plugin or the core moved the odds: the test fails the same way against
every game_renderer.py back to #268, which added it, and the core's
4x6-font.ttf has not changed since it was added.
The test measured with 4x6 at size 6, off that font's 7px grid. Off the
grid, Pillow's layout engines disagree: Raqm (the Linux wheels, so CI and
the Pi) keeps fractional advances, and the basic engine (the Windows wheel
has no Raqm) rounds each one. "O/U: 8.5" is 25.7px on the Pi and 30px on
Windows, beside an inning that starts at x=27 -- clear on one, a 3px
overlap on the other. The renderer measures with the engine that draws,
so it stepped down correctly on both; the expectation was the platform-
dependent part.
The test now measures with the card's defaults, which are on their grids
(4x6 at 7 for the odds, PressStart2P at 8 for the inning, "Final" and the
time), where both engines give the same whole pixels. With those, any
O/U reaches the inning on 64px, so the two cases become what does fit
there: a spread alone stays at the edge, and the same spread steps down
beside a recent card's wider "Final". It skips (exit 2) without the core's
fonts instead of falling back to PIL's default.
Also corrects the renderer comment that repeated the "O/U: 8.5 clears it
by 2px" figure; that comment is the only shipped change, hence the patch
bump. The sibling scoreboards' odds tests pass on both engines (ufc's
already uses these fonts), so there is nothing to port.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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 | 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.
#614 (case-sensitive asset paths) released baseball-scoreboard 1.57.1 while this branch was open. Keep its 1.57.1 entry and put this change's comment fix on top as 1.57.2; plugins.json regenerated with update_registry.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
plugins/baseball-scoreboard/test_odds_placement.pyfailed two checks on a Windows checkout against a fresh core main:64x32 stays at the top when the O/U is short: y=8a narrow panel with short strings still uses the top edge: y=8Nothing moved the odds. The same two checks fail against every
game_renderer.pyback to #268, the PR that added the test. The core's4x6-font.ttfhas one commit (the one that added it). CI ran this test green on #606, and it passes on hdpi.The cause is the font size the test measured with, combined with Pillow's layout engine. The test used 4x6 at size 6, off that font's 7px grid. Off the grid, Pillow's two layout engines measure differently:
"O/U: 8.5""▲3"_draw_dynamic_oddsmeasures with the same engine that draws, so it made the right call on both platforms. The platform-dependent part was the test's expectation.The renderer is unchanged. The test now measures with the card's default fonts, which sit on their pixel grids: 4x6 at 7 for the odds, PressStart2P at 8 for the inning, "Final" and the time. At those sizes both engines give the same whole-pixel widths for the ASCII strings (checked on hdpi with both
Layout.BASICandLayout.RAQM). With these fonts any O/U reaches the inning on a 64px panel, so the two cases now test what does fit there:The test now skips (exit 2) when the core's fonts are missing, instead of falling back to PIL's default font, whose widths differ between Pillow versions.
Shipped change: a comment in
game_renderer.pyrepeated the "O/U: 8.5 clears it by 2px" figure, so it's corrected. The comment is the only shipped change, hence the patch bump to 1.57.2 (#614 released 1.57.1 while this was open; this branch merges main and keeps that entry). The registry was regenerated withupdate_registry.py;commitis dropped until the post-merge workflow fills it, as designed.Sibling scoreboards: nothing to port. The other scoreboards' odds tests (afl, basketball, football, hockey, soccer, nrl, ufc) pass on Windows (basic engine) and in CI (Raqm). ufc's
test_odds_top_row_collision.pyalready measures with 4x6 at 7 and PressStart2P at 8, and this PR follows its pattern.Test plan
test_odds_placement.py: all checks pass on Windows (basic engine) against a fresh core main, and on hdpi (Raqm)_odds_would_hit_top_rowtoFalsefails 7 checks; forcing it toTruefails 14scripts/run_plugin_tests.py baseball-scoreboard --core <fresh core>: 54 passed, 0 failed after merging main (on main, the odds test fails on Windows only)check_plugin.py --plugin baseball-scoreboardagainst a fresh core: 25 renders pass, exit 0update_registry.py --check,check_version_bump.py --base origin/main baseball-scoreboard(1.57.1 → 1.57.2),check_module_collisions.py,check_manifests_ascii.pyscripts/test_*.pyguardsPre-existing and out of scope: the baseball harness makes live ESPN summary requests for the fake event id
test001(HTTP 400), on main too. It's flagged as a separate task.🤖 Generated with Claude Code