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
|
cv.state.lineWidth = width
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFont sets the font and font size. The font parameter can be:
|
// SetFont sets the font and font size. The font parameter can be a font loaded
|
||||||
// - a font loaded with the LoadFont function
|
// with the LoadFont function, a filename for a font to load (which will be
|
||||||
// - a string matching the name parameter on LoadFont
|
// cached), or nil, in which case the first loaded font will be used
|
||||||
// - a filename for a font to load which will be cached
|
|
||||||
// - nil, in which case the first loaded font will be used
|
|
||||||
func (cv *Canvas) SetFont(font interface{}, size float64) {
|
func (cv *Canvas) SetFont(font interface{}, size float64) {
|
||||||
if font == nil {
|
if font == nil {
|
||||||
cv.state.font = defaultFont
|
cv.state.font = defaultFont
|
||||||
|
@ -460,9 +458,11 @@ func (cv *Canvas) SetFont(font interface{}, size float64) {
|
||||||
if f, ok := fonts[v]; ok {
|
if f, ok := fonts[v]; ok {
|
||||||
cv.state.font = f
|
cv.state.font = f
|
||||||
} else {
|
} else {
|
||||||
f, err := LoadFont(v, v)
|
f, err := LoadFont(v)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cv.state.font = f
|
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
|
var defaultFont *Font
|
||||||
|
|
||||||
func LoadFont(src interface{}, name string) (*Font, error) {
|
func LoadFont(src interface{}) (*Font, error) {
|
||||||
var f *Font
|
var f *Font
|
||||||
switch v := src.(type) {
|
switch v := src.(type) {
|
||||||
case *truetype.Font:
|
case *truetype.Font:
|
||||||
|
@ -46,9 +46,6 @@ func LoadFont(src interface{}, name string) (*Font, error) {
|
||||||
default:
|
default:
|
||||||
return nil, errors.New("Unsupported source type")
|
return nil, errors.New("Unsupported source type")
|
||||||
}
|
}
|
||||||
if name != "" {
|
|
||||||
fonts[name] = f
|
|
||||||
}
|
|
||||||
if defaultFont == nil {
|
if defaultFont == nil {
|
||||||
defaultFont = f
|
defaultFont = f
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue