Repository navigation
fix(apple): match framesetter heights for fonts with leading - #340
Merged
Merged
Conversation
This was referenced Nov 16, 2026
This was referenced Nov 16, 2026
houko
force-pushed
the
fix/apple-fallback-line-metrics
branch
from
November 17, 2026 03:54
1f2850c to
dfa29b0
Compare
CTLineGetTypographicBounds counts a font's whole typographic leading in a line's height, where a framesetter leaves it out of a frame's last line: an ASCII text in Hiragino Sans GB at 12 points measured 19 points on the one-line shortcut and 13 through the framesetter, and Heiti, Thonburi and Devanagari Sangam MN were a point too tall. A line with nonzero leading now stays on the framesetter for measuring and drawing; lines without leading keep the shortcut. The regression compares sizes, pixels, lines and carets for those four fonts, ASCII and other scripts, with and without a line limit.
houko
force-pushed
the
fix/apple-fallback-line-metrics
branch
from
November 17, 2026 04:02
dfa29b0 to
1f5f15d
Compare
Collaborator
Author
|
Reviewed. Rebased onto current main (now 1f5f15d, a clean rebase: the commits main gained touch only
|
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.
Apple's single-line shortcut measured a line with
CTLineGetTypographicBounds, which counts a font's whole typographic leading in the height. A framesetter leaves that leading out of a frame's last line. Native CI first saw this as Menlo's Japanese fallback measuring 24 points against the framesetter's 18. Main has since moved every non-ASCII text off the shortcut (isASCIILine). ASCII texts in fonts that have leading still differ: at 12 points, "abc" in Hiragino Sans GB measures 19 points as a line and 13 in a frame, and Heiti SC, Thonburi and Devanagari Sangam MN each measure a point taller.A text whose shaped line has nonzero typographic leading now uses the framesetter for both measuring and drawing. Lines without leading, such as the system font's, keep the shortcut and its rounding to whole points (
framedHeight).docs/architecture/text.mdnow says that only ASCII texts take the shortcut and that texts in fonts with leading do not. The shared backend change applies to macOS and Apple's mobile targets.The regression
TestOneLineWithLeadingMatchesTheFramesettercompares measured sizes, rendered pixels, line information and carets between the shortcut and the framesetter. It covers four fonts, ASCII text and three other scripts, each with and without a line limit.Validation:
go tool nsgo test ./internal/platform/appleon macOS arm64: 78 passed, 0 failed, 2 skipped.go tool nsgo check -target allpassed.go build ./...passed for the host, windows, linux, android/arm64 and js/wasm.go vetpassed for darwin and ios oninternal/platform/apple.go tool nsgo test -run 'Layer|Skills|Doc' .: 35 passed.