Font: fall back to a host CJK font so Chinese text is not drawn as '?' #1754

Open
github-bot wants to merge 1 commit from github-bot/gh-1754 into main AGit
Owner

@⁠ccxp on GitHub · 2026-10-20 08:11 UTC · original
ccxp:main → main · +205 −23 · 3 files · 1 commits · open

With the console language set to Chinese, some in-game text showed up as "??". This is not an encoding bug: libFont draws '?' on purpose for any character it cannot find in the font.

Root cause:

  • The game opens the PS5 system font sets (SC/TC/JP/KR) through FontOpenFontSet. Those fonts don't exist on the host, so libFont falls back to Roboto (3rdparty/tracy), which only has Latin glyphs.
  • stb_supported_codepoint() replaced every code point missing from the font with '?'.
  • The font format check only accepted .ttf/.otf, so TrueType collections (.ttc), which most Windows CJK fonts are (e.g. msyh.ttc), were rejected.
  • FontGetKerning() returned FONT_ERROR_NO_SUPPORT_CODE for any character missing from the primary face, including CJK characters.

The system overlay already merges a per-language CJK font through AddSystemFontFallbacks(), so it is not changed here.

Changes:

  • Add Common::FindCjkFontFiles(locale) (src/common/systemFonts.{h,cpp}). It tries KYTY_CJK_FONT first, then the installed system CJK fonts, ordered by the console locale so shared Han characters use the regional glyph forms: zh-Hans prefers Microsoft YaHei, zh-Hant Microsoft JhengHei, ja-JP Yu Gothic/Meiryo, ko-KR Malgun Gothic. macOS (PingFang, Hiragino, Apple SD Gothic Neo) and Linux (Noto Sans CJK, WenQuanYi, Droid Sans Fallback) paths are included too.
  • libFont: accept .ttc files and load face 0 through stbtt_GetFontOffsetForIndex().
  • libFont: add resolve_stb_glyph(), which picks the face per character: the font's own face first, then the host CJK fallback, and '?' only if neither has the glyph. Glyph metrics and bitmaps are computed with the face that was actually picked, using its own em scale.
  • libFont: FontGetKerning() returns OK with zero kerning when a character is drawn from the CJK fallback face, instead of FONT_ERROR_NO_SUPPORT_CODE.
  • libFont: log which CJK fallback font is used, or warn when none is found.

Testing: this is the same change, on the same base commit (1a053f9e), that was built successfully and verified in Astro Bot with the console language set to Chinese: text that used to show as "??" renders correctly.

**@⁠ccxp** on GitHub · 2026-10-20 08:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1754) `ccxp:main` → `main` · +205 −23 · 3 files · 1 commits · open With the console language set to Chinese, some in-game text showed up as "??". This is not an encoding bug: libFont draws '?' on purpose for any character it cannot find in the font. Root cause: - The game opens the PS5 system font sets (SC/TC/JP/KR) through FontOpenFontSet. Those fonts don't exist on the host, so libFont falls back to Roboto (3rdparty/tracy), which only has Latin glyphs. - stb_supported_codepoint() replaced every code point missing from the font with '?'. - The font format check only accepted .ttf/.otf, so TrueType collections (.ttc), which most Windows CJK fonts are (e.g. msyh.ttc), were rejected. - FontGetKerning() returned FONT_ERROR_NO_SUPPORT_CODE for any character missing from the primary face, including CJK characters. The system overlay already merges a per-language CJK font through AddSystemFontFallbacks(), so it is not changed here. Changes: - Add Common::FindCjkFontFiles(locale) (src/common/systemFonts.{h,cpp}). It tries KYTY_CJK_FONT first, then the installed system CJK fonts, ordered by the console locale so shared Han characters use the regional glyph forms: zh-Hans prefers Microsoft YaHei, zh-Hant Microsoft JhengHei, ja-JP Yu Gothic/Meiryo, ko-KR Malgun Gothic. macOS (PingFang, Hiragino, Apple SD Gothic Neo) and Linux (Noto Sans CJK, WenQuanYi, Droid Sans Fallback) paths are included too. - libFont: accept .ttc files and load face 0 through stbtt_GetFontOffsetForIndex(). - libFont: add resolve_stb_glyph(), which picks the face per character: the font's own face first, then the host CJK fallback, and '?' only if neither has the glyph. Glyph metrics and bitmaps are computed with the face that was actually picked, using its own em scale. - libFont: FontGetKerning() returns OK with zero kerning when a character is drawn from the CJK fallback face, instead of FONT_ERROR_NO_SUPPORT_CODE. - libFont: log which CJK fallback font is used, or warn when none is found. Testing: this is the same change, on the same base commit (1a053f9e), that was built successfully and verified in Astro Bot with the console language set to Chinese: text that used to show as "??" renders correctly.
With the console language set to Chinese, some in-game text showed up
as "??". This is not an encoding bug: libFont draws '?' on purpose for
any character it cannot find in the font.

