forked from joejulian/gio
text/shaper: Add Metrics method to Shaper struct.
Signed-off-by: Werner Laurensse <werner@alman.ax>
This commit is contained in:
committed by
Elias Naur
parent
0bfcac9734
commit
e76726d4f7
@@ -3,6 +3,7 @@
|
|||||||
package text
|
package text
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"golang.org/x/image/font"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"gioui.org/op"
|
"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)
|
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 {
|
func (s *Shaper) faceForStyle(font Font) *face {
|
||||||
tf := s.faces[font]
|
tf := s.faces[font]
|
||||||
if tf == nil {
|
if tf == nil {
|
||||||
@@ -115,6 +121,10 @@ func (t *face) shape(ppem fixed.Int26_6, str String) op.CallOp {
|
|||||||
return clip
|
return clip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *face) metrics(ppem fixed.Int26_6) font.Metrics {
|
||||||
|
return t.face.Metrics(ppem)
|
||||||
|
}
|
||||||
|
|
||||||
func fallbackLayout(str string) *Layout {
|
func fallbackLayout(str string) *Layout {
|
||||||
l := &Layout{
|
l := &Layout{
|
||||||
Lines: []Line{
|
Lines: []Line{
|
||||||
|
|||||||
Reference in New Issue
Block a user