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
- Variables
- func Init() error
- func LinkedVersion() *sdl.Version
- func Quit()
- func Version() *sdl.Version
- func WasInit() bool
- type Font
- func (f Font) Ascent() (int, error)
- func (f Font) Close()
- func (f Font) Descent() (int, error)
- func (f Font) FaceFamilyName() (string, error)
- func (f Font) FaceIsFixedWidth() (bool, error)
- func (f Font) FaceStyleName() (string, error)
- func (f Font) Faces() (int, error)
- func (f Font) GetHinting() (Hint, error)
- func (f Font) GetKerning() (bool, error)
- func (f Font) GetOutline() (int, error)
- func (f Font) GetStyle() (Style, error)
- func (f Font) GetkerningSize(prevIndex, index int) (int, error)
- func (f Font) GlyphIsProvided(ch uint16) (bool, error)
- func (f Font) GlyphMetrics(ch uint16) (minx, maxx, miny, maxy, advance int, err error)
- func (f Font) Height() (int, error)
- func (f Font) LineSkip() (int, error)
- func (f Font) RenderTextBlended(text string, fg sdl.Color) (*sdl.Surface, error)
- func (f Font) RenderTextBlendedWrapped(text string, fg sdl.Color, wrapLength uint32) (*sdl.Surface, error)
- func (f Font) RenderTextShaded(text string, fg, bg sdl.Color) (*sdl.Surface, error)
- func (f Font) RenderTextSolid(text string, fg sdl.Color) (*sdl.Surface, error)
- func (f Font) SetHinting(hinting Hint) error
- func (f Font) SetKerning(allowed bool) error
- func (f Font) SetOutline(outline int) error
- func (f Font) SetStyle(style Style) error
- func (f Font) Size(text string) (w, h int, err error)
- type Hint
- type Style
Constants ¶
const ( MAJOR_VERSION = C.SDL_TTF_MAJOR_VERSION MINOR_VERSION = C.SDL_TTF_MINOR_VERSION PATCHLEVEL = C.SDL_TTF_PATCHLEVEL )
Variables ¶
var InvalidFont = fmt.Errorf("Invalid Font")
Functions ¶
func LinkedVersion ¶
LinkedVersion returns the version of the dynamically linked SDL_ttf library.
Types ¶
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font contains font information.
func OpenFont ¶
OpenFont opens a font file and creates a font of the specified point size. This can load .ttf or .fon files.
func OpenFontIndex ¶
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 ¶
Ascent gets the offset from the baseline to the top of f. This is a positive value, relative to the baseline.
func (Font) Descent ¶
Descent gets the off from the baseline to the bottom of f. This is a negative value, relative to the baseline.
func (Font) FaceFamilyName ¶
FaceFamilyName returns the current font face family name of f.
func (Font) FaceIsFixedWidth ¶
FaceIsFixedWidth checks if the current font face of f is a fixed width font.
func (Font) FaceStyleName ¶
FaceStyleName returns the current font face style name of f.
func (Font) GetHinting ¶
GetHinting gets the FreeType hinter setting for f.
func (Font) GetKerning ¶
GetKerning returns whether or not kerning is allowed for f.
func (Font) GetOutline ¶
GetOutline gets the outline of f in pixels.
func (Font) GetkerningSize ¶
GetKerningSize gets the kerning size of two glyphs.
func (Font) GlyphIsProvided ¶
GlyphIsProvided checks whether a glyph is provided by f or not.
func (Font) GlyphMetrics ¶
GlyphMetrics gets the metrics of a glyph.
See http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
func (Font) RenderTextBlended ¶
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 ¶
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 ¶
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 ¶
SetHinting sets the FreeType hinter setting for f.
func (Font) SetKerning ¶
SetKerning sets whether or not kerning is allowed for f.
func (Font) SetOutline ¶
SetOutline sets the outline of f in pixels.
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.