Root cause:
- The game opens the PS5 system font sets (SC/TC/JP/KR) through
  FontOpenFontSet. Those fonts don't exist on the host, so libFont falls
  back to Roboto (3rdparty/tracy), which only has Latin glyphs.
- stb_supported_codepoint() replaced every code point missing from the
  font with '?'.
- The font format check only accepted .ttf/.otf, so TrueType
  collections (.ttc), which most Windows CJK fonts are (e.g. msyh.ttc),
  were rejected.
- FontGetKerning() returned FONT_ERROR_NO_SUPPORT_CODE for any
  character missing from the primary face, including CJK characters.

The system overlay already merges a per-language CJK font through
AddSystemFontFallbacks(), so it is not changed here.

Changes:
- Add Common::FindCjkFontFiles(locale) (src/common/systemFonts.{h,cpp}).
  It tries KYTY_CJK_FONT first, then the installed system CJK fonts,
  ordered by the console locale so shared Han characters use the
  regional glyph forms: zh-Hans prefers Microsoft YaHei, zh-Hant
  Microsoft JhengHei, ja-JP Yu Gothic/Meiryo, ko-KR Malgun Gothic.
  macOS (PingFang, Hiragino, Apple SD Gothic Neo) and Linux (Noto Sans
  CJK, WenQuanYi, Droid Sans Fallback) paths are included too.
- libFont: accept .ttc files and load face 0 through
  stbtt_GetFontOffsetForIndex().
- libFont: add resolve_stb_glyph(), which picks the face per character:
  the font's own face first, then the host CJK fallback, and '?' only if
  neither has the glyph. Glyph metrics and bitmaps are computed with the
  face that was actually picked, using its own em scale.
- libFont: FontGetKerning() returns OK with zero kerning when a
  character is drawn from the CJK fallback face, instead of
  FONT_ERROR_NO_SUPPORT_CODE.
- libFont: log which CJK fallback font is used, or warn when none is
  found.

Testing: this is the same change, on the same base commit (1a053f9e),
that was built successfully and verified in Astro Bot with the console
language set to Chinese: text that used to show as "??" renders
correctly. This checkout has not been built or tested separately.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:04:46 +00:00
Author
Owner

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

Review in Change Stack →

📝 Walkthrough

The change adds Common::FindCjkFontFiles to locate existing CJK font files through an environment override and platform-specific paths. Font initialization now supports .ttc files and loads a CJK fallback face based on the console language and locale. Glyph metrics and bitmap rendering use the primary face when possible, then the CJK fallback face, and finally ?. Kerning validation also checks glyph availability in the fallback face.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🔵 Low · up to aa759

Some CJK characters may still appear as question marks, and Linux users may see incorrect regional glyph forms. These are bounded cases, but both fallback gaps should be addressed.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding host CJK font fallback to prevent Chinese text from rendering as question marks.
Description check Passed The description is directly related to the changeset. It explains the root cause, implementation details, affected APIs, fallback behavior, and testing results.
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.
  • Autofix · 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-20 08:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1754#issuecomment-6286616859) <!-- 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/1754?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The change adds `Common::FindCjkFontFiles` to locate existing CJK font files through an environment override and platform-specific paths. Font initialization now supports `.ttc` files and loads a CJK fallback face based on the console language and locale. Glyph metrics and bitmap rendering use the primary face when possible, then the CJK fallback face, and finally `?`. Kerning validation also checks glyph availability in the fallback face. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"aa759ad391d1f48699e98e05b0a785796534e48f" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>aa759</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `aa759` --> <!-- final_review_risk_coverage:{"sourceCommitId":"aa759ad391d1f48699e98e05b0a785796534e48f","coveredCommitId":"aa759ad391d1f48699e98e05b0a785796534e48f","kind":"reviewed"} --> Some CJK characters may still appear as question marks, and Linux users may see incorrect regional glyph forms. These are bounded cases, but both fallback gaps should be addressed. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: adding host CJK font fallback to prevent Chinese text from rendering as question marks. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset. It explains the root cause, implementation details, affected APIs, fallback behavior, and testing results. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </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">Autofix</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=1754)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [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) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -0,0 +73,4 @@
