Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
text: remove Metrics from Face interface
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
eliasnaur committed Jun 26, 2020
1 parent db03b08 commit 913a780
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
14 changes: 0 additions & 14 deletions text/shaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"io"
"strings"

"golang.org/x/image/font"

"gioui.org/op"
"golang.org/x/image/math/fixed"
)
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
2 changes: 0 additions & 2 deletions text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"

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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 913a780

Please sign in to comment.