Skip to content

Commit

Permalink
Expand bounds for space characters if font does not properly compute …
Browse files Browse the repository at this point in the history
…bounds
  • Loading branch information
bhperry committed Sep 11, 2024
1 parent b79fe6d commit e39b841
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ext/text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,20 @@ func (txt *Text) drawBuf() {
continue
}

var dot pixel.Vec
var rect, frame, bounds pixel.Rect
rect, frame, bounds, txt.Dot = txt.Atlas().DrawRune(txt.prevR, r, txt.Dot)
rect, frame, bounds, dot = txt.Atlas().DrawRune(txt.prevR, r, txt.Dot)
if r == ' ' {
// Space character has empty bounds for some fonts
if bounds.W() == 0 {
bounds.Max = bounds.Max.Add(dot.Sub(txt.Dot))
}
if bounds.H() == 0 {
bounds.Min = txt.Dot
bounds.Max.Y += txt.atlas.lineHeight
}
}
txt.Dot = dot

txt.prevR = r

Expand Down

0 comments on commit e39b841

Please sign in to comment.