Documentation ¶
Overview ¶
This package is used to manage and load fonts, layout and draw text.
Index ¶
- Variables
- type Char
- type Face
- func (f *Face) GetAscent() int
- func (f *Face) GetCapHeight() int
- func (f *Face) GetDescent() int
- func (f *Face) GetFont() *Font
- func (f *Face) GetGlyph(r rune) *Glyph
- func (f *Face) GetKerning(r1, r2 rune) int
- func (f *Face) GetLineHeight() int
- func (f *Face) GetSize() int
- func (f *Face) GetXHeight() int
- type Font
- type Glyph
- func (g *Glyph) GetAdvance() int
- func (g *Glyph) GetAscent() int
- func (g *Glyph) GetBearing() a.IntVector2
- func (g *Glyph) GetDescent() int
- func (g *Glyph) GetFace() *Face
- func (g *Glyph) GetHeight() int
- func (g *Glyph) GetPixels() []byte
- func (g *Glyph) GetRune() rune
- func (g *Glyph) GetSize() a.IntVector2
- func (g *Glyph) GetWidth() int
- type LayoutOptions
- type Line
- type Text
Constants ¶
This section is empty.
Variables ¶
var DefaultFontData []byte
Functions ¶
This section is empty.
Types ¶
type Char ¶
type Char struct {
// contains filtered or unexported fields
}
Char is a representation of a character of text on the screen.
func (*Char) GetGlyph ¶
GetGlyph returns the Glyph for this character. Can return nil if the character is not associated with any Glyph.
func (*Char) GetPosition ¶
func (c *Char) GetPosition() a.IntVector2
GetPosition returns the position of the character on the screen, where it should be drawn.
type Face ¶
type Face struct {
// contains filtered or unexported fields
}
Face represents a font face, i.e. a font variant of the specific size.
func (*Face) GetCapHeight ¶
GetCapHeight returns the height of capital letter in this face.
func (*Face) GetDescent ¶
GetDescent returns the descent of this face.
func (*Face) GetKerning ¶
GetKerning returns the kerning between the two given runes.
func (*Face) GetLineHeight ¶
GetLineHeight returns the line height of this face.
func (*Face) GetXHeight ¶
GetXHeight returns the xHeight of this face.
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents a true type font.
func LoadDefaultFont ¶
func LoadFont ¶
LoadFont tries to find font file with the specified name in well-known locations and parse it. Supported only on PC.
type Glyph ¶
type Glyph struct {
// contains filtered or unexported fields
}
Glyph is the visual representation of a rune.
func (*Glyph) GetAdvance ¶
GetAdvance returns the x advance of the glyph.
func (*Glyph) GetBearing ¶
func (g *Glyph) GetBearing() a.IntVector2
GetBearing returns the x and y bearing of the glyph.
func (*Glyph) GetDescent ¶
GetDescent returns the descent of the glyph.
func (*Glyph) GetPixels ¶
GetPixels returns the actual pixels of the glyph, that can be drawn to the screen.
func (*Glyph) GetSize ¶
func (g *Glyph) GetSize() a.IntVector2
GetSize returns the size of the glyph.
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line represents a single line of characters in the text.
func (*Line) GetCharsCount ¶ added in v0.2.0
func (*Line) GetSize ¶
func (l *Line) GetSize() a.IntVector2
Returns the size of the line in pixels.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text contains the layered out text.
func LayoutRunes ¶
func LayoutRunes(face *Face, runes []rune, bounds *common.RectBoundary, options LayoutOptions) *Text
LayoutRunes splits the given text into lines, aligns text and calculates the coordinates of each rune in the slice.
func LayoutStringCompat ¶ added in v0.2.0
func (*Text) ForEachChar ¶
ForEachChar iterates over each character in this text.
func (*Text) GetAllChars ¶ added in v0.2.0
GetAllChars returns all characters in the text.
func (*Text) GetCharAt ¶ added in v0.2.0
GetCharAt returns the character at the specified position in text.
func (*Text) GetCharsCount ¶ added in v0.2.0
GetCharCount returns the total number of characters in the text.
func (*Text) GetLinesCount ¶ added in v0.2.0
func (*Text) GetSize ¶
func (t *Text) GetSize() a.IntVector2
GetSize returns the calculated text size.