font

package
v0.0.0-...-d623aaa Latest Latest
Warning

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

Go to latest
Published: May 28, 2018 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTextureFontSize = 64

DefaultTextureFontSize is the default size used for SDF texture generation

View Source
const MaxTextureSize = 2048

MaxTextureSize is the maximum width/height each font texture can have

View Source
const SDFRadius = 8

SDFRadius is the search radius for each pixel during the distance fields generation

Variables

View Source
var (
	// ErrFontDoesntFit means the font glyphs don't fit within the maximum texture limit
	ErrFontDoesntFit = errors.New("font texture doesn't fit within texture size limits")
)
View Source
var ErrFontNotFound = errors.New("could not find font files")

ErrFontNotFound means any valid font formats (ttf, sdf+atlas) could not be found

Functions

func ClearCache

func ClearCache()

ClearCache removes all entries from the font cache

Types

type Atlas

type Atlas map[rune]image.Rectangle

Atlas is a dictionary that maps each font glyph to its position on a texture atlas

type Font

type Font struct {
	Texture *image.RGBA
	Atlas   Atlas
	Size    int
	TTF     *truetype.Font
}

Font holds the necessary data for using a font in youi

func DefaultFont

func DefaultFont() *Font

DefaultFont loads (and generate, if necessary) the default font for youi (goregular)

func LoadFont

func LoadFont(fontName string) (*Font, error)

LoadFont loads either the pregenerated SDF+Atlas or TTF font from disk or binary and returns a usable youi font

func MakeFont

func MakeFont(fnt *truetype.Font, fontSize int) (*Font, error)

MakeFont creates an SDF font atlas from a ttf font

Jump to

Keyboard shortcuts

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