LoadFontFile loads a font from a file.
(filename string, style FontStyle)
| 252 | |
| 253 | // LoadFontFile loads a font from a file. |
| 254 | func LoadFontFile(filename string, style FontStyle) (*Font, error) { |
| 255 | b, err := os.ReadFile(filename) |
| 256 | if err != nil { |
| 257 | return nil, fmt.Errorf("failed to load font file '%s': %w", filename, err) |
| 258 | } |
| 259 | return LoadFont(b, 0, style) |
| 260 | } |
| 261 | |
| 262 | // LoadFontCollection loads a font from a collection file and uses the font at the specified index. |
| 263 | func LoadFontCollection(filename string, index int, style FontStyle) (*Font, error) { |