fix(font): skip the glyphs the shaper marks invisible - #170
Merged
Conversation
Measure and Draw disagreed about default-ignorable characters. Measure summed every shaped advance; Draw skipped only .notdef. A word joiner therefore reserved a full advance of empty space in the middle of a word, and a soft hyphen — which Go Regular maps to a real hyphen glyph — drew a visible dash mid-word. go-opentype/shape v0.4.0 now zeroes and flags those leftovers (Glyph.Invisible), which fixes the width. This honours the flag when painting: without it a mapped ignorable would still stamp its glyph, now at zero advance, straight on top of the following letter — strictly worse than before. invisible(g) names the rule (.notdef or shaper-hidden) so Draw and any future back-end apply the same one. 100% coverage held; race-clean. Asserted on pixels: six ignorables inside a word leave the measured width and every byte of the surface identical. Co-Authored-By: Claude Opus 4.8 <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.
The bug
MeasureandDrawdisagreed about default-ignorable characters.Measuresummed every shaped advance;Drawskipped only.notdef.A word joiner therefore reserved a full advance of empty space in the middle of a word, and a soft hyphen — which Go Regular maps to a real hyphen glyph — drew a visible dash mid-word.
The fix
go-opentype/shape v0.4.0 now zeroes and flags those leftovers (
Glyph.Invisible), which fixes the width. This PR honours the flag when painting.That second half matters: without it a mapped ignorable would still stamp its glyph, now at zero advance, straight on top of the following letter — strictly worse than before the shape fix.
invisible(g)names the rule (.notdefor shaper-hidden) soDrawand any future back-end apply the same one.Verification
go test -race→ 100.0% of statements, race-clean.U+00AD,U+2060,U+200B,U+200D,U+FEFF,U+FE0F) placed inside a word leave the measured width and every byte of the surface identical.🤖 Generated with Claude Code