ttf

package
v0.0.0-...-c6f5269 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2013 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package ttf provides bindings for SDL2_ttf.

Usage

The ttf package is not thread safe and all calls must be serialized in some way. This can be done by only calling the ttf package from a single goroutine or wrapping the calls in a sync.Mutex. See http://bugzilla.libsdl.org/show_bug.cgi?id=1532 for more information.

Index

Constants

View Source
const (
	MAJOR_VERSION = C.SDL_TTF_MAJOR_VERSION
	MINOR_VERSION = C.SDL_TTF_MINOR_VERSION
	PATCHLEVEL    = C.SDL_TTF_PATCHLEVEL
)

Variables

View Source
var InvalidFont = fmt.Errorf("Invalid Font")

Functions

func Init

func Init() error

Init initializes the TTF engine.

func LinkedVersion

func LinkedVersion() *sdl.Version

LinkedVersion returns the version of the dynamically linked SDL_ttf library.

func Quit

func Quit()

Quit cleans up the TTF engine.

func Version

func Version() *sdl.Version

Version returns the compile-time version of the SDL_ttf library.

func WasInit

func WasInit() bool

Wasinit checks if the TTF engine is intialized.

Types

type Font

type Font struct {
	// contains filtered or unexported fields
}

Font contains font information.

func OpenFont

func OpenFont(file string, ptsize int) (Font, error)

OpenFont opens a font file and creates a font of the specified point size. This can load .ttf or .fon files.

func OpenFontIndex

func OpenFontIndex(file string, ptsize, index int) (Font, error)

OpenFontIndex opens a font file and creates a font of the specified point size using the specified index. This can load .ttf or .fon files.

func (Font) Ascent

func (f Font) Ascent() (int, error)

Ascent gets the offset from the baseline to the top of f. This is a positive value, relative to the baseline.

func (Font) Close

func (f Font) Close()

Close closes the font file.

func (Font) Descent

func (f Font) Descent() (int, error)

Descent gets the off from the baseline to the bottom of f. This is a negative value, relative to the baseline.

func (Font) FaceFamilyName

func (f Font) FaceFamilyName() (string, error)

FaceFamilyName returns the current font face family name of f.

func (Font) FaceIsFixedWidth

func (f Font) FaceIsFixedWidth() (bool, error)

FaceIsFixedWidth checks if the current font face of f is a fixed width font.

func (Font) FaceStyleName

func (f Font) FaceStyleName() (string, error)

FaceStyleName returns the current font face style name of f.

func (Font) Faces

func (f Font) Faces() (int, error)

Faces gets the number of faces of f.

func (Font) GetHinting

func (f Font) GetHinting() (Hint, error)

GetHinting gets the FreeType hinter setting for f.

func (Font) GetKerning

func (f Font) GetKerning() (bool, error)

GetKerning returns whether or not kerning is allowed for f.

func (Font) GetOutline

func (f Font) GetOutline() (int, error)

GetOutline gets the outline of f in pixels.

func (Font) GetStyle

func (f Font) GetStyle() (Style, error)

GetStyle gets the style of f.

func (Font) GetkerningSize

func (f Font) GetkerningSize(prevIndex, index int) (int, error)

GetKerningSize gets the kerning size of two glyphs.

func (Font) GlyphIsProvided

func (f Font) GlyphIsProvided(ch uint16) (bool, error)

GlyphIsProvided checks whether a glyph is provided by f or not.

func (Font) GlyphMetrics

func (f Font) GlyphMetrics(ch uint16) (minx, maxx, miny, maxy, advance int, err error)

GlyphMetrics gets the metrics of a glyph.

See http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html

func (Font) Height

func (f Font) Height() (int, error)

Height gets the total height of f.

func (Font) LineSkip

func (f Font) LineSkip() (int, error)

LineSkip gets the recommended spacing between lines of text for f.

func (Font) RenderTextBlended

func (f Font) RenderTextBlended(text string, fg sdl.Color) (*sdl.Surface, error)

RenderTextBlended creates a 32-bit ARGB surface and renders the given text at high quality, using alpha blending to dither the font with the given color.

func (Font) RenderTextBlendedWrapped

func (f Font) RenderTextBlendedWrapped(text string, fg sdl.Color, wrapLength uint32) (*sdl.Surface, error)

RenderTextBlendedWrapped creates a 32-bit ARGB surface and renders the given text at high quality, using alpha blending to dither the font with the given color. Text is wrapped to multiple lines on line endings and on word boundaries if it extends beyond wrapLength in pixels.

func (Font) RenderTextShaded

func (f Font) RenderTextShaded(text string, fg, bg sdl.Color) (*sdl.Surface, error)

RenderTextShaded creates an 8-bit palattized surface and renders the given text at high quality with the given font and colors. The 0 pixel is background, while other pixels have varying degrees of the foreground color.

func (Font) RenderTextSolid

func (f Font) RenderTextSolid(text string, fg sdl.Color) (*sdl.Surface, error)

RenderTextSolid creates an 8-bit palettized surface and render the given text at fast quality with the given font and color. The 0 pixel is the colorkey, giving a transparent background, and the 1 pixel is set to the text color.

func (Font) SetHinting

func (f Font) SetHinting(hinting Hint) error

SetHinting sets the FreeType hinter setting for f.

func (Font) SetKerning

func (f Font) SetKerning(allowed bool) error

SetKerning sets whether or not kerning is allowed for f.

func (Font) SetOutline

func (f Font) SetOutline(outline int) error

SetOutline sets the outline of f in pixels.

func (Font) SetStyle

func (f Font) SetStyle(style Style) error

SetStyle set the style of f.

func (Font) Size

func (f Font) Size(text string) (w, h int, err error)

Get the dimensions of a rendered string of text.

type Hint

type Hint int
const (
	HINTING_NORMAL Hint = C.TTF_HINTING_NORMAL
	HINTING_LIGHT  Hint = C.TTF_HINTING_LIGHT
	HINTING_MONO   Hint = C.TTF_HINTING_MONO
	HINTING_NONE   Hint = C.TTF_HINTING_NONE
)

FreeType hinter settings.

type Style

type Style int
const (
	STYLE_NORMAL        Style = C.TTF_STYLE_NORMAL
	STYLE_BOLD          Style = C.TTF_STYLE_BOLD
	STYLE_ITALIC        Style = C.TTF_STYLE_ITALIC
	STYLE_UNDERLINE     Style = C.TTF_STYLE_UNDERLINE
	STYLE_STRIKETHROUGH Style = C.TTF_STYLE_STRIKETHROUGH
)

Font style settings.

Jump to

Keyboard shortcuts

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