Skip to content

Japanese text names the system's own fonts before Noto Sans JP - #609

Merged
MerciHanrim merged 1 commit into
mainfrom
ja-font-system-first
Nov 22, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
ja-font-system-first

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #607.

What was wrong

On a Windows machine that has Noto Sans JP installed in one weight only (NotoSansJP-Bold.otf), every Japanese glyph in the interface was drawn in that Bold face: the menu bar at 400, the canvas node names at 500 and the headings at 700 alike. The :lang(ja) stack named 'Noto Sans JP' right after IBM Plex Sans, which has no Japanese glyphs, so the browser took the installed Bold face for every weight.

Measured with CDP CSS.getPlatformFontsForNode (the face the engine really used, not the declared stack), desktop 1280×800, the seawater desalination Template:

Place Weight Before (main 300fe41) After (this branch)
Menu bar 400 NotoSansJP-Bold YuGothicUI-Regular
Canvas node name 500 NotoSansJP-Bold YuGothicUI-Semibold
Model list 400 NotoSansJP-Bold YuGothicUI-Regular
Inspector name 700 NotoSansJP-Bold YuGothicUI-Bold

Korean (Malgun Gothic) and English (IBM Plex Sans) measured the same before and after.

The change

Only the Japanese list in src/index.css changes. The platform's own Japanese UI fonts now come before 'Noto Sans JP':

'IBM Plex Sans', 'Hiragino Sans', 'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Noto Sans JP', sans-serif

Hiragino Sans (macOS) and Yu Gothic UI, Yu Gothic and Meiryo (Windows) ship every weight the UI uses. Noto Sans JP stays as the fallback where none of them exists.

Out of scope, as agreed:

  • the two Chinese lists;
  • the canvas name's weight of 500, which now draws in Yu Gothic UI Semibold.

Tests

Which font a browser takes depends on what the machine has installed, so there is no browser test. src/i18n/fontStacks.test.ts is a static check of the order in the stylesheet:

  • the Japanese stack starts with IBM Plex Sans and ends with sans-serif;
  • Hiragino Sans, Yu Gothic UI, Yu Gothic and Meiryo each come before Noto Sans JP, which stays in the stack;
  • the Japanese stack names no Korean or Chinese family;
  • the base stack and the two Chinese stacks equal their current lists.

On main's stylesheet the order test fails ("Hiragino Sans before Noto Sans JP: expected 2 to be less than 1"). On this branch all 5 pass.

Local runs:

  • every check:* script: 0 failed;
  • tsc -b: clean;
  • lint: 88 warnings, the baseline;
  • unit: 5705 passed;
  • related Japanese e2e on chromium, one worker, no retries: 179 passed (cjk-punctuation-font, toolbar-locale-width, run-bar-fit, descriptive-copy-wrapping, node-long-label, i18n-acceptance, template-label-overlay, data-import-guide);
  • the mobile all-languages sheet test (mobile.spec.ts:1723, 390 and 320 px), one worker, no retries: 1 passed.

Snapshots were compared in these runs, but none of them holds a Japanese image.

Part of #607. A machine with Noto Sans JP installed in its Bold weight only drew every Japanese glyph bold, because the Japanese stack named it first. Hiragino Sans, Yu Gothic UI, Yu Gothic and Meiryo now come first; a static check pins the order and leaves the base and Chinese stacks as they are.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 22, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7123867
Status: ✅  Deploy successful!
Preview URL: https://7a66dddc.cozy-loop-studio.pages.dev
Branch Preview URL: https://ja-font-system-first.cozy-loop-studio.pages.dev

View logs

@MerciHanrim

Copy link
Copy Markdown
Owner Author

CI record for head 71238672, before the merge (Lumi approved this head):

  • Run 44996445819, attempt 1: e2e (shard 1/8) failed, 355 passed and 1 failed. e2e/error-paths-423.spec.ts:30 (Reset all data, partial) failed on its first try and on its test retry, both with Expected: < 4, Received: 4. Every other job passed with no retries: checks, production bundle, PWA and shards 2 to 8.
  • Attempt 2, the failed job rerun on the same head: e2e (shard 1/8) passed, 356 passed, no retries. error-paths-423.spec.ts:30 passed on its first try. The e2e gate passed; all 13 checks are green.
  • The failure is unrelated to this change. It is a race in the test: the autosave's first write of loop-studio:graph:v1 can land after the test counts the keys, so one key goes and one arrives. It was reproduced locally with the CPU throttled ×3, in 4 of 5 runs. It failed the same way once before, on From amounts of about 10^9, a Gate hands a Converter more than a run takes, and the rest is gone #576's CI. The product behaved correctly in every run. A fix to the test needs its own scope.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant