text/shaper: Add Metrics method to Shaper struct.

Signed-off-by: Werner Laurensse <werner@alman.ax>
This commit is contained in:
Werner Laurensse
2019-12-15 15:12:58 +01:00
committed by Elias Naur
parent 0bfcac9734
commit e76726d4f7
+10
View File
@@ -3,6 +3,7 @@
package text
import (
"golang.org/x/image/font"
"unicode/utf8"
"gioui.org/op"
@@ -51,6 +52,11 @@ func (s *Shaper) Shape(c unit.Converter, font Font, str String) op.CallOp {
return tf.shape(fixed.I(c.Px(font.Size)), str)
}
func (s *Shaper) Metrics(c unit.Converter, font Font) font.Metrics {
tf := s.faceForFont(font)
return tf.metrics(fixed.I(c.Px(font.Size)))
}
func (s *Shaper) faceForStyle(font Font) *face {
tf := s.faces[font]
if tf == nil {
@@ -115,6 +121,10 @@ func (t *face) shape(ppem fixed.Int26_6, str String) op.CallOp {
return clip
}
func (t *face) metrics(ppem fixed.Int26_6) font.Metrics {
return t.face.Metrics(ppem)
}
func fallbackLayout(str string) *Layout {
l := &Layout{
Lines: []Line{