mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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:
committed by
Elias Naur
parent
aca511f849
commit
4bcb4ec8b6
@@ -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{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user