textsdf

package
v0.0.0-...-a9b1306 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ISO3098TTF

func ISO3098TTF() []byte

ISO3098TTF returns the ISO-3098 true type font file.

Types

type Font

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

Font implements font parsing and glyph (character) generation.

func (*Font) AdvanceWidth

func (f *Font) AdvanceWidth(c rune) float32

Kern returns the horizontal adjustment for the given glyph pair. A positive kern means to move the glyphs further apart.

func (*Font) Configure

func (f *Font) Configure(cfg FontConfig) error

func (*Font) Glyph

func (f *Font) Glyph(c rune) (_ glbuild.Shader2D, err error)

Glyph returns a SDF for a character defined by the argument rune.

func (*Font) Kern

func (f *Font) Kern(c0, c1 rune) float32

Kern returns the horizontal adjustment for the given glyph pair. A positive kern means to move the glyphs further apart.

func (*Font) LoadTTFBytes

func (f *Font) LoadTTFBytes(ttf []byte) error

LoadTTFBytes loads a TTF file blob into f. After calling Load the Font is ready to generate text SDFs.

func (*Font) TextLine

func (f *Font) TextLine(s string) (glbuild.Shader2D, error)

TextLine returns a single line of text with the set font. TextLine takes kerning and advance width into account for letter spacing. Glyph locations are set starting at x=0 and appended in positive x direction.

type FontConfig

type FontConfig struct {
	// RelativeGlyphTolerance sets the permissible curve tolerance for glyphs. Must be between 0..1. If zero a reasonable value is chosen.
	RelativeGlyphTolerance float32
	Builder                *gsdf.Builder
}

Jump to

Keyboard shortcuts

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