Repository navigation
Fonts: bound workbook families fall back to the interface chain (no CJK tofu) - #2408
dantehe729 wants to merge 1 commit into
Conversation
…JK tofu) font_definitions_with bound the workbook's installed families before the Proportional chain became the UI chain, so bind_faces appended egui's Latin-only default chain: once the font scan runs (storytold#974), a cell in any bound family (even Calibri) drew Chinese, Japanese, Korean, Thai and Hebrew as tofu. Bind them after the UI chain is in place, so each bound family ends with the cell font and the script fallback faces like the built-in roles. Regression test: a_bound_workbook_font_falls_back_to_the_interface_chain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Bind workbook faces with the UI chain crates/ui-egui/src/theme.rs |
The font-definition path collects installed workbook faces and binds them after setting the proportional family to the UI chain. A test checks the UI chain on all four Ubuntu style roles. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: justinjohn0306
Merge Risk: 
Minimal · up to 395c7
-
Workbook fonts are set up to inherit the UI fallback chain. No issue identified here calls for delaying the merge.
Architecture risk: 
Medium · up to 395c7
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in crates/ui-egui/src/theme.rs:
font_definitions_withnow collects installed workbook families and their faces, then passes them to the new privatefont_definitions_bindinghelper. - observed — Modified behavior in crates/ui-egui/src/theme.rs: Removed the earlier loop that bound installed workbook families before interface-family fallback adjustments.
- observed — Modified behavior in crates/ui-egui/src/theme.rs: Installed workbook faces are now bound after the proportional family is set to the UI chain, passing each collected family and its faces to
bind_faces. - observed — Modified behavior in crates/ui-egui/src/theme.rs: Added a test that creates a temporary Ubuntu face, builds definitions for Chinese, and checks that all four bound Ubuntu style-role chains end with the UI chain; it restores the standard bound roles and removes the temporary directory.
Reliability and maintainability
- inferred — Risk-relevant change factors for crates: blast_radius_1; direct_dependents_1
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: fonts bound to workbook families fall back to the interface chain, so there is no CJK tofu. The theme gathers the installed families among those used, gets their faces and passes them to font_definitions_binding, which builds the definitions with the interface fallback after each bound family. A family that the workbook names and the machine has should still draw its own glyphs, with CJK taken from the fallback chain only for missing characters, as Excel does. The fallback chain is the same one as in gridcraft#2324 (Khmer) and the related PRs, so the order of the chain should be decided once. Building font definitions for every used family is expensive, so the result should be cached until the set of used families changes. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
From @RockerHX's review: Arial, Tahoma and Verdana, each regular, bold, italic and bold italic, must end with the interface chain of their weight (ui-bold for bold roles, ui otherwise) and draw "中文ABC2026". It covers the CJK fallback order of storytold#2408 as well as storytold#2035. It's a separate test binary because it runs the process-wide font scan. On macOS 27 all 12 roles are checked and pass; with font_setup.rs and fonts.rs from main it fails with "fnt:Arial:nn must inherit ui". Co-authored-by: RockerHX <5380764+RockerHX@users.noreply.github.com>
Summary
Once the installed-font scan actually runs (#974), every workbook font that gets bound draws Chinese, Japanese, Korean, Thai and Hebrew text as tofu, including plain Latin families such as Calibri.
font_definitions_withbound the workbook families beforeFontFamily::Proportionalwas replaced with the UI chain.bind_facesappends the Proportional chain as the fallback, so at that point it still appended egui's default chain (Ubuntu-Light,NotoEmoji-Regular,emoji-icon-font), which has no script faces. A cell inCalibriholding满分小学霸 双11销售盘点rendered the digits and nothing else.This change binds the workbook families after the Proportional chain becomes the UI chain. Each bound family then ends with
sys-celland the script fallback faces (sys-cjk-han-zh,sys-cjk-han-ja,sys-cjk-hangul,sys-thai,sys-hebrew,sys-symbols), the same as the built-in roles.On
mainthe binding never runs, because nothing starts the scan in the apps (#974). So this bug only shows up together with #974, #1179 or #1931. The fix is independent of those PRs and works with any of them.Changes
theme::font_definitions_withresolvesusedto(name, faces)pairs and calls a new privatefont_definitions_binding, which binds them after the Proportional chain is set. The change is mechanical: the binding loop moves below the UI-chain step.New test
a_bound_workbook_font_falls_back_to_the_interface_chain: it binds a temporary Ubuntu face and asserts that all four role chains end with the UI chain. It fails with the old order:It passes with this change.
Validation (Windows 10, Simplified Chinese fonts)
cargo fmt --all -- --checkcargo clippy -p gridcraft-ui-egui --all-targets -- -D warningscargo test -p gridcraft-ui-egui --lib -- theme:: fonts::: 32 passed.cargo check -p gridcraft-ui-egui --target wasm32-unknown-unknownI did not run the full
cargo xtask cilocally, because the whole ui-egui suite takes more than 30 minutes on this machine. CI will cover the rest.🤖 Generated with Claude Code
Summary by CodeRabbit