go-chart/font.go
Zeni Kim cc8d36edd9
Some checks failed
Continuous Integration / Tests (push) Has been cancelled
update url
2024-10-27 21:52:38 -05:00

29 lines
562 B
Go

package chart
import (
"sync"
"git.smarteching.com/zeni/go-chart/v2/roboto"
"github.com/golang/freetype/truetype"
)
var (
_defaultFontLock sync.Mutex
_defaultFont *truetype.Font
)
// GetDefaultFont returns the default font (Roboto-Medium).
func GetDefaultFont() (*truetype.Font, error) {
if _defaultFont == nil {
_defaultFontLock.Lock()
defer _defaultFontLock.Unlock()
if _defaultFont == nil {
font, err := truetype.Parse(roboto.Roboto)
if err != nil {
return nil, err
}
_defaultFont = font
}
}
return _defaultFont, nil
}