Skip to content

Fix #69: build against the scttfrdmn/canvas fork carrying canvas#397 - #112

Merged
scttfrdmn merged 1 commit into
mainfrom
chore/90-canvas-fork
Nov 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
chore/90-canvas-fork

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

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:

  • the same canvas commit inkcap already pinned (b3beae08c578), so there are no other upstream changes,
  • plus the #397 fix,
  • with the module path renamed (fork branch inkcap).

A rename rather than a replace directive, because go install …@version refuses any module whose go.mod has one, and the README advertises go install. All imports are rewritten, and go mod why confirms 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.

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.
@scttfrdmn
scttfrdmn merged commit 5979b6f into main Nov 16, 2026
1 check passed
@scttfrdmn
scttfrdmn deleted the chore/90-canvas-fork branch November 16, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Soft hyphens (U+00AD) garble justified lines

1 participant