AppendIfFile(result, path);
}
(void)locale;
#endif
Author
Owner

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,85p' src/common/systemFonts.cpp
sed -n '1,35p' src/common/systemFonts.h
sed -n '805,900p' src/libs/libFont.cpp
sed -n '9,32p' src/common/localization.cpp

Repository: KytyPS5/KytyPS5

Length of output: 7352


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- diff ---'
git diff --stat 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d aa759ad391d1f48699e98e05b0a785796534e48f
git diff -- src/common/systemFonts.cpp src/common/systemFonts.h src/libs/libFont.cpp 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d aa759ad391d1f48699e98e05b0a785796534e48f
printf '%s\n' '--- libFont relevant symbols ---'
rg -n -F --glob 'src/libs/libFont.cpp' -e 'resolve_stb_glyph' -e 'stbtt_GetGlyphHMetrics' -e 'stbtt_GetGlyphBitmap' -e 'FontGetKerning' -e 'cjk_fallback_face' -e 'cjk_fallback_has_glyph' -e 'FontGetGlyph' src/libs/libFont.cpp || true
printf '%s\n' '--- nearby libFont blocks ---'
sed -n '835,1030p' src/libs/libFont.cpp
printf '%s\n' '--- repository font/test references ---'
rg -n -F --glob '!build/**' --glob '!dist/**' -e 'FindCjkFontFiles' -e 'KYTY_CJK_FONT' -e 'NotoSansCJK' -e 'zh-Hant' -e 'ja-JP' src tests docs CMakeLists.txt .github 2>/dev/null || true

Repository: KytyPS5/KytyPS5

Length of output: 9678


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- comparable system overlay ordering ---'
sed -n '270,340p' src/graphics/presentation/systemOverlay.cpp
printf '%s\n' '--- init_stb_info and FontState initialization ---'
rg -n -F --glob '*.cpp' --glob '*.h' -e 'init_stb_info' -e 'init_stb_font' -e 'stbtt_InitFont' src | head -80
printf '%s\n' '--- font metadata tools and candidate availability ---'
command -v fc-scan || true
command -v fc-query || true
command -v otfinfo || true
command -v python3 || true
for p in \
  /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc \
  /usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc \
  /usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc \
  /usr/share/fonts/opentype/noto/NotoSansCJKsc-Regular.otf \
  /usr/share/fonts/truetype/wqy/wqy-microhei.ttc \
  /usr/share/fonts/wenquanyi/wqy-microhei/wqy-microhei.ttc \
  /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc \
  /usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf; do
  if test -f "$p"; then printf 'present %s\n' "$p"; fi
done

Repository: KytyPS5/KytyPS5

Length of output: 4174


🏁 Script executed:

sed -n '755,805p' src/libs/libFont.cpp
sed -n '1,90p' src/common/systemFonts.cpp
sed -n '1,25p' src/common/systemFonts.h

Repository: KytyPS5/KytyPS5

Length of output: 5026


Honor the console locale in the Linux CJK fallback order.

