From ad16b6fee2bb7f011160c6098e016cc7ccb67250 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Wed, 4 Apr 2018 17:27:04 +0200 Subject: [PATCH] removed the name parameter from LoadFont --- canvas.go | 12 ++++++------ text.go | 5 +---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/canvas.go b/canvas.go index 68ba849..ffa2a8e 100644 --- a/canvas.go +++ b/canvas.go @@ -442,11 +442,9 @@ func (cv *Canvas) SetLineWidth(width float64) { cv.state.lineWidth = width } -// SetFont sets the font and font size. The font parameter can be: -// - a font loaded with the LoadFont function -// - a string matching the name parameter on LoadFont -// - a filename for a font to load which will be cached -// - nil, in which case the first loaded font will be used +// SetFont sets the font and font size. The font parameter can be a font loaded +// with the LoadFont function, a filename for a font to load (which will be +// cached), or nil, in which case the first loaded font will be used func (cv *Canvas) SetFont(font interface{}, size float64) { if font == nil { cv.state.font = defaultFont @@ -460,9 +458,11 @@ func (cv *Canvas) SetFont(font interface{}, size float64) { if f, ok := fonts[v]; ok { cv.state.font = f } else { - f, err := LoadFont(v, v) + f, err := LoadFont(v) if err == nil { cv.state.font = f + } else { + fonts[v] = f } } } diff --git a/text.go b/text.go index 097e5f2..8710de6 100644 --- a/text.go +++ b/text.go @@ -22,7 +22,7 @@ var zeroes [alphaTexSize]byte var defaultFont *Font -func LoadFont(src interface{}, name string) (*Font, error) { +func LoadFont(src interface{}) (*Font, error) { var f *Font switch v := src.(type) { case *truetype.Font: @@ -46,9 +46,6 @@ func LoadFont(src interface{}, name string) (*Font, error) { default: return nil, errors.New("Unsupported source type") } - if name != "" { - fonts[name] = f - } if defaultFont == nil { defaultFont = f }