go-freetype-fontloader
Finds and loads TrueType font files for use with github.com/golang/freetype.
Includes a simple font cache.
- License: revised BSD, see LICENSE
- Docs: godoc
- Dependencies:
fc-match
from the fontconfig
package.
Usage
Recommended usage (assuming few fonts are needed):
font, err := LoadCache("sans")
Loading a font without caching it (e.g. to implement your own cache):
font, err := Load("sans")
Using your own cache instance instead of the predefined global cache:
cache := NewFontCache()
font, err := cache.Load("sans")
Absolute paths are also supported. This provides a fallback for users who don't have fontconfig installed:
font, err := Load("/usr/share/fonts/dejavu/DejaVuSans.ttf")