Init initializes the font library if it hasn't been yet
()
| 96 | |
| 97 | // Init initializes the font library if it hasn't been yet |
| 98 | func (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 |
no test coverage detected