You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Long URLs, identifiers and inline code overflow the page and table cells #60
A long URL or a long inline-code identifier (`pkg.(*T).method`) runs past the right margin, and in a wide table neighbouring cells overlap. The Knuth-Plass breaker has no break opportunity inside a long token.
Fix direction: in emit/buildText, insert zero-width break opportunities after / . _ - ? & = in link text and code spans, and fall back to a forced character break when a single token is still wider than the measure. In table.go, cellWidths/solve should cap a column's minimum width so other columns aren't starved. Test: no glyph's x-extent exceeds the right margin or its cell, for a long URL in body text and in a table.
Root cause found; it's in canvas, and it's shared by #60 and #69.
canvas already treats U+200B (zero-width space) and U+00AD (soft hyphen) as optional breaks (text/linebreak.go, GlyphsToItems). In RichText.ToText (text.go), the branch for a potential but unused break doesn't advance the glyph index past that character. Every unused U+200B or U+00AD on a line therefore shifts the rest of the line's text by one glyph. That's the garbling in #69, and it's why breaking long tokens at inserted U+200B (#60) currently renders as "Fallba / kAndVeryLongNam e".
Verified fix (applied to a scratch copy via a temporary replace; the repo is unchanged):
ifi+1<end {
// potential but unused hyphen: the soft hyphen or// zero-width space glyph stays in the span, invisibleift:=glyphs[bg].Text; t==""||t=="" {
glyphs[bg].XAdvance=0ifid:=glyphs[bg].SFNT.GlyphIndex(' '); id!=0 {
glyphs[bg].ID=id
}
}
bg+=items[i].Size
} elseif...
With the fix, inline code and URLs wrap at the inserted U+200B, soft-hyphenated paragraphs render cleanly, and pdftotext extracts the text intact. IBM Plex has no U+200B glyph, which is why the glyph is drawn as a zero-advance space.
Next: this needs a canvas change, either an upstream PR to tdewolff/canvas or a fork with a replace directive in the meantime. Note that go install …@version ignores replace directives, so a fork alone would leave go install builds unfixed. Waiting on the user's decision.
Upstream fix opened: tdewolff/canvas#397 ("Fix text shifting after an unused soft hyphen or zero-width space"), from the scttfrdmn/canvas fork, branch fix-unused-optional-break. It includes the regression test TestRichTextUnusedOptionalBreaks, which fails on canvas master and passes with the fix. How inkcap picks up the fix before upstream merges is still being decided (a replace directive or a module-renamed fork).
Activity
scttfrdmn commentedon Nov 16, 2026
Root cause found; it's in canvas, and it's shared by #60 and #69.
canvas already treats U+200B (zero-width space) and U+00AD (soft hyphen) as optional breaks (
text/linebreak.go,GlyphsToItems). InRichText.ToText(text.go), the branch for a potential but unused break doesn't advance the glyph index past that character. Every unused U+200B or U+00AD on a line therefore shifts the rest of the line's text by one glyph. That's the garbling in #69, and it's why breaking long tokens at inserted U+200B (#60) currently renders as "Fallba / kAndVeryLongNam e".Verified fix (applied to a scratch copy via a temporary
replace; the repo is unchanged):With the fix, inline code and URLs wrap at the inserted U+200B, soft-hyphenated paragraphs render cleanly, and
pdftotextextracts the text intact. IBM Plex has no U+200B glyph, which is why the glyph is drawn as a zero-advance space.Next: this needs a canvas change, either an upstream PR to tdewolff/canvas or a fork with a
replacedirective in the meantime. Note thatgo install …@versionignoresreplacedirectives, so a fork alone would leavego installbuilds unfixed. Waiting on the user's decision.scttfrdmn commentedon Nov 16, 2026
Upstream fix opened: tdewolff/canvas#397 ("Fix text shifting after an unused soft hyphen or zero-width space"), from the scttfrdmn/canvas fork, branch
fix-unused-optional-break. It includes the regression testTestRichTextUnusedOptionalBreaks, which fails on canvas master and passes with the fix. How inkcap picks up the fix before upstream merges is still being decided (a replace directive or a module-renamed fork).Fix #69: build against the scttfrdmn/canvas fork carrying canvas#397 (#…