Skip to content

fix oneline overflow (copy from pr#226)#229

Merged
andydotxyz merged 2 commits intogo-text:mainfrom
zodimo:main
Feb 12, 2026
Merged

fix oneline overflow (copy from pr#226)#229
andydotxyz merged 2 commits intogo-text:mainfrom
zodimo:main

Conversation

@zodimo
Copy link
Contributor

@zodimo zodimo commented Feb 12, 2026

I have discovered this bug when updating go-text/typesetting to v0.3.3 and the gioui/widget.Editor SingleLine=true stopped working and text was displayed vertical one character per line. I have traced it to widget/text.go line 246-254.

	maxWidth := gtx.Constraints.Max.X
	if e.SingleLine {
		maxWidth = math.MaxInt
	}
	minWidth := gtx.Constraints.Min.X
	if maxWidth != e.params.MaxWidth {
		e.params.MaxWidth = maxWidth
		e.invalidate()
	}

Which caused and overflow in text/gotext.go line 514.

	return s.wrapper.WrapParagraph(wc, params.MaxWidth, txt, shaping.NewSliceIterator(s.shapeText(params.PxPerEm, params.Locale, txt)))

which progressed to shaping/wrapping.go from github.com/go-text/typesetting v 0.3.3, where the overflow occurs. fixed.I(maxWidth) -> -64 when maxWidth is math.MaxInt

func (l *LineWrapper) WrapParagraph(config WrapConfig, maxWidth int, paragraph []rune, runs RunIterator) (_ []Line, truncated int) {
	return l.WrapParagraphF(config, fixed.I(maxWidth), paragraph, runs)
}

The error before the fix was applied.

--- FAIL: TestWrapping_oneLine_overflow_bug (0.00s)
    wrapping_test.go:3614: expected one line, got 2
    wrapping_test.go:3620: expected no line, got 2

I have created a safety check for the overflow and created a test to verify

@zodimo
Copy link
Contributor Author

zodimo commented Feb 12, 2026

The checks are still waiting. I dont know how to fix this.

@andydotxyz andydotxyz mentioned this pull request Feb 12, 2026
@andydotxyz andydotxyz merged commit 6113239 into go-text:main Feb 12, 2026
7 checks passed
benoitkugler added a commit that referenced this pull request Feb 23, 2026
@benoitkugler benoitkugler mentioned this pull request Feb 23, 2026
benoitkugler added a commit that referenced this pull request Feb 23, 2026
* [font] Reorder extents lookup order

* [shaping] extends fix in #229 to WrapNextLine
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.

2 participants