From e76726d4f76b6c056698b53de0c25624458ec52f Mon Sep 17 00:00:00 2001 From: Werner Laurensse Date: Sun, 15 Dec 2019 15:12:58 +0100 Subject: [PATCH] text/shaper: Add Metrics method to Shaper struct. Signed-off-by: Werner Laurensse --- text/shaper.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/text/shaper.go b/text/shaper.go index abcd884f..c67c6481 100644 --- a/text/shaper.go +++ b/text/shaper.go @@ -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{