font: rasterize glyphs larger than 128 pixels #1214

Manually merged
github merged 1 commit from gh-pr/1214/head into gh-pr/1214/base 2026-11-26 09:48:03 +00:00
Owner

@⁠Cosmo on GitHub · 2026-10-08 14:56 UTC · original
Cosmo:fix/font-glyph-size → main · +17 −15 · 1 files · 1 commits · merged 2026-10-08 16:03 UTC

Astro's Playroom (PPSA01325) shows area names as large title cards, for example PLAYSTATION LABO.

Since f96a14a0 rasterizes glyphs at the size the game asks for, these letters were drawn cut into bands: glyph images were still rendered into a fixed 128x128 buffer, so everything past 128 pixels was missing.

Before that commit the title was whole but too small.
Glyph images now grow to the glyph's size.
The VGA fallback font keeps its 128-pixel limit, and scalable glyphs are limited to 4096 pixels only to reject absurd scales.

I left the comments so that the magic numbers are explained.

AI use

Research, implementation and tests were done with Claude Code at my direction.
I reviewed the code, and tested it as described above.

Screen captures

Screenshot of older builds as reference:
image

Current upstream:
image

After fix:
image

**@⁠Cosmo** on GitHub · 2026-10-08 14:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1214) `Cosmo:fix/font-glyph-size` → `main` · +17 −15 · 1 files · 1 commits · merged 2026-10-08 16:03 UTC Astro's Playroom (PPSA01325) shows area names as large title cards, for example PLAYSTATION LABO. Since f96a14a0 rasterizes glyphs at the size the game asks for, these letters were drawn cut into bands: glyph images were still rendered into a fixed 128x128 buffer, so everything past 128 pixels was missing. Before that commit the title was whole but too small. Glyph images now grow to the glyph's size. The VGA fallback font keeps its 128-pixel limit, and scalable glyphs are limited to 4096 pixels only to reject absurd scales. I left the comments so that the magic numbers are explained. ## AI use Research, implementation and tests were done with Claude Code at my direction. I reviewed the code, and tested it as described above. ## Screen captures Screenshot of older builds as reference: <img width="1440" height="802" alt="image" src="https://github.com/user-attachments/assets/88af074c-ed74-48a8-bc18-4783b8df7a0d" /> Current upstream: <img width="1416" height="796" alt="image" src="https://github.com/user-attachments/assets/fecefc13-1049-4710-aa4e-ab32cb9945d1" /> After fix: <img width="1422" height="800" alt="image" src="https://github.com/user-attachments/assets/12f58644-1a26-41a7-9d05-8e8bcac248de" />
Glyph images were rendered into a fixed 128x128 buffer and their width and
height were clamped to 128. Since glyphs are rasterized at the requested
scale (f96a14a0), large text such as title cards lost every row and column
past 128 pixels, so letters were drawn cut into bands.

The glyph buffers now grow to the glyph's bitmap box and width_byte is the
glyph's width. The VGA fallback font keeps its 128-pixel limit; scalable
glyphs are limited to 4096 pixels only to reject absurd scales.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:48:02 +00:00
github manually merged commit 2f8b740fa9 into gh-pr/1214/base 2026-11-26 09:48:03 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 15:00 UTC · original

Review in Change Stack →

📝 Walkthrough

Walkthrough

Glyph and fallback image storage now uses dynamically sized vectors instead of fixed-size arrays. TrueType glyph dimensions are limited to 4096 pixels, and buffers are sized to the glyph dimensions with at least one byte for blank glyphs. TrueType rasterization and fallback bitmap writes use the glyph width as the row stride. Fallback glyph selection and scaled dimensions remain unchanged.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🔵 Low · up to 2f8b7

Extremely large TrueType glyphs can be cropped instead of using the fallback font. This is a bounded edge case; the PR carries low merge risk, though the oversized-glyph handling should be corrected.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: support for rasterizing glyphs larger than 128 pixels.
Description check ✅ Passed The description explains the rendering defect, the affected game scenario, the buffer-sizing fix, and the retained size limits.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • 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.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 15:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1214#issuecomment-6062707799) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1214?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough Glyph and fallback image storage now uses dynamically sized vectors instead of fixed-size arrays. TrueType glyph dimensions are limited to 4096 pixels, and buffers are sized to the glyph dimensions with at least one byte for blank glyphs. TrueType rasterization and fallback bitmap writes use the glyph width as the row stride. Fallback glyph selection and scaled dimensions remain unchanged. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"2f8b740fa9263b86580b227c899e0a45a516dabd" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **🔵 Low** · up to `2f8b7` <!-- final_review_risk_coverage:{"sourceCommitId":"2f8b740fa9263b86580b227c899e0a45a516dabd","coveredCommitId":"2f8b740fa9263b86580b227c899e0a45a516dabd","kind":"reviewed"} --> Extremely large TrueType glyphs can be cropped instead of using the fallback font. This is a bounded edge case; the PR carries low merge risk, though the oversized-glyph handling should be corrected. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :--------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :------- | :------------------------------------------------------------------------------------------------------------------------------ | | Title check | ✅ Passed | The title clearly identifies the main change: support for rasterizing glyphs larger than 128 pixels. | | Description check | ✅ Passed | The description explains the rendering defect, the affected game scenario, the buffer-sizing fix, and the retained size limits. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1214)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -873,2 +873,2 @@
const auto width = static_cast<uint32_t>(std::clamp(x1 - x0, 0, FONT_BITMAP_MAX_DIM));
const auto height = static_cast<uint32_t>(std::clamp(y1 - y0, 0, FONT_BITMAP_MAX_DIM));
const auto width = static_cast<uint32_t>(std::clamp(x1 - x0, 0, FONT_GLYPH_MAX_DIM));
const auto height = static_cast<uint32_t>(std::clamp(y1 - y0, 0, FONT_GLYPH_MAX_DIM));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 15:00 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject oversized TrueType glyphs instead of cropping them.

If a bitmap box exceeds 4096 pixels, these clamps reduce its dimensions and init_stb_image still returns success. The rasterized glyph is cropped, rather than rejected as intended. Check the original box dimensions before allocation and return a failure for an oversized glyph.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 15:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1214#discussion_r4220593294) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Reject oversized TrueType glyphs instead of cropping them.** If a bitmap box exceeds 4096 pixels, these clamps reduce its dimensions and `init_stb_image` still returns success. The rasterized glyph is cropped, rather than rejected as intended. Check the original box dimensions before allocation and return a failure for an oversized glyph. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:fdc775634616d846e29c06bc --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 15:00 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c841d46b-f8f4-4612-83ff-6ce5e02b6195
📥 Commits

Reviewing files that changed from the base of the PR and between aa3b2cd57f and 2f8b740fa9.

📒 Files selected for processing (1)
  • src/libs/libFont.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 15:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1214#pullrequestreview-5458628153) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c841d46b-f8f4-4612-83ff-6ce5e02b6195` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between aa3b2cd57f84e414a4af0ccbc42d7eb35a8af17b and 2f8b740fa9263b86580b227c899e0a45a516dabd. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/libs/libFont.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=a5fb636a-0958-41a5-938a-e39272e76aa8 attempt=2ed2de54-54cd-4f85-8c21-d0c5b4db258f batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-08 16:01 UTC · original

@⁠Cosmo Thanks!

**@⁠Nmzik** on GitHub · 2026-10-08 16:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1214#issuecomment-6063909158) @⁠Cosmo Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.