From c47d77b2b5252cdcfe52a23a034d19976eb05616 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Fri, 5 May 2017 16:02:47 +0200
Subject: [PATCH] add Text.Bounds, Atlas.Ascent, Atlas.Descent

---
 text/atlas.go | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/text/atlas.go b/text/atlas.go
index 5dbb665..0461e2d 100644
--- a/text/atlas.go
+++ b/text/atlas.go
@@ -20,6 +20,8 @@ type Atlas struct {
 	pic        pixel.Picture
 	mapping    map[rune]Glyph
 	kern       map[struct{ r0, r1 rune }]float64
+	ascent     float64
+	descent    float64
 	lineHeight float64
 }
 
@@ -95,10 +97,12 @@ func NewAtlas(face font.Face, runes []rune) *Atlas {
 	}
 
 	return &Atlas{
-		pixel.PictureDataFromImage(atlasImg),
-		mapping,
-		kern,
-		float64(face.Metrics().Height) / (1 << 6),
+		pic:        pixel.PictureDataFromImage(atlasImg),
+		mapping:    mapping,
+		kern:       kern,
+		ascent:     float64(face.Metrics().Ascent) / (1 << 6),
+		descent:    float64(face.Metrics().Descent) / (1 << 6),
+		lineHeight: float64(face.Metrics().Height) / (1 << 6),
 	}
 }
 
@@ -119,6 +123,14 @@ func (a *Atlas) Kern(r0, r1 rune) float64 {
 	return a.kern[struct{ r0, r1 rune }{r0, r1}]
 }
 
+func (a *Atlas) Ascent() float64 {
+	return a.ascent
+}
+
+func (a *Atlas) Descent() float64 {
+	return a.descent
+}
+
 func (a *Atlas) LineHeight() float64 {
 	return a.lineHeight
 }
-- 
GitLab