FindCjkFontFiles() discards locale on Linux and always returns the same list. cjk_fallback_face() selects the first usable file, and init_stb_info() always loads face 0. Therefore, when multiple regional fonts are installed, ja-JP, zh-Hant, and zh-Hans can all select a non-matching face and render shared Han glyphs with the wrong regional forms. The locale-aware ordering in AddSystemFontFallbacks() does not affect this libFont.cpp path. Add Linux locale-specific candidate or face selection before the generic fallback list.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 08:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1754#discussion_r4322889811) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '1,85p' src/common/systemFonts.cpp sed -n '1,35p' src/common/systemFonts.h sed -n '805,900p' src/libs/libFont.cpp sed -n '9,32p' src/common/localization.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 7352 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- diff ---' git diff --stat 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d aa759ad391d1f48699e98e05b0a785796534e48f git diff -- src/common/systemFonts.cpp src/common/systemFonts.h src/libs/libFont.cpp 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d aa759ad391d1f48699e98e05b0a785796534e48f printf '%s\n' '--- libFont relevant symbols ---' rg -n -F --glob 'src/libs/libFont.cpp' -e 'resolve_stb_glyph' -e 'stbtt_GetGlyphHMetrics' -e 'stbtt_GetGlyphBitmap' -e 'FontGetKerning' -e 'cjk_fallback_face' -e 'cjk_fallback_has_glyph' -e 'FontGetGlyph' src/libs/libFont.cpp || true printf '%s\n' '--- nearby libFont blocks ---' sed -n '835,1030p' src/libs/libFont.cpp printf '%s\n' '--- repository font/test references ---' rg -n -F --glob '!build/**' --glob '!dist/**' -e 'FindCjkFontFiles' -e 'KYTY_CJK_FONT' -e 'NotoSansCJK' -e 'zh-Hant' -e 'ja-JP' src tests docs CMakeLists.txt .github 2>/dev/null || true ``` Repository: KytyPS5/KytyPS5 Length of output: 9678 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- comparable system overlay ordering ---' sed -n '270,340p' src/graphics/presentation/systemOverlay.cpp printf '%s\n' '--- init_stb_info and FontState initialization ---' rg -n -F --glob '*.cpp' --glob '*.h' -e 'init_stb_info' -e 'init_stb_font' -e 'stbtt_InitFont' src | head -80 printf '%s\n' '--- font metadata tools and candidate availability ---' command -v fc-scan || true command -v fc-query || true command -v otfinfo || true command -v python3 || true for p in \ /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc \ /usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc \ /usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc \ /usr/share/fonts/opentype/noto/NotoSansCJKsc-Regular.otf \ /usr/share/fonts/truetype/wqy/wqy-microhei.ttc \ /usr/share/fonts/wenquanyi/wqy-microhei/wqy-microhei.ttc \ /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc \ /usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf; do if test -f "$p"; then printf 'present %s\n' "$p"; fi done ``` Repository: KytyPS5/KytyPS5 Length of output: 4174 --- 🏁 Script executed: ```bash sed -n '755,805p' src/libs/libFont.cpp sed -n '1,90p' src/common/systemFonts.cpp sed -n '1,25p' src/common/systemFonts.h ``` Repository: KytyPS5/KytyPS5 Length of output: 5026 --- </details> **Honor the console locale in the Linux CJK fallback order.** `FindCjkFontFiles()` discards `locale` on Linux and always returns the same list. `cjk_fallback_face()` selects the first usable file, and `init_stb_info()` always loads face 0. Therefore, when multiple regional fonts are installed, `ja-JP`, `zh-Hant`, and `zh-Hans` can all select a non-matching face and render shared Han glyphs with the wrong regional forms. The locale-aware ordering in `AddSystemFontFallbacks()` does not affect this `libFont.cpp` path. Add Linux locale-specific candidate or face selection before the generic fallback list. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:425253541c58522a4e647854 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -788,0 +849,4 @@
const auto& cjk = cjk_fallback_face();
return cjk.ok && stbtt_FindGlyphIndex(&cjk.info, static_cast<int>(code)) != 0;
}
Author
Owner

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,90p' src/common/systemFonts.cpp
sed -n '765,975p' src/libs/libFont.cpp

Repository: KytyPS5/KytyPS5

Length of output: 9976


🏁 Script executed:

git diff --no-ext-diff --unified=35 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d aa759ad391d1f48699e98e05b0a785796534e48f -- src/common/systemFonts.cpp src/common/systemFonts.h src/libs/libFont.cpp
printf '\n--- relevant references ---\n'
rg -n -F --glob '*.{cpp,h,md,txt}' -e 'FindCjkFontFiles' -e 'cjk_fallback_face' -e 'resolve_stb_glyph' -e 'KYTY_CJK_FONT' -e 'CJK fallback' -e 'AddSystemFontFallbacks' src docs README* 2>/dev/null || test "$?" -eq 1
printf '\n--- font-related tests/files ---\n'
rg --files | rg '(^|/)(.*[Ff]ont.*|.*[Tt]tf.*|.*[Ff]allback.*)(\.(cpp|h|md|txt|json|yaml|yml))?$' | head -100

Repository: KytyPS5/KytyPS5

Length of output: 21199


🏁 Script executed:

printf '%s\n' '--- resolve callers and API path ---'
rg -n -F --glob 'src/libs/libFont.cpp' -e 'get_stb_metrics(' -e 'init_stb_image(' -e 'fill_metrics_for_code(' -e 'FontRenderChar' -e 'FontGetRenderCharGlyphMetrics' -e 'FontGetCharGlyphMetrics'
sed -n '960,1065p' src/libs/libFont.cpp
sed -n '2115,2188p' src/libs/libFont.cpp
printf '%s\n' '--- localization contract ---'
rg -n -F --glob 'src/common/localization.*' -e 'LocaleName' -e 'ConsoleLanguage'
sed -n '1,180p' src/common/localization.cpp 2>/dev/null
sed -n '1,120p' src/common/localization.h 2>/dev/null

