-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathubuntu.go
47 lines (41 loc) · 1.08 KB
/
ubuntu.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
39
40
41
42
43
44
45
46
47
package ubuntu
import (
"sync"
"gio.tools/fonts/ubuntu/ubuntubold"
"gio.tools/fonts/ubuntu/ubuntubolditalic"
"gio.tools/fonts/ubuntu/ubuntuitalic"
"gio.tools/fonts/ubuntu/ubuntulight"
"gio.tools/fonts/ubuntu/ubuntulightitalic"
"gio.tools/fonts/ubuntu/ubuntumedium"
"gio.tools/fonts/ubuntu/ubuntumediumitalic"
"gio.tools/fonts/ubuntu/ubunturegular"
"gioui.org/font"
"gioui.org/font/opentype"
)
var (
once sync.Once
collection []font.FontFace
)
func Collection() []font.FontFace {
once.Do(func() {
register(ubuntubold.TTF)
register(ubuntubolditalic.TTF)
register(ubuntuitalic.TTF)
register(ubuntulight.TTF)
register(ubuntulightitalic.TTF)
register(ubuntumedium.TTF)
register(ubuntumediumitalic.TTF)
register(ubunturegular.TTF)
// Ensure that any outside appends will not reuse the backing store.
n := len(collection)
collection = collection[:n:n]
})
return collection
}
func register(src []byte) {
faces, err := opentype.ParseCollection(src)
if err != nil {
panic("failed to parse font: " + err.Error())
}
collection = append(collection, faces[0])
}