@@ -3,6 +3,7 @@ package shaping
33import (
44 "bytes"
55 "fmt"
6+ "math"
67 "os"
78 "reflect"
89 "sort"
@@ -3587,3 +3588,35 @@ func TestMaxWidthRouding(t *testing.T) {
35873588 line , _ = wr .WrapNextLineF (run .Advance )
35883589 tu .Assert (t , line .NextLine == 13 )
35893590}
3591+
3592+ func TestWrapping_oneLine_overflow_bug (t * testing.T ) {
3593+
3594+ maxWidth := math .MaxInt
3595+
3596+ textInput := []rune ("Lorem ipsum" ) // a simple input that fits on one line
3597+ face := benchEnFace
3598+ var shaper HarfbuzzShaper
3599+ out := []Output {shaper .Shape (Input {
3600+ Text : textInput ,
3601+ RunStart : 0 ,
3602+ RunEnd : len (textInput ),
3603+ Direction : di .DirectionLTR ,
3604+ Face : face ,
3605+ Size : fixed .I (16 ),
3606+ Script : language .Latin ,
3607+ Language : language .NewLanguage ("EN" ),
3608+ })}
3609+ iter := NewSliceIterator (out )
3610+ var l LineWrapper
3611+
3612+ outs , _ := l .WrapParagraph (WrapConfig {BreakPolicy : Never }, maxWidth , textInput , iter )
3613+ if len (outs ) != 1 {
3614+ t .Errorf ("expected one line, got %d" , len (outs ))
3615+ }
3616+
3617+ // the run in iter should have been consumed
3618+ outs , _ = l .WrapParagraph (WrapConfig {BreakPolicy : Never }, maxWidth , textInput , iter )
3619+ if len (outs ) != 0 {
3620+ t .Errorf ("expected no line, got %d" , len (outs ))
3621+ }
3622+ }
0 commit comments