Skip to content

Commit

Permalink
text: extend Handler interface to expose underlying font cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sbinet committed Feb 12, 2021
1 parent b77680a commit dfecc4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions text/latex.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ type Latex struct {

var _ Handler = (*Latex)(nil)

// Cache returns the cache of fonts used by the text handler.
func (hdlr Latex) Cache() *font.Cache {
return hdlr.Fonts
}

// Extents returns the Extents of a font.
func (hdlr Latex) Extents(fnt font.Font) font.Extents {
face := hdlr.Fonts.Lookup(fnt, fnt.Size)
Expand Down
5 changes: 5 additions & 0 deletions text/plain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ type Plain struct {

var _ Handler = (*Plain)(nil)

// Cache returns the cache of fonts used by the text handler.
func (hdlr Plain) Cache() *font.Cache {
return hdlr.Fonts
}

// Extents returns the Extents of a font.
func (hdlr Plain) Extents(fnt font.Font) font.Extents {
face := hdlr.Fonts.Lookup(fnt, fnt.Size)
Expand Down
3 changes: 3 additions & 0 deletions text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (

// Handler parses, formats and renders text.
type Handler interface {
// Cache returns the cache of fonts used by the text handler.
Cache() *font.Cache

// Extents returns the Extents of a font.
Extents(fnt font.Font) font.Extents

Expand Down

0 comments on commit dfecc4a

Please sign in to comment.