Repository navigation
Fix #69: build against the scttfrdmn/canvas fork carrying canvas#397 - #112
Merged
Merged
Conversation
canvas's ToText doesn't advance past the glyph of an unused soft hyphen or zero-width space, so the text after each one shifts by a glyph, which garbled soft-hyphenated paragraphs (#69) and blocks U+200B break points for long tokens (#60). The fix is proposed upstream as tdewolff/canvas#397. Until it merges, inkcap imports github.com/scttfrdmn/canvas: the commit inkcap already pinned (b3beae08c578), plus that fix, with the module path renamed (branch 'inkcap' of the fork). A rename rather than a replace directive, because 'go install …@Version' refuses modules whose go.mod has replace directives. TestSoftHyphens checks that unused soft hyphens leave the text intact and that wrapped text keeps every character. Run against the fork with the fix reverted (via a local replace), it fails. The README notes the fork. Refs #90.
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.
Fixes #69. Refs #60 (unblocked by this) and #90.
The fix: canvas mis-assembles span text after an unused soft hyphen or zero-width space, shifting the rest of the line by one glyph. It's proposed upstream in tdewolff/canvas#397, with a regression test that fails on canvas master.
How inkcap carries it: inkcap now imports
github.com/scttfrdmn/canvas, which is:b3beae08c578), so there are no other upstream changes,inkcap).A rename rather than a
replacedirective, becausego install …@versionrefuses any module whose go.mod has one, and the README advertisesgo install. All imports are rewritten, andgo mod whyconfirms tdewolff/canvas is no longer needed. Once #397 merges, inkcap switches back to upstream (tracked in #90).Test:
TestSoftHyphens: unused soft hyphens leave the text identical, and a narrow wrap keeps every character in order. Run against the fork with the fix reverted (through a temporary local replace), both assertions fail; with the fork they pass. A real render of soft-hyphenated text now extracts cleanly. The README has a short fork note.