Release 0.1.3: English multi-line text in stories - #5
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
ui/fonts.jsonsource: "open") uses the open face's own line height, ascent and descent.LocalizeManager.ApplyLanguageLineSpacing) is set for the game's fonts.-100removes one em. That takes out the 1 em line gap of the game's primary font, whose line height is 2 em.-100left 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:ui.jsontextStyle.roles.ui/languages.jsonroles, or from thefontRoleof the text nodes that use the asset.textStyleroles, are laid out as before.Talk text at 36 px, story 10045, open fonts:
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 ofStoryFontAssetsnpm run typechecknode scripts/build.mjs --checktests/data/story-ui-layout.test.mjson 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.🤖 Generated with Claude Code