-
Notifications
You must be signed in to change notification settings - Fork 0
/
intelonemono.go
47 lines (41 loc) · 1.22 KB
/
intelonemono.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 intelonemono
import (
"sync"
"gio.tools/fonts/intelonemono/intelonemonobold"
"gio.tools/fonts/intelonemono/intelonemonobolditalic"
"gio.tools/fonts/intelonemono/intelonemonoitalic"
"gio.tools/fonts/intelonemono/intelonemonolight"
"gio.tools/fonts/intelonemono/intelonemonolightitalic"
"gio.tools/fonts/intelonemono/intelonemonomedium"
"gio.tools/fonts/intelonemono/intelonemonomediumitalic"
"gio.tools/fonts/intelonemono/intelonemonoregular"
"gioui.org/font"
"gioui.org/font/opentype"
)
var (
once sync.Once
collection []font.FontFace
)
func Collection() []font.FontFace {
once.Do(func() {
register(intelonemonobold.OTF)
register(intelonemonobolditalic.OTF)
register(intelonemonoitalic.OTF)
register(intelonemonolight.OTF)
register(intelonemonolightitalic.OTF)
register(intelonemonomedium.OTF)
register(intelonemonomediumitalic.OTF)
register(intelonemonoregular.OTF)
// 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])
}