Documentation
¶
Overview ¶
Package text implements texture rendering from font texture map
Index ¶
- Constants
- type Align
- type Entity
- type Font
- type FontOptions
- type FontOptionsFunc
- type Glyph
- type Mesh
- func (m *Mesh) MeasureWidth(w []rune) float32
- func (m *Mesh) SetAlignment(a Align)
- func (m *Mesh) SetBoundary(w, h float32)
- func (m *Mesh) SetFont(font *Font)
- func (m *Mesh) SetMode(mm Mode)
- func (m *Mesh) SetOverflow(o Overflow)
- func (m *Mesh) SetSize(v float32)
- func (m *Mesh) SetText(a ...any)
- func (m *Mesh) Update()
- type MeshFunc
- type Mode
- type Overflow
Constants ¶
const ( // OverflowOverlap let the text overflow the boundary OverflowOverlap = Overflow(iota) // OverflowWordWrap breaks lines on spaces and char by char if no space OverflowWordWrap // OverflowBreakWord breaks words OverflowBreakWord )
const ( AlignStart = Align(iota) AlignCenter AlignEnd )
Text Alignment types.
const ( ModeFlow = Mode(iota) ModeRaw )
Flow modes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity struct {
gorge.TransformComponent
gorge.RenderableComponent
gorge.ColorableComponent
// contains filtered or unexported fields
}
Entity renderable entity
type Font ¶
type Font struct {
Face font.Face
Glyphs map[rune]Glyph
SpaceAdv float32
// Size is the internally rendered size
Size float32
*gorge.Texture
}
Font is like a texture with extra information about glyphs
type FontOptions ¶
FontOptions options for font
type FontOptionsFunc ¶
type FontOptionsFunc func(o *FontOptions)
FontOptionsFunc func to manipulate font options.
func FontBackground ¶
func FontBackground(c gm.Vec4) FontOptionsFunc
FontBackground sets the font texture background option.
func FontForeground ¶
func FontForeground(c gm.Vec4) FontOptionsFunc
FontForeground sets the font texture foreground option.
func FontResolution ¶
func FontResolution(n int) FontOptionsFunc
FontResolution sets the font texture resolution option.
func FontRunes ¶
func FontRunes(chars []rune) FontOptionsFunc
FontRunes sets the font texture runes option.
type Glyph ¶
type Glyph struct {
Uv1 gm.Vec2
Uv2 gm.Vec2
Size gm.Vec2
Advance float32
BearingH float32
BearingV float32
}
Glyph char information
type Mesh ¶
type Mesh struct {
Text string
// Boundary counting from starting Point
Boundary gm.Vec2
// Wrap just naive string wrap, should have better options
Alignment Align
Overflow Overflow
// Size 0 will return a default size (1)
Size float32
Mode Mode
Font *Font
// TODO: {lpf} Calculated values should be private and functions added
Min, Max gm.Vec2
Lines int
// contains filtered or unexported fields
}
Mesh to be used on renderable update must be called to update the mesh after changing.
func (*Mesh) MeasureWidth ¶
MeasureWidth measures a width of a text best usage without "\n"
func (*Mesh) SetAlignment ¶
SetAlignment sets the horizontal alignment based on boundary and updates underlying mesh.
func (*Mesh) SetBoundary ¶
SetBoundary set text boundary, and updates mesh.
func (*Mesh) SetFont ¶
SetFont sets the font used to draw the vertices, Material texture should change too to show the assigned font.
func (*Mesh) SetOverflow ¶
SetOverflow sets text overflow based on boundary and updates underlying mesh.
type MeshFunc ¶
type MeshFunc func(t *Mesh)
MeshFunc allows mesh function options to be added in initializator