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{