bugfix for text getting cut off
This commit is contained in:
parent
6b4af8f29f
commit
78a6d8f020
1 changed files with 4 additions and 3 deletions
7
text.go
7
text.go
|
@ -80,7 +80,7 @@ func (cv *Canvas) FillText(str string, x, y float64) {
|
||||||
curInside := false
|
curInside := false
|
||||||
|
|
||||||
var textOffset image.Point
|
var textOffset image.Point
|
||||||
var strWidth, strHeight int
|
var strWidth, strMaxY int
|
||||||
for i, rn := range str {
|
for i, rn := range str {
|
||||||
idx := fnt.Index(rn)
|
idx := fnt.Index(rn)
|
||||||
if idx == 0 {
|
if idx == 0 {
|
||||||
|
@ -114,12 +114,13 @@ func (cv *Canvas) FillText(str string, x, y float64) {
|
||||||
if bounds.Min.Y < textOffset.Y {
|
if bounds.Min.Y < textOffset.Y {
|
||||||
textOffset.Y = bounds.Min.Y
|
textOffset.Y = bounds.Min.Y
|
||||||
}
|
}
|
||||||
if h := bounds.Dy(); h > strHeight {
|
if bounds.Max.Y > strMaxY {
|
||||||
strHeight = h
|
strMaxY = bounds.Max.Y
|
||||||
}
|
}
|
||||||
p.X += advance
|
p.X += advance
|
||||||
}
|
}
|
||||||
strWidth = p.X.Ceil() - textOffset.X
|
strWidth = p.X.Ceil() - textOffset.X
|
||||||
|
strHeight := strMaxY - textOffset.Y
|
||||||
|
|
||||||
if strFrom == strTo || strWidth == 0 || strHeight == 0 {
|
if strFrom == strTo || strWidth == 0 || strHeight == 0 {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue