text

package
v0.0.0-...-abed7bd Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package text supports a few simple functions for doing distance field font rendering. Dictionaries are created from truetype font files using the text/tool binary. One of these .dict files can be loaded using text.LoadDictionary(), then font can be rendered using dict.RenderString().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dictionary

type Dictionary struct {
	Runes   map[rune]RuneInfo
	Kerning map[RunePair]int

	// Width and height of the atlas
	Dx, Dy int32

	// Greyscale bytes of the atlas
	Pix []byte

	// Maximum bounds of any glyphs.
	GlyphMax image.Rectangle
	// contains filtered or unexported fields
}

Dictionary contains all of the information about a font necessary for rendering it using distance field font rendering.

func LoadDictionary

func LoadDictionary(r io.Reader) (*Dictionary, error)

LoadDictionary reads a gobbed Dictionary object from r, registers its atlas texture with opengl, and returns a Dictionary that is ready to render text.

func (*Dictionary) RenderString

func (d *Dictionary) RenderString(str string, x, y, height float64)

RenderString must be called on the render thread. x and y are the initial position of the pen, in screen coordinates, and height is the height of a full line of text, in screen coordinates.

func (*Dictionary) SetFontColor

func (d *Dictionary) SetFontColor(r, g, b float64)

type RuneInfo

type RuneInfo struct {
	PixBounds       image.Rectangle
	GlyphBounds     image.Rectangle
	AdvanceHeight   int
	TopSideBearing  int
	AdvanceWidth    int
	LeftSideBearing int
}

type RunePair

type RunePair struct {
	A, B rune
}

Directories

Path Synopsis
Binary tool generates dictionary files that can be used by the text package to render text using the distance field font rendering method.
Binary tool generates dictionary files that can be used by the text package to render text using the distance field font rendering method.

Jump to

Keyboard shortcuts

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