fix: resolve font NameError, JPEG/webp mismatch, and duplicate Tower …of Hanoi entry- Load fonts once at top of generate_banner() to fix NameError in matrix branch- Bundle DejaVu Sans Bold font for consistent cross-platform rendering- Warn via RuntimeWarning if no font is found instead of failing silently- Save banners as true WebP instead of JPEG bytes in a .webp file- Remove duplicate Tower of Hanoi entry that silently overwrote its own output#1272
Merged
steam-bell-92 merged 1 commit intoJun 19, 2026
Conversation
…of Hanoi entry- Load fonts once at top of generate_banner() to fix NameError in matrix branch- Bundle DejaVu Sans Bold font for consistent cross-platform rendering- Warn via RuntimeWarning if no font is found instead of failing silently- Save banners as true WebP instead of JPEG bytes in a .webp file- Remove duplicate Tower of Hanoi entry that silently overwrote its own output
|
@Tech4Aditya is attempting to deploy a commit to the Anuj's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
🎉 Thank you for your contribution! Your Pull Request has been merged successfully. We appreciate the time and effort you put into improving this project. Contributions like yours help the repository grow and stay useful for everyone. If you'd like to contribute again, please check the open issues and make sure you are assigned before opening another Pull Request. Thanks again for your support! 🙌 |
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.
📝 Description
Fixes three bugs and bundles a missing asset in
web-app/generate_banners.py:1.
NameErrorcrash on the "matrix" banner branchfont_titlewas referenced inside thematrixbranch of the if-elif chain but only defined ~80 lines later, after the chain. Any banner with "matrix" in its name (e.g.Matrix Calculator) crashed withNameError: name 'font_title' is not defined. Fixed by extracting font loading into aload_fonts()helper called once at the top ofgenerate_banner(), before any drawing logic runs.2. Silent font fallback made banner text unreadable on non-Windows machines
The original fallback chain only checked
segoeui.ttfandarial.ttf— both Windows-only fonts that don't exist on Linux/macOS/CI. When neither was found, it silently fell back toImageFont.load_default()(a ~10px bitmap font), with no warning logged. Every banner generated outside Windows had broken text and no one would know. Fixed by:assets/fonts/DejaVuSans-Bold.ttf(Bitstream Vera license, safe to vendor) so font loading is OS-independent and requires no system font.RuntimeWarningonly if every option fails, so the failure is now visible instead of silent.3. Output saved as JPEG bytes inside a
.webpfilefinal_img.save(filename, "JPEG", quality=90)wrote JPEG-encoded data to paths ending in.webp. Tools/browsers reading by extension would attempt WebP decoding and fail or show corrupted output. Fixed by saving with"WEBP"format andmethod=6(libwebp's best compression preset, fine since this only runs at build time).4. Duplicate
"Tower of Hanoi"entry silently overwrote its own outputThe
projectslist had two entries (mathandutilities) pointing to the same filenametower-of-hanoi.webp. The second call silently overwrote the first, so the utilities-styled banner never made it to disk. Removed the duplicate with an inline comment explaining why.Note: this file already depends on Pillow (
PIL) before my changes — I didn't introduce a new third-party dependency. Flagging in case the "standard library only" guideline needs a separate conversation about the existing PIL usage.🔗 Linked Issue
Closes #1183
📋 Contribution Checklist