Skip to content

Release 0.1.3: English multi-line text in stories - #5

Merged
nichinichisou0609 merged 3 commits into
mainfrom
dev
Sep 28, 2026
Merged

nichinichisou0609 merged 3 commits into
mainfrom
dev

Conversation

@nichinichisou0609

@nichinichisou0609 nichinichisou0609 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Multi-line English text in the story player was drawn with the second line over the first (reported by a user).

The cause is a mismatch between the font data and the line spacing:

  • Font data made from open fonts (ui/fonts.json source: "open") uses the open face's own line height, ascent and descent.
  • The per-language line spacing (LocalizeManager.ApplyLanguageLineSpacing) is set for the game's fonts.
  • English's -100 removes one em. That takes out the 1 em line gap of the game's primary font, whose line height is 2 em.
  • Noto Sans CJK has a line height of 1.448 em and no gap, so the same -100 left the lines only 0.448 em apart.

The fix, in the new StoryFontAssets (src/story/ui-fonts.js), shared by the story UI and the simple talk window:

  • An open font asset standing in for a font role now uses the game's line height, ascent and descent for that role, from ui.json textStyle.roles.
  • The role comes from ui/languages.json roles, or from the fontRole of the text nodes that use the asset.
  • Game fonts, and data without textStyle roles, are laid out as before.
  • No data needs to be regenerated.

Talk text at 36 px, story 10045, open fonts:

language line pitch before after first baseline before after
en 16.13 (overlap) 36 (1 em) 41.76 31.68
ja 52.13 72 (2 em) 41.76 31.68
zh-Hans 53.93 43.38 41.76 32.11
ko 44.74 44.74 (unchanged: the open font is the game's) 34.26 34.26

The zh-Hans values after the fix, 43.38 and 32.11, equal the reference values the real-data layout test already checks for the game's FZLTH font.

Test plan

  • npm test: 536 pass, including a new synthetic test of StoryFontAssets
  • npm run typecheck
  • node scripts/build.mjs --check
  • Opt-in tests/data/story-ui-layout.test.mjs on story 10045 in en, ja, zh-Hans and ko: all checks pass (166–167 each).

Also fixes that opt-in test (test(story) commit). Its typewriter checks always failed on long lines, because the fixed 90-frame scenario ended before the longest line was typed out. They now run on a talk of their own until the line ends, cancelling the first typing the way the game's Talk does.

  • Not checked in a browser. Look at a two-line English talk, and at Japanese, where the lines are now spaced as in the game (wider than before).

🤖 Generated with Claude Code

nichinichisou0609 and others added 3 commits September 28, 2026 08:50
Font data made from open fonts kept the open face's line height, ascent
and descent, while the language line spacing is set for the game's fonts.
English's -100 takes the 1 em line gap of the game's primary font (line
height 2 em) out; on Noto Sans CJK (1.448 em, no gap) it left 0.448 em
between lines, so a second line of English text was drawn over the first.

An open font asset of a font role now takes the line height, ascent and
descent of the game's font of that role (ui.json textStyle.roles), found
through ui/languages.json roles and the text nodes' fontRole, in both the
story UI and the simple talk window. At 36 px the talk text's pitch is
36 px in English (was 16.1), 72 in Japanese (52.1) and 43.38 in Chinese
(53.9, the game's value), with the first baseline at the game's ascent.
Game fonts and data without textStyle roles are laid out as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The opt-in layout test typed the episode's longest line within its fixed
90-frame scenario, which ends before a long line does (143 English
characters take 91 frames, and Japanese characters 3 frames each), so the
typing end and isTyping checks always failed. The typewriter and next
indicator checks now run on a talk of their own after the rest: the first
typing is cancelled as the game's Talk does (typingCts.Cancel), and the new
line is stepped until it ends. Story 10045 passes in en, ja, zh-Hans and ko.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nichinichisou0609 nichinichisou0609 changed the title fix(story): lay open fonts out with the game's line metrics Release 0.1.3: English multi-line text in stories Sep 28, 2026
@nichinichisou0609
nichinichisou0609 merged commit f462765 into main Sep 28, 2026
3 checks passed
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.

1 participant