aboutsummaryrefslogtreecommitdiff
path: root/go/font/font.go
blob: ae75cf8d6a7aa8b77d4531cac7821de16abf2ca9 (plain)
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 font

import (
	"log"

	"golang.org/x/image/font"
	"golang.org/x/image/font/gofont/goregular"
	"golang.org/x/image/font/opentype"
)

var Font24 font.Face
var Font18 font.Face
var Font12 font.Face

func InitFont() {
	tt, err := opentype.Parse(goregular.TTF)
	if err != nil {
		log.Fatal(err)
	}

	opts := &opentype.FaceOptions{Size: 24, DPI: 72}
	Font24, err = opentype.NewFace(tt, opts)
	if err != nil {
		log.Fatal(err)
	}

	opts = &opentype.FaceOptions{Size: 18, DPI: 72}
	Font18, err = opentype.NewFace(tt, opts)
	if err != nil {
		log.Fatal(err)
	}

	opts = &opentype.FaceOptions{Size: 12, DPI: 72}
	Font12, err = opentype.NewFace(tt, opts)
	if err != nil {
		log.Fatal(err)
	}
}