Documentation ¶
Overview ¶
Package atext is used to manage and load fonts, layout and draw text.
Index ¶
- Variables
- type Char
- func (c *Char) GetGlyph() *Glyph
- func (c *Char) GetPosition() a.IntVector2
- func (c *Char) GetRect() *common.RectBoundary
- func (c *Char) GetRune() rune
- func (c *Char) GetSize() a.IntVector2
- func (c *Char) GetX() int
- func (c *Char) GetY() int
- func (c *Char) IsVisible() bool
- func (c *Char) String() string
- 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 Provider
- type Text
- func (t *Text) ForEachChar(delegate func(c *Char))
- func (t *Text) GetAText() *Text
- func (t *Text) GetActualRect() *common.RectBoundary
- func (t *Text) GetAllChars() []*Char
- func (t *Text) GetCharAt(index int) *Char
- func (t *Text) GetCharsCount() int
- func (t *Text) GetInitialRect() *common.RectBoundary
- func (t *Text) GetLineAt(index int) *Line
- func (t *Text) GetLinesCount() int
- func (t *Text) GetSize() a.IntVector2
- func (t *Text) String() string
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 top-left position of the character on the screen, where it should be drawn.
func (*Char) GetRect ¶ added in v0.3.4
func (c *Char) GetRect() *common.RectBoundary
GetRect returns the rect of the char.
func (*Char) GetSize ¶ added in v0.3.4
func (c *Char) GetSize() a.IntVector2
GetSize reruns the size of the char in pixels.
func (*Char) GetX ¶ added in v0.2.0
GetX return the x coordinate of the top-left position of the char.
func (*Char) GetY ¶ added in v0.2.0
GetY return the y coordinate of the top-left position of the char.
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 LayoutOptions ¶
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line represents a single line of characters in the text.
func (*Line) GetCharAt ¶ added in v0.2.0
GetCharAt returns the char at the given index. Returns nil if index is out of bounds.
func (*Line) GetCharsCount ¶ added in v0.2.0
GetCharsCount returns the number of characters in this line.
func (*Line) GetSize ¶
func (l *Line) GetSize() a.IntVector2
GetSize returns the size of the line in pixels.
func (*Line) GetWidth ¶ added in v0.3.4
GetWidth returns the width of all characters in this line in pixels.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text contains the layered out text. Read only.
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) GetActualRect ¶ added in v0.3.4
func (t *Text) GetActualRect() *common.RectBoundary
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
GetCharsCount returns the total number of characters in the text.
func (*Text) GetInitialRect ¶ added in v0.3.4
func (t *Text) GetInitialRect() *common.RectBoundary
func (*Text) GetLinesCount ¶ added in v0.2.0
func (*Text) GetSize ¶
func (t *Text) GetSize() a.IntVector2
GetSize returns the calculated text size.