atext

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package atext is used to manage and load fonts, layout and draw text.

Index

Constants

This section is empty.

Variables

View Source
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

func (c *Char) GetGlyph() *Glyph

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) GetRune

func (c *Char) GetRune() rune

GetRune returns the rune the char is associated with.

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

func (c *Char) GetX() int

GetX return the x coordinate of the top-left position of the char.

func (*Char) GetY added in v0.2.0

func (c *Char) GetY() int

GetY return the y coordinate of the top-left position of the char.

func (*Char) IsVisible

func (c *Char) IsVisible() bool

IsVisible tells if the character has a visual representation.

func (*Char) String added in v0.3.4

func (c *Char) String() string

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) GetAscent

func (f *Face) GetAscent() int

GetAscent returns the ascent of this face.

func (*Face) GetCapHeight

func (f *Face) GetCapHeight() int

GetCapHeight returns the height of capital letter in this face.

func (*Face) GetDescent

func (f *Face) GetDescent() int

GetDescent returns the descent of this face.

func (*Face) GetFont

func (f *Face) GetFont() *Font

GetFont returns the Font, that this face is associates with.

func (*Face) GetGlyph

func (f *Face) GetGlyph(r rune) *Glyph

GetGlyph creates a glyph i.e. a visual representation for the given rune.

func (*Face) GetKerning

func (f *Face) GetKerning(r1, r2 rune) int

GetKerning returns the kerning between the two given runes.

func (*Face) GetLineHeight

func (f *Face) GetLineHeight() int

GetLineHeight returns the line height of this face.

func (*Face) GetSize

func (f *Face) GetSize() int

GetSize returns the size of this font face.

func (*Face) GetXHeight

func (f *Face) GetXHeight() int

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 LoadDefaultFont() (*Font, error)

func LoadFont

func LoadFont(name string) (*Font, error)

LoadFont tries to find font file with the specified name in well-known locations and parse it. Supported only on PC.

func ParseFont

func ParseFont(fontData []byte) (*Font, error)

ParseFont parses a true type font from the data.

func (*Font) GetName

func (f *Font) GetName() string

Get Name returns the name of the font.

func (*Font) NewFace

func (f *Font) NewFace(size int) *Face

NewFace creates a new font face with the specifies size.

type Glyph

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

Glyph is the visual representation of a rune.

func (*Glyph) GetAdvance

func (g *Glyph) GetAdvance() int

GetAdvance returns the x advance of the glyph.

func (*Glyph) GetAscent

func (g *Glyph) GetAscent() int

GetAscent returns the ascent 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

func (g *Glyph) GetDescent() int

GetDescent returns the descent of the glyph.

func (*Glyph) GetFace

func (g *Glyph) GetFace() *Face

GetFace returns the font face it is associated with.

func (*Glyph) GetHeight added in v0.2.0

func (g *Glyph) GetHeight() int

func (*Glyph) GetPixels

func (g *Glyph) GetPixels() []byte

GetPixels returns the actual pixels of the glyph, that can be drawn to the screen.

func (*Glyph) GetRune

func (g *Glyph) GetRune() rune

GetRune returns the rune glyph is associated with.

func (*Glyph) GetSize

func (g *Glyph) GetSize() a.IntVector2

GetSize returns the size of the glyph.

func (*Glyph) GetWidth added in v0.2.0

func (g *Glyph) GetWidth() int

type LayoutOptions

type LayoutOptions struct {
	VTextAlign a.TextAlign
	HTextAlign a.TextAlign
	SingleLine bool
}

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

func (l *Line) GetCharAt(index int) *Char

GetCharAt returns the char at the given index. Returns nil if index is out of bounds.

func (*Line) GetCharsCount added in v0.2.0

func (l *Line) GetCharsCount() int

GetCharsCount returns the number of characters in this line.

func (*Line) GetHeight added in v0.3.4

func (l *Line) GetHeight() int

GetHeight return the height of this line in pixels.

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

func (l *Line) GetWidth() int

GetWidth returns the width of all characters in this line in pixels.

func (*Line) IsEmpty added in v0.3.4

func (l *Line) IsEmpty() bool

IsEmpty checks if this line has no characters.

func (*Line) String added in v0.3.4

func (l *Line) String() string

type Provider added in v0.3.4

type Provider interface {
	GetAText() *Text
}

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 LayoutStringCompat(face *Face, text string, minX, maxX, minY, maxY, minZ, maxZ float32, vTextAlign, hTextAlign int) *Text

func (*Text) ForEachChar

func (t *Text) ForEachChar(delegate func(c *Char))

ForEachChar iterates over each character in this text.

func (*Text) GetAText added in v0.3.4

func (t *Text) GetAText() *Text

func (*Text) GetActualRect added in v0.3.4

func (t *Text) GetActualRect() *common.RectBoundary

func (*Text) GetAllChars added in v0.2.0

func (t *Text) GetAllChars() []*Char

GetAllChars returns all characters in the text.

func (*Text) GetCharAt added in v0.2.0

func (t *Text) GetCharAt(index int) *Char

GetCharAt returns the character at the specified position in text.

func (*Text) GetCharsCount added in v0.2.0

func (t *Text) GetCharsCount() int

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) GetLineAt added in v0.2.0

func (t *Text) GetLineAt(index int) *Line

func (*Text) GetLinesCount added in v0.2.0

func (t *Text) GetLinesCount() int

func (*Text) GetSize

func (t *Text) GetSize() a.IntVector2

GetSize returns the calculated text size.

func (*Text) String added in v0.3.4

func (t *Text) String() string

Jump to

Keyboard shortcuts

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