Skip to content

Fix baseball custom fonts and abbreviation KeyError#63

Closed
ChuckBuilds wants to merge 4 commits intomainfrom
fix/baseball-custom-fonts
Closed

Fix baseball custom fonts and abbreviation KeyError#63
ChuckBuilds wants to merge 4 commits intomainfrom
fix/baseball-custom-fonts

Conversation

@ChuckBuilds
Copy link
Copy Markdown
Owner

@ChuckBuilds ChuckBuilds commented Mar 30, 2026

Summary

  • Adds custom font support to baseball game renderer (was hardcoded unlike basketball/football)
  • Fixes BDF font loading (ImageFont.load instead of truetype)
  • Fixes KeyError when NCAA baseball teams lack abbreviation field in ESPN API (uses .get() with fallback)
  • Fixes odds ticker y-position font mismatch

Supersedes #61 which is a subset of these changes.

Test plan

  • Verify NCAA baseball games render without KeyError
  • Verify custom fonts load correctly in baseball game renderer
  • Verify odds ticker y-position alignment

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added customizable font options for scoreboard text elements (scores, team names, status, details, and rankings).
  • Bug Fixes

    • Improved handling of incomplete team data by deriving team abbreviations from team names as a fallback.
    • Enhanced font loading error handling with automatic fallbacks to default fonts.
    • Fixed odds layout calculation for accurate vertical positioning.
  • Chores

    • Baseball Scoreboard updated to v1.5.6; Odds Ticker updated to v1.1.3.

ChuckBuilds and others added 4 commits March 29, 2026 22:15
Some NCAA baseball teams lack the 'abbreviation' field in ESPN API
responses, causing KeyError crashes. Use .get() with fallback to
team name truncated to 3 chars, matching the pattern already used
in sports.py and data_manager.py.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ismatch

Baseball game_renderer was hardcoding fonts instead of reading from
customization config like basketball and football do. Also fixes textbbox
using 'time' font instead of 'detail' font for odds y-position calculation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…dates

Fix TypeError when team name is None by using `or` coalescing instead of
passing potentially-None values to [:3] slice. Log default font fallback
failures instead of silently swallowing them. Update last_updated and
latest_version in manifests and registry.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BDF fonts can't be loaded via ImageFont.truetype(). Look for pre-converted
.pil/.pbm files and use ImageFont.load(), matching the football renderer
pattern. Also adds OTF support and better logging for missing/unknown fonts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR updates version metadata for the baseball-scoreboard and odds-ticker plugins, introduces defensive fallback logic for extracting team abbreviations in both plugins, and adds configurable font loading with enhanced error handling to the baseball scoreboard renderer.

Changes

Cohort / File(s) Summary
Metadata and Versioning
plugins.json, plugins/baseball-scoreboard/manifest.json, plugins/odds-ticker/manifest.json
Updated plugin versions: baseball-scoreboard from 1.5.5 to 1.5.6, odds-ticker from 1.1.1 to 1.1.3. Added new version entries to manifests with release date 2026-03-29 and ledmatrix_min 2.0.0. Updated last_updated timestamps.
Defensive Team Abbreviation Extraction
plugins/baseball-scoreboard/baseball.py, plugins/odds-ticker/manager.py
Modified abbreviation extraction to use defensive fallback logic: attempts team.abbreviation, falls back to first 3 characters of team.name, or defaults to "?" if both are missing. Prevents crashes and ensures deterministic placeholders for downstream filtering and display.
Baseball Scoreboard Renderer Enhancements
plugins/baseball-scoreboard/game_renderer.py
Introduced configurable font loading via config["customization"] for six font types (score_text, period_text, team_name, status_text, detail_text, rank_text). Refactored _load_fonts to delegate to new _load_custom_font helper supporting .ttf/.otf/. bdf formats with fallback chain. Expanded error handling with exception logging and multiple fallback attempts. Adjusted odds layout to use detail font for vertical positioning calculation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix baseball custom fonts and abbreviation KeyError' directly summarizes the two main changes: adding custom font support to the baseball renderer and fixing the KeyError for missing team abbreviations in NCAA data.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/baseball-custom-fonts

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 and usage tips.

@ChuckBuilds
Copy link
Copy Markdown
Owner Author

Closing — these changes are already on main.

@ChuckBuilds ChuckBuilds deleted the fix/baseball-custom-fonts branch March 30, 2026 13:35
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