mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
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
|
||||
|
||||
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{
|
||||
|
||||
Reference in New Issue
Block a user