fonts

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

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

Go to latest
Published: Jan 17, 2020 License: ISC Imports: 5 Imported by: 0

README

Package fonts provides a cross-platform way to load font data in Go
-------------------------------------------------------------------
http://godoc.org/github.com/tmc/fonts

Currently supported: MacOS, (generic) Linux, Windows
License: ISC

Documentation

Overview

Package fonts provides a cross-platform interface to list and load font data

Index

Examples

Constants

This section is empty.

Variables

View Source
var FontPaths = []string{
	"$HOME/.fonts/**/*",
	"/usr/local/share/fonts/**/*",
	"/usr/share/fonts/**/*",
	"/usr/X11/lib/X11/fonts/**/*",
}

The list of font paths on Linux this could be improved to use fontconfig

View Source
var ValidExtensions = []string{"ttf", "otf"}

ValidExtensions is the list of file extensions to consider font files

Functions

func Load

func Load(fontNames ...string) (io.Reader, error)

Load attempts to load font file data given font names

Example
fontReader, _ := Load("Helvetica", "DejaVuSansMono")
fontBytes, _ := ioutil.ReadAll(fontReader)
_, err := freetype.ParseFont(fontBytes) // "code.google.com/p/freetype-go/freetype"
fmt.Println(err)
Output:

<nil>

Types

type Font

type Font struct {
	Name   string
	Source string
}

Font holds the name of a font and an optional string indicating the font's source

func List

func List() ([]Font, error)

List the available fonts

func (Font) Load

func (f Font) Load() (io.Reader, error)

Load attempts to load the font's data from its Name

Jump to

Keyboard shortcuts

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