Skip to content

Commit

Permalink
Expand bounds based on control runes
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Sep 11, 2024
1 parent 64b3d7e commit b79fe6d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ext/text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ func (txt *Text) controlRune(r rune, dot pixel.Vec) (newDot pixel.Vec, control b
case '\n':
dot.X = txt.Orig.X
dot.Y -= txt.LineHeight
if txt.bounds.Empty() {
txt.bounds.Min = dot
txt.bounds.Max = txt.Orig.Add(pixel.V(0.01, txt.atlas.lineHeight))
} else {
txt.bounds.Min.Y -= txt.LineHeight
}
case '\r':
dot.X = txt.Orig.X
case '\t':
Expand All @@ -343,6 +349,12 @@ func (txt *Text) controlRune(r rune, dot pixel.Vec) (newDot pixel.Vec, control b
rem = txt.TabWidth
}
dot.X += rem
if txt.bounds.Empty() {
txt.bounds.Min = txt.Dot
txt.bounds.Max = pixel.V(dot.X, txt.Orig.Y+txt.atlas.lineHeight)
} else if dot.X > txt.bounds.Max.X {
txt.bounds.Max.X = dot.X
}
default:
return dot, false
}
Expand Down

0 comments on commit b79fe6d

Please sign in to comment.