text: add Metrics method to Face interface. font/opentype: implement Metrics method for Font struct.

Signed-off-by: Werner Laurensse <werner@alman.ax>
This commit is contained in:
Werner Laurensse
2019-11-23 06:53:34 +01:00
committed by Elias Naur
parent aca511f849
commit 4bcb4ec8b6
2 changed files with 7 additions and 0 deletions
+5
View File
@@ -46,6 +46,11 @@ func (f *Font) Shape(ppem fixed.Int26_6, str text.String) clip.Op {
return textPath(&f.buf, ppem, &opentype{Font: f.font, Hinting: font.HintingFull}, str)
}
func (f *Font) Metrics(ppem fixed.Int26_6) font.Metrics {
o := &opentype{Font: f.font, Hinting: font.HintingFull}
return o.Metrics(&f.buf, ppem)
}
func layoutText(buf *sfnt.Buffer, ppem fixed.Int26_6, str string, f *opentype, opts text.LayoutOptions) *text.Layout {
m := f.Metrics(buf, ppem)
lineTmpl := text.Line{
+2
View File
@@ -5,6 +5,7 @@ package text
import (
"gioui.org/op/clip"
"gioui.org/unit"
"golang.org/x/image/font"
"golang.org/x/image/math/fixed"
)
@@ -60,6 +61,7 @@ type Font struct {
type Face interface {
Layout(ppem fixed.Int26_6, str string, opts LayoutOptions) *Layout
Shape(ppem fixed.Int26_6, str String) clip.Op
Metrics(ppem fixed.Int26_6) font.Metrics
}
// Typeface identifies a particular typeface design. The empty