Repository navigation
Text: keep the top of a stroked label's outline under the "hanging" baseline on macOS - #1898
Merged
Merged
Conversation
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.
Description
A stroked, multi-line
Textlabel withtextBaseline: "hanging"can lose the top of its outline on macOS, wheresans-serifresolves to Helvetica: the ink padding around the baked canvas comes out exactly as tall as the ink, so the outline is sheared at row 0 of the canvas texture (#1870).The padding in
TextMetrics#measureTextisceil(ascent + strokeReach) + INK_SLACK. The rasterizer paints the ink about a pixel past whatactualBoundingBoxAscentreports, whichINK_SLACK = 1was meant to absorb — but whenascent + strokelands close enough to a whole number,ceil()adds no headroom on top of that, and the slack is then exactly the spill. Measured in Chromium on macOS with Helvetica at 20px,"XX"under"hanging"reports an ascent of -0.05px, soceil(-0.05 + 3) + 1 = 4and the painted ink reaches exactly 4px above the alignment point — ink on the first row. Every other baseline passes because its fractional ascent leaves headroom in theceil().This raises
INK_SLACKto 2, so the worst whole-number alignment is absorbed too, and documents the measurement in the comment. The failing engine test now passes on macOS, where it failed before.Type of change
Checklist
pnpm lintpasses)pnpm testpasses)pnpm build)Related issues
Fixes #1870