fix Text.Bounds
This commit is contained in:
parent
b91d8be6cd
commit
1d17e45825
22
text/text.go
22
text/text.go
|
@ -199,16 +199,18 @@ func (txt *Text) WriteRune(r rune) (n int, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glyphBounds := glyph.Frame.Moved(txt.Dot - glyph.Orig)
|
glyphBounds := glyph.Frame.Moved(txt.Dot - glyph.Orig)
|
||||||
if glyphBounds.H() > 0 {
|
if glyphBounds.W()*glyphBounds.H() != 0 {
|
||||||
glyphBounds = glyphBounds.Resized(txt.Dot, pixel.V(
|
glyphBounds = pixel.R(
|
||||||
glyphBounds.W(),
|
glyphBounds.Min.X(),
|
||||||
txt.atlas.Ascent()+txt.atlas.Descent(),
|
txt.Dot.Y()-txt.Atlas().Descent(),
|
||||||
))
|
glyphBounds.Max.X(),
|
||||||
}
|
txt.Dot.Y()+txt.Atlas().Ascent(),
|
||||||
if txt.bounds.W()*txt.bounds.H() == 0 {
|
)
|
||||||
txt.bounds = glyphBounds
|
if txt.bounds.W()*txt.bounds.H() == 0 {
|
||||||
} else {
|
txt.bounds = glyphBounds
|
||||||
txt.bounds = txt.bounds.Union(glyphBounds)
|
} else {
|
||||||
|
txt.bounds = txt.bounds.Union(glyphBounds)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a := pixel.V(glyph.Frame.Min.X(), glyph.Frame.Min.Y())
|
a := pixel.V(glyph.Frame.Min.X(), glyph.Frame.Min.Y())
|
||||||
|
|
Loading…
Reference in New Issue