fontloader

package module
v0.0.0-...-b826926 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2017 License: BSD-3-Clause Imports: 6 Imported by: 1

README

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")

Documentation

Index

Constants

View Source
const (
	FONTCONFIG_MATCH_PROGRAM = "fc-match"
)

Variables

This section is empty.

Functions

func Load

func Load(fontName string) (*truetype.Font, error)

func LoadCache

func LoadCache(fontName string) (*truetype.Font, error)

Types

type FontCache

type FontCache interface {
	Load(fontName string) (*truetype.Font, error)
}

func NewFontCache

func NewFontCache() FontCache

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL