atext

package
v0.2.0-preview.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

This package 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 position of the character on the screen, where it should be drawn.

func (*Char) GetRune

func (c *Char) GetRune() rune

GetRune returns the rune the char is associated with.

func (*Char) GetX added in v0.2.0

func (c *Char) GetX() int

func (*Char) GetY added in v0.2.0

func (c *Char) GetY() int

func (*Char) IsVisible

func (c *Char) IsVisible() bool

IsVisible tells if the character has a visual representation.

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
}

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

func (*Line) GetCharsCount added in v0.2.0

func (l *Line) GetCharsCount() int

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

GetCharCount returns the total number of characters in the text.

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.

Jump to

Keyboard shortcuts

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