From 1d17e45825b7abec654ecc8249bb28fa9ad11530 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Fri, 5 May 2017 16:42:40 +0200
Subject: [PATCH] fix Text.Bounds

---
 text/text.go | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/text/text.go b/text/text.go
index 229d335..d6662cd 100644
--- a/text/text.go
+++ b/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)
-	if glyphBounds.H() > 0 {
-		glyphBounds = glyphBounds.Resized(txt.Dot, pixel.V(
-			glyphBounds.W(),
-			txt.atlas.Ascent()+txt.atlas.Descent(),
-		))
-	}
-	if txt.bounds.W()*txt.bounds.H() == 0 {
-		txt.bounds = glyphBounds
-	} else {
-		txt.bounds = txt.bounds.Union(glyphBounds)
+	if glyphBounds.W()*glyphBounds.H() != 0 {
+		glyphBounds = pixel.R(
+			glyphBounds.Min.X(),
+			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
+		} else {
+			txt.bounds = txt.bounds.Union(glyphBounds)
+		}
 	}
 
 	a := pixel.V(glyph.Frame.Min.X(), glyph.Frame.Min.Y())
-- 
GitLab