MCPcopy Create free account
hub / github.com/cogentcore/core / Init

Method Init

paint/fontlib.go:98–117  ·  view source on GitHub ↗

Init initializes the font library if it hasn't been yet

()

Source from the content-addressed store, hash-verified

96
97// Init initializes the font library if it hasn't been yet
98func (fl *FontLib) Init() {
99 if fl.FontPaths == nil {
100 loadFontMu.Lock()
101 // fmt.Printf("Initializing font lib\n")
102 fl.FontsFS = fsx.Sub(defaultFonts, "fonts")
103 fl.FontPaths = make([]string, 0)
104 fl.FontsAvail = make(map[string]string)
105 fl.FontInfo = make([]FontInfo, 0)
106 fl.Faces = make(map[string]map[int]*styles.FontFace)
107 loadFontMu.Unlock()
108 return // no paths to load from yet
109 }
110 loadFontMu.RLock()
111 sz := len(fl.FontsAvail)
112 loadFontMu.RUnlock()
113 if sz == 0 {
114 // fmt.Printf("updating fonts avail in %v\n", fl.FontPaths)
115 fl.UpdateFontsAvail()
116 }
117}
118
119// Font gets a particular font, specified by the official regularized font
120// name (see FontsAvail list), at given dots size (integer), using a cache of

Callers 2

FontMethod · 0.95
AddFontPathsMethod · 0.95

Calls 4

UpdateFontsAvailMethod · 0.95
SubFunction · 0.92
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected