~eliasnaur/gio

913a780d64618ff12fb0e1da1857ff10d40defcb — Elias Naur 3 years ago db03b08
text: remove Metrics from Face interface

It's not used in text shaping, so let's not require it.

Note that the concrete opentype package still retains the Metrics
implementation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2 files changed, 0 insertions(+), 16 deletions(-)

M text/shaper.go
M text/text.go
M text/shaper.go => text/shaper.go +0 -14
@@ 6,8 6,6 @@ import (
	"io"
	"strings"

	"golang.org/x/image/font"

	"gioui.org/op"
	"golang.org/x/image/math/fixed"
)


@@ 23,9 21,6 @@ type Shaper interface {
	LayoutString(font Font, size fixed.Int26_6, maxWidth int, str string) []Line
	// ShapeString is like Shape for lines previously laid out by LayoutString.
	ShapeString(font Font, size fixed.Int26_6, str string, layout []Glyph) op.CallOp

	// Metrics returns the font metrics for font.
	Metrics(font Font, size fixed.Int26_6) font.Metrics
}

// A FontFace is a Font and a matching Face.


@@ 120,11 115,6 @@ func (s *Cache) ShapeString(font Font, size fixed.Int26_6, str string, layout []
	return cache.shape(size, str, layout)
}

func (s *Cache) Metrics(font Font, size fixed.Int26_6) font.Metrics {
	cache := s.lookup(font)
	return cache.metrics(size)
}

func (f *faceCache) layout(ppem fixed.Int26_6, maxWidth int, str string) []Line {
	if f == nil {
		return nil


@@ 157,7 147,3 @@ func (f *faceCache) shape(ppem fixed.Int26_6, str string, layout []Glyph) op.Cal
	f.pathCache.Put(pk, clip)
	return clip
}

func (f *faceCache) metrics(ppem fixed.Int26_6) font.Metrics {
	return f.face.Metrics(ppem)
}

M text/text.go => text/text.go +0 -2
@@ 6,7 6,6 @@ import (
	"io"

	"gioui.org/op"
	"golang.org/x/image/font"
	"golang.org/x/image/math/fixed"
)



@@ 50,7 49,6 @@ type Font struct {
type Face interface {
	Layout(ppem fixed.Int26_6, maxWidth int, txt io.Reader) ([]Line, error)
	Shape(ppem fixed.Int26_6, str []Glyph) op.CallOp
	Metrics(ppem fixed.Int26_6) font.Metrics
}

// Typeface identifies a particular typeface design. The empty