removed the name parameter from LoadFont
This commit is contained in:
parent
db1797c19a
commit
ad16b6fee2
2 changed files with 7 additions and 10 deletions
12
canvas.go
12
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
5
text.go
5
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue