Skip to content

fix(baseball-scoreboard): measure odds placement with the card's on-grid fonts (1.57.2) - #617

Merged
ChuckBuilds merged 2 commits into
mainfrom
fix/baseball-odds-top-edge
Oct 4, 2026
Merged

ChuckBuilds merged 2 commits into
mainfrom
fix/baseball-odds-top-edge

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

plugins/baseball-scoreboard/test_odds_placement.py failed two checks on a Windows checkout against a fresh core main:

  • 64x32 stays at the top when the O/U is short: y=8
  • a narrow panel with short strings still uses the top edge: y=8

Nothing moved the odds. The same two checks fail against every game_renderer.py back to #268, the PR that added the test. The core's 4x6-font.ttf has 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:

Engine Where "O/U: 8.5" "▲3" Inning starts at Result on 64px
Raqm Linux wheels: CI, the Pi 25.7px 9.1px x=27 clears, y=0
basic Windows wheel (no Raqm) 30px 10px x=27 3px overlap, y=8

_draw_dynamic_odds measures 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.BASIC and Layout.RAQM). With these fonts any O/U reaches the inning on a 64px panel, so the two cases now test what does fit there:

  • a spread alone stays at the top edge on 64x32
  • the same spread steps down beside a recent card's wider "Final" (same panel, same odds, different top row)

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.py repeated 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 with update_registry.py; commit is 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.py already 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)
  • Mutation check: forcing _odds_would_hit_top_row to False fails 7 checks; forcing it to True fails 14
  • The old test passes on hdpi and fails on Windows, which confirms the engine diagnosis
  • scripts/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-scoreboard against a fresh core: 25 renders pass, exit 0
  • update_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.py
  • scripts/test_*.py guards

Pre-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

…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>
@coderabbitai

coderabbitai Bot commented Oct 4, 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: Advanced
  • Run ID: dce858c4-8c08-424b-9a6c-ae4fba11465c
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 0 complexity

Metric Results
Complexity 0

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.

#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>
@ChuckBuilds ChuckBuilds changed the title fix(baseball-scoreboard): measure odds placement with the card's on-grid fonts (1.57.1) fix(baseball-scoreboard): measure odds placement with the card's on-grid fonts (1.57.2) Oct 4, 2026
@ChuckBuilds
ChuckBuilds merged commit 39a7a45 into main Oct 4, 2026
5 checks passed
@ChuckBuilds
ChuckBuilds deleted the fix/baseball-odds-top-edge branch October 4, 2026 18:27
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