Skip to content

i18n: the CJK fallback sits on the Latin baseline (#1309) - #1395

Merged
bflatastic merged 3 commits into
storytold:mainfrom
zitann2020:i18n/ja-cjk-baseline
Oct 29, 2026
Merged

bflatastic merged 3 commits into
storytold:mainfrom
zitann2020:i18n/ja-cjk-baseline

Conversation

@zitann2020

@zitann2020 zitann2020 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

The CJK fallback faces sat about 3 pt high at 12 pt, measured against the Latin capital's ink
bottom; they now sit on the same baseline. The tweak's factor is derived at install time from the face
and the row height rather than hardcoded, so a font swap does not need a new number.

Rebased onto main after #1322 landed: that PR gave the interface its own candidate list in
install_script_fallbacks, and this keeps the generated face name it introduced while applying the
tweak — name.clone() rather than the old name.to_string().

Verification: cargo +1.95 build -p effectcraft-ui-egui -j 1 and fmt --check are clean, and
script_font_tests passes (7 tests). clippy was not run here — the machine has 3.5 GB free and rustc
runs out of memory under it — so CI is the authority for that one.

Summary by CodeRabbit

  • Bug Fixes
    • Japanese text rendered with system fallback fonts now aligns more closely with surrounding text across several UI font sizes. This improves the consistency of mixed-script text, reducing noticeable shifts between Japanese glyphs and the interface’s primary font when a compatible Japanese font is available.

FeiLiuEM added a commit to FeiLiuEM/effectcraft that referenced this pull request Oct 18, 2026
…s the print ones

Windows ships a UI variant of its Japanese and Chinese families (`Meiryo`/`Meiryo UI`, `Yu
Gothic`/`Yu Gothic UI`, `MS Gothic`/`MS UI Gothic`, `Microsoft YaHei`/`Microsoft YaHei UI`,
`Microsoft JhengHei`/`Microsoft JhengHei UI`) whose kana and kanji are drawn for the screen, and its
own link table for `Segoe UI` picks the UI one for everything it draws. The interface should ask for
it - but the same lists feed `fonts::fallback_for`, which shapes composed frames, so reordering them
would change how existing projects render. The two orders are therefore separate: this leaves
`crates/text/src/fonts.rs` exactly as it is and gives the interface its own candidate list in
`install_script_fallbacks`, which falls back to the shared choice when the platform has no UI variant,
none is installed, or it does not cover the probe.

`PMingLiU` is in the interface list for its proportional spacing, not as a sibling of `MingLiU`: it is
MingLiU's proportional relative.

The rendered order is pinned by a test now: the Japanese list keeps `Yu Gothic` ahead of `Yu Gothic
UI`, and no UI name appears in the lists a document renders with. `the_interface_asks_for_the_
platforms_ui_faces` pins the interface list and checks that every other script the install probes has
none, so a script that draws correctly in any face keeps the shared order.

Review fixes: the locale is mapped once (the call passes the language, the helper maps it), the new
test sits after the storytold#394 test it had split from its doc comment, and the fonts.rs test asserts instead
of panicking inside a closure. Rebased on current main; storytold#1395 has not landed yet, so there is nothing
to rebase after it.
@zitann2020

Copy link
Copy Markdown
Contributor Author

Just checking in on the order rather than the timing: this and #1322 both change
install_script_fallbacks in crates/ui-egui/src/theme.rs, so whichever lands second needs a
rebase. If #1322 goes first I will move this one onto it rather than leave you resolving the overlap —
say which you would rather have.

Nothing else is outstanding from my side as far as I can tell: the test reads the sign now, the doc
says why A stands in for the baseline, and the measurement on your machine is in #1309.

zitann2020 and others added 3 commits October 26, 2026 02:39
Co-Authored-By: DeepSeek V4.1 Flash <noreply@deepseek.com>
Measured on a second machine (Noto Sans CJK JP), the ink-bottom gap after the
correction is 1.125 / 1.9375 / 1.71875 pt at 12 / 15 / 18 pt, so the old bound
failed at 15 and 18 where the interface is right. Without the correction the kana
sits 3-5 pt above the Latin ink, so the sign separates the two and the magnitude
only has to allow the face's own kana overshoot.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@deepseek.com>
epaint exposes no baseline, but a capital without a descender has its ink bottom on
it, so the Latin half of the pair is load-bearing. Suggested by FeiLiuEM in storytold#1309.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@deepseek.com>
@zitann2020
zitann2020 force-pushed the i18n/ja-cjk-baseline branch from 54283f5 to 6938cf4 Compare October 25, 2026 19:13
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a0ea5f5 and 6938cf4.

Files selected for processing: 1
  • crates/ui-egui/src/theme.rs

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

Walkthrough

Native builds now calculate a baseline FontTweak for each registered fallback font relative to Inter. A new test checks Japanese glyph alignment across four font families and three sizes.

Changes: Fallback font baseline alignment

Layer / File(s) Summary
Calculate baseline adjustment
crates/ui-egui/src/theme.rs
Native helpers round font metrics at 12 px and derive a size-independent FontTweak from the Inter row font and each fallback face.
Apply and test fallback adjustment
crates/ui-egui/src/theme.rs
The installer retains the resolved Inter face and assigns a calculated FontTweak to each fallback. A test checks Japanese glyph-bottom drift across four font families and sizes of 12, 15, and 18 pt.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: feiliuem

Merge Risk: Minimal · up to 6938c

The fallback alignment change has no established merge-blocking issue; it is ready for normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: aligning the CJK fallback with the Latin baseline.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files.
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.
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.

@bflatastic
bflatastic merged commit f987de8 into storytold:main Oct 29, 2026
3 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thank you @zitann2020! It landed on main with a batch of community PRs, after a full workspace build and test run on Windows against the refactored main (fmt, strict clippy, about 4,100 tests, layers, assets and wasm).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants