CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload
()
| 77 | |
| 78 | // CreatePreloaded is for loading fonts which have already been defined (and loaded) within Preload |
| 79 | func (f *Font) CreatePreloaded() error { |
| 80 | fontres, err := engo.Files.Resource(f.URL) |
| 81 | if err != nil { |
| 82 | return err |
| 83 | } |
| 84 | |
| 85 | fnt, ok := fontres.(FontResource) |
| 86 | if !ok { |
| 87 | return fmt.Errorf("preloaded font is not of type `*truetype.Font`: %s", f.URL) |
| 88 | } |
| 89 | |
| 90 | f.TTF = fnt.Font |
| 91 | f.face = truetype.NewFace(f.TTF, &truetype.Options{ |
| 92 | Size: f.Size, |
| 93 | DPI: dpi, |
| 94 | Hinting: font.HintingFull, |
| 95 | }) |
| 96 | fontCache = append(fontCache, f) |
| 97 | return nil |
| 98 | } |
| 99 | |
| 100 | // TextDimensions returns the total width, total height and total line size |
| 101 | // of the input string written out in the Font. |