fix(ui): Chinese and Korean letters are drawn by their own Windows font, not Japanese Yu Gothic's boxes #3152
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3152
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/cjk-menu-fonts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On Windows, the Insert menu in Simplified Chinese shows many letters as boxes ("画□□□", "□高比", "□出分辨率"), and in Korean every Hangul letter would be one. On
main: set Game language to 简体中文 (Menu language Auto), press Insert, Graphics.The UI (
game/crates/ui/src/text.rs) read one system font for all of Han, Kana, Hangul and Bopomofo: the first file of its list found, which on Windows is always Yu Gothic (Japanese). Yu Gothic lacks many Simplified Chinese letters and every Hangul one, and Microsoft YaHei and Malgun Gothic after it in the list were never read.This reads the first usable file for each CJK system font and gives each script and language its own first:
The system's fonts are fontique's fallbacks only, no longer in the family list every text is given: that list is tried before any fallback, so a CJK font in it draws every language's Han and Kana (with the four fonts read, Microsoft YaHei would have drawn the Japanese menu). The texts get the menu's language as their locale: the UI thread sends
Msg::FontLanguagewhenmenu_lang()changes (game/crates/longshot-game/src/ui.rs), and the main thread'sMeasurermeasures in it too (game/crates/api/src/services/ui.rs). A system font's bytes are read once for the process and shared by both.Read first:
game/crates/ui/src/text.rsCJK_FONTS,CJK_FALLBACKS,fallback_plan,fallbacks_from/register_fallback, thenFonts::set_languageandprops.Fixes #3075
Testing
Tested: Windows 10, RTX 4090, driver 617.42, 2560x1440, keyboard and mouse; Insert menu, Graphics tab, Game language set in the run's settings, Menu language Auto.
main(299ed5b70's text code, unchanged onmainsince; #3149's runtime), Simplified Chinese: many letters are boxes ("画□□□", "□高比", "□出分辨率", "□生成与延□").v3.2.0-293-gd3be22ce1), Simplified Chinese: every letter drawn ("画质预设", "宽高比", "输出分辨率", "帧生成与延迟"); Korean: every Hangul letter drawn (Malgun Gothic); Japanese: kana and kanji drawn by Yu Gothic, as onmain. No fault in any run's log.mainand this PR in Simplified Chinese, this PR in Korean and Japanese).Checks (Linux, WSL Ubuntu 22.04):
cargo test -p game-ui --lib: on the test commit4f807ec2eeach_cjk_script_and_language_is_drawn_by_its_own_windows_font_first_the_others_after_itfails (Hangul: Malgun Gothic: Yu Gothic is Hangul's one font) andthe_system_fonts_are_fallbacks_only_and_han_takes_its_language_s_firstfails (the system's fonts are not in every text's family list); on5e6cb633c176 passed, 0 failed. The second test runs the real registration with stand-ins for the system fonts (Atkinson for Microsoft YaHei, Libertinus Serif for Yu Gothic) and asks fontique's fallback list for Han by default, Han in Japanese and Kana.tests/test_gfx_world.py(readsgame/crates/api/src/services/ui.rs) passes on both sides.cargo check -p api -p longshot-game -p modtool --all-targetsbuilds;cargo fmt --checkclean;cargo clippy -p game-ui -- -D warningshas nothing in the changed files.--stricton5e6cb633cagainstmainca830e895: 843 passed, 42 failed, 13 skipped on both, the same 42 files (they fail onmainin this WSL). The in-game runs were on d3be22ce1, the same two patches before the rebase ontoca830e895(git range-diff:=for both;mainchanged none of these files).Still to test:
Measurements
Nothing on the frame path: the fonts are read once, the first time a text needs a system font, and a language change lays the texts out again once. Memory: reading every CJK font found takes, on this PC's Windows 10, Microsoft YaHei 19.7 MB + JhengHei 21.4 MB + Yu Gothic 13.7 MB + Malgun Gothic 13.5 MB = 68.3 MB, where
mainread Yu Gothic alone (13.7 MB); once for the process (the UI thread and the main thread's measurer share the bytes). Mapping the files instead would needunsafecode, which the workspace denies: a follow-up if the team wants it.Risks
On Windows, a CJK letter takes another font than before (a Japanese menu's: the same, Yu Gothic), and 54 MB more memory once any text needs a system font (the language rows 日本語 / 한국어 / 简体中文 are enough). Every text now has the menu's language as its locale: fonts with localized forms (
locl) may draw a letter in that language's form. Nothing changes in saves or settings; a revert is enough.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened (tests/test_gfx_world.pyreadsgame/crates/api/src/services/ui.rs: it passes unchanged).mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZksJ2byiSpsd2k2YbY
Tested in game: Windows 10, RTX 4090, driver 617.42, 2560x1440; Insert menu, Graphics tab, Game language in the settings, Menu language Auto. main (299ed5b70's text code, unchanged since), Simplified Chinese: many letters are boxes. This PR (d3be22ce1, the same patches as this head): Simplified Chinese, Korean and Japanese all drawn, no boxes; Japanese by Yu Gothic as before; no fault in the logs.
Screenshots: Windows 10, RTX 4090, 2560x1440; Insert menu, Graphics tab, Game language set in the run's settings, Menu language Auto.
main(299ed5b70's text code), Simplified Chinese: the letters Yu Gothic lacks are boxes.This PR (d3be22ce1), Simplified Chinese: every letter drawn.
This PR, Korean: every Hangul letter drawn (on
mainHangul has no font). The thin 업 and 프 in the two orange headings are the faux-bold bug this PR does not change; its own PR follows.This PR, Japanese: kana and kanji by Yu Gothic, as on
main.WIP: fix(ui): Chinese and Korean letters are drawn by their own Windows font, not Japanese Yu Gothic's boxesto fix(ui): Chinese and Korean letters are drawn by their own Windows font, not Japanese Yu Gothic's boxes@review
Recommendation: Request changes. It conflicts with its base branch: bring it up to date (
@fixor@rebasetry first). (L3) The reported Windows runs show that the Chinese and Korean menu text is drawn, and the fix has a game-free regression test. The changed fallback registration also runs on Linux, where its rendering has not yet been checked in game.The change selects CJK fallback fonts by script and menu language, fixing missing Chinese and Korean glyphs on the tested Windows system. It adds approximately 54 MB of retained font data on that system and changes fallback selection on Linux as well.
Blocking (1): must change before merging.
@fixor@rebasetry first). (for the author)Should fix (1): not blocking, but worth doing before merging.
game/crates/ui/src/text.rs:131: The plan selects the first existing file before trying to read or register it, so an unreadable or invalid font prevents trying later paths in the same group. (more on the line) Do: Choose the first path that can be read and yields registered font families, continuing through the group's remaining paths on failure.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/ui/src/text.rs:319: Check the changed fallback registration in a Linux game run. (more on the line) Do: On Linux, open the same menu in Simplified Chinese, Traditional Chinese, Japanese and Korean and check the text and language names for missing or incorrect glyphs.@fixcan do L2.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported Windows bug: the author reports boxes on main and readable Simplified Chinese and Korean text with the change, with Japanese also checked. Linux behavior remains unverified in game.
Other systems: Font selection and text locale also change on Linux, including the Steam Deck; no Linux game run is reported. Arabic and Hebrew system fonts now enter the fallback lists rather than the common family list. The UI thread and main-thread measurer share font bytes through a mutex-protected cache.
Switches: None.
Reviewed:
5e6cb633cfagainstca830e8959: Read the available repository rules, PR template, standards, diff, commit messages, font fallback implementation and tests, language sender and measurer changes, and relevant renderer and editor callers. The large core and API files were inspected around the changed paths rather than read in full. The linked screenshots were not accessible in the closed network; their reported results were considered. The sibling Tooling AGENTS.md and docs/review-checklist.md were not present.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run for this read-only review. The author reports game-free tests passing and Windows in-game checks; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -83,0 +128,4 @@fn fallback_plan(there: &dyn Fn(&str) -> bool) -> Vec<Fallback> {let found: Vec<(Cjk, &'static str)> = CJK_FONTS.iter().filter_map(|(lang, paths)| paths.iter().copied().find(|p| there(p)).map(|p| (*lang, p)))L2 (should fix): The plan selects the first existing file before trying to read or register it, so an unreadable or invalid font prevents trying later paths in the same group.
When: On Linux, if the first Noto path exists but cannot be read and a later Source Han path is usable, the plan includes only the Noto path. Registration then produces no CJK fallback, whereas the previous loop continued to the next path after a failed read or registration.
Do: Choose the first path that can be read and yields registered font families, continuing through the group's remaining paths on failure.
@ -229,1 +317,3 @@}let there = |p: &str| expand(p).is_some_and(|p| std::path::Path::new(&p).is_file());self.fallbacks_from(&there, &system_file);}L1 (should fix): Check the changed fallback registration in a Linux game run.
When: Linux now registers its CJK font only as script fallbacks and applies the menu locale, while the reported game runs cover Windows alone. A Linux font collection or locale selection can therefore produce different glyphs or missing text without being covered by those runs.
Do: On Linux, open the same menu in Simplified Chinese, Traditional Chinese, Japanese and Korean and check the text and language names for missing or incorrect glyphs.
@fix
5e6cb633cff8825d13faRecommendation: Approve. The code is ready: only testing is left. The Windows runs show the missing Chinese and Korean letters drawn, but the changed Linux fallback registration still needs an in-game run. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
f8825d13fa. I rebased it ontomain(095c4c0461).Conflicts resolved
game/crates/ui/src/core.rsI edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The change selects system font fallbacks by script and menu language and shares font bytes between the UI and measurer. It fixes the reported Windows rendering issue at a reported cost of about 54 MB of additional memory on the tested PC.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/ui/src/text.rs:319: Check the changed fallback registration in a Linux game run. When: Linux now registers its CJK font only as script fallbacks and applies the menu locale, while the reported game runs cover Windows alone. A Linux font collection or locale selection can therefore produce different glyphs or missing text without being covered by those runs. Do: On Linux, open the same menu in Simplified Chinese, Traditional Chinese, Japanese and Korean and check the text and language names for missing or incorrect glyphs.Checks: they run again on this head; a failure shows on the pull request.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported Windows cases: the author reports boxes on main and correctly drawn Simplified Chinese and Korean text with the change. Linux rendering remains unverified in a game run.
Other systems: The fallback change also affects Linux and other scripts that use system fonts; no Linux game run is reported. The recorded Windows run covers Simplified Chinese, Korean and Japanese on one system.
Switches: None.
Reviewed:
f8825d13faagainst095c4c0461: Read AGENTS.md, CONTRIBUTING.md, the font selection and registration code, the fix diff, and the focused UI diffs. The full base diff was truncated and includes many files beyond the four described; the changed code files were not all read in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run during this review. The author reports Windows game runs and Linux-hosted checks; CI has not run on the fix head.
Overlaps and merge order: Not checked.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
LGTM
Additional Windows verification for #3075, covering the shader preparation screen.
On
nightly-1022-b4d56f52with Simplified Chinese selected, 备 (U+5907), 过 (U+8FC7), 仅 (U+4EC5), 进 (U+8FDB), and 闭 (U+95ED) appeared as boxes. I checked the installed font collections on the affected PC.YuGothM.ttclacks all five glyphs, andmsyh.ttccovers them. Nightly 1077 still used the first usable CJK font as its only CJK system fallback.For an independent check on
nightly-1077-f577a1ae, I rebuilt only the Vulkan renderer with a small Windowszh-Hansworkaround. Ingpu/vk/vk_ui.cpp,tell_fonts()reads the installedmsyh.ttcand registers it throughhost->ui_font. The resulting build passed verification for all 54 files in its manifest. An in-game smoke test logged Microsoft YaHei registration, loaded a copied save, evaluated a scene frame with DLSS 5, and exited cleanly.These results are from the local Nightly 1077 workaround. This PR addresses the same fallback selection in the shared UI code.