-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfont.go
38 lines (30 loc) · 882 Bytes
/
font.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package charts
import (
"github.com/golang/freetype/truetype"
"github.com/go-analyze/charts/chartdraw"
)
const defaultFontSize = 12.0
// InstallFont installs the font for charts
func InstallFont(fontFamily string, data []byte) error {
return chartdraw.InstallFont(fontFamily, data)
}
func getPreferredFont(fonts ...*truetype.Font) *truetype.Font {
for _, font := range fonts {
if font != nil {
return font
}
}
return GetDefaultFont()
}
// GetDefaultFont get default font.
func GetDefaultFont() *truetype.Font {
return chartdraw.GetDefaultFont()
}
// SetDefaultFont set default font by name.
func SetDefaultFont(fontFamily string) error {
return chartdraw.SetDefaultFont(fontFamily)
}
// GetFont get the font by font family or the default if the family is not installed.
func GetFont(fontFamily string) *truetype.Font {
return chartdraw.GetFont(fontFamily)
}