Repository: KytyPS5/KytyPS5

Length of output: 10648


Search all initialized fallback faces per code point.

When KYTY_CJK_FONT points to a structurally valid font that lacks a requested CJK glyph, cjk_fallback_face() selects it and stops. It never checks later files from FindCjkFontFiles(). If the primary font also lacks the glyph, resolve_stb_glyph() returns ? even when a later host font contains the glyph. Retain all initialized fallback faces and test them in order from resolve_stb_glyph().

**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 08:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1754#discussion_r4322889825) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '1,90p' src/common/systemFonts.cpp sed -n '765,975p' src/libs/libFont.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 9976 --- 🏁 Script executed: ```bash git diff --no-ext-diff --unified=35 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d aa759ad391d1f48699e98e05b0a785796534e48f -- src/common/systemFonts.cpp src/common/systemFonts.h src/libs/libFont.cpp printf '\n--- relevant references ---\n' rg -n -F --glob '*.{cpp,h,md,txt}' -e 'FindCjkFontFiles' -e 'cjk_fallback_face' -e 'resolve_stb_glyph' -e 'KYTY_CJK_FONT' -e 'CJK fallback' -e 'AddSystemFontFallbacks' src docs README* 2>/dev/null || test "$?" -eq 1 printf '\n--- font-related tests/files ---\n' rg --files | rg '(^|/)(.*[Ff]ont.*|.*[Tt]tf.*|.*[Ff]allback.*)(\.(cpp|h|md|txt|json|yaml|yml))?$' | head -100 ``` Repository: KytyPS5/KytyPS5 Length of output: 21199 --- 🏁 Script executed: ```bash printf '%s\n' '--- resolve callers and API path ---' rg -n -F --glob 'src/libs/libFont.cpp' -e 'get_stb_metrics(' -e 'init_stb_image(' -e 'fill_metrics_for_code(' -e 'FontRenderChar' -e 'FontGetRenderCharGlyphMetrics' -e 'FontGetCharGlyphMetrics' sed -n '960,1065p' src/libs/libFont.cpp sed -n '2115,2188p' src/libs/libFont.cpp printf '%s\n' '--- localization contract ---' rg -n -F --glob 'src/common/localization.*' -e 'LocaleName' -e 'ConsoleLanguage' sed -n '1,180p' src/common/localization.cpp 2>/dev/null sed -n '1,120p' src/common/localization.h 2>/dev/null ``` Repository: KytyPS5/KytyPS5 Length of output: 10648 --- </details> **Search all initialized fallback faces per code point.** When `KYTY_CJK_FONT` points to a structurally valid font that lacks a requested CJK glyph, `cjk_fallback_face()` selects it and stops. It never checks later files from `FindCjkFontFiles()`. If the primary font also lacks the glyph, `resolve_stb_glyph()` returns `?` even when a later host font contains the glyph. Retain all initialized fallback faces and test them in order from `resolve_stb_glyph()`. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4b603f7492ff40d89de3d64d --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6acb6ab1-bc3b-4609-b657-2f69b57cec72
📥 Commits

Reviewing files that changed from the base of the PR and between 1a053f9e13 and aa759ad391.

📒 Files selected for processing: 3
  • src/common/systemFonts.cpp
  • src/common/systemFonts.h
  • 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-20 08:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1754#pullrequestreview-5582486915) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `6acb6ab1-bc3b-4609-b657-2f69b57cec72` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 1a053f9e13405bf34171a47aae9f2b9a6e7afd7d and aa759ad391d1f48699e98e05b0a785796534e48f. </details> <details> <summary>📒 Files selected for processing: 3</summary> * `src/common/systemFonts.cpp` * `src/common/systemFonts.h` * `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=e65a161c-3021-4b5f-8a34-d5a1cc4d56cb attempt=d36ab93c-4004-4305-a9c1-011a41a077a5 batch=1/1 -->
This pull request has changes conflicting with the target branch.
  • src/libs/libFont.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1754/head:github-bot/gh-1754'
git switch 'github-bot/gh-1754'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1754'
git switch 'github-bot/gh-1754'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1754'
git switch 'github-bot/gh-1754'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1754'
git switch 'main'
git merge --squash 'github-bot/gh-1754'
git switch 'main'
git merge --ff-only 'github-bot/gh-1754'
git switch 'main'
git merge 'github-bot/gh-1754'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.