font

package
v0.0.0-...-63a8a9f Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: Unlicense Imports: 4 Imported by: 0

Documentation

Overview

Package font handles graphical text entries with customizable font size, style and color. It uses a small subset of the features provided by the SFML library version 2.5 1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Font

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

A Font provides glyphs (visual characters) and metrics used for text rendering.

func Load

func Load(path string) (*Font, error)

Load loads the provided TTF font.

Note: The Free method of the font must be called when finished using it.

func (*Font) Free

func (font *Font) Free()

Free frees the font.

type Style

type Style uint32

Style is a bitfield which represents the style of a text.

const (
	// Regular characters (no style).
	Regular Style = C.sfTextRegular
	// Bold characters.
	Bold Style = C.sfTextBold
	// Italic characters.
	Italic Style = C.sfTextItalic
	// Underlined characters.
	Underlined Style = C.sfTextUnderlined
)

Text styles.

type Text

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

Text represent a graphical text entry with a specific font size, style and color. It implements the wandi.Image interface.

func NewText

func NewText(font *Font, args ...interface{}) (*Text, error)

NewText returns a new graphical text entry based on the provided font and any optional customization arguments. The initial text, size, style and color of the graphical text entry can be customized through string, int, Style and color.Color arguments respectively, depending on the type of the argument.

The default font size, style and color of the text is 12, regular (no style) and black respectively.

Note: The Free method of the text entry must be called when finished using it.

func (*Text) Free

func (text *Text) Free()

Free frees the text entry.

func (*Text) Height

func (text *Text) Height() int

Height returns the height of the text entry.

func (*Text) SetColor

func (text *Text) SetColor(c color.Color)

SetColor sets the color of the text.

func (*Text) SetSize

func (text *Text) SetSize(size int)

SetSize sets the font size, in pixels, of the text.

func (*Text) SetStyle

func (text *Text) SetStyle(style Style)

SetStyle sets the style of the text.

func (*Text) SetText

func (text *Text) SetText(s string)

SetText sets the text of the text entry.

func (*Text) Width

func (text *Text) Width() int

Width returns the width of the text entry.

Jump to

Keyboard shortcuts

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