text

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT, Unlicense Imports: 30 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alignment

type Alignment uint8
const (
	Start Alignment = iota
	End
	Middle
)

func (Alignment) Align

func (a Alignment) Align(dir system.TextDirection, width fixed.Int26_6, maxWidth int) fixed.Int26_6

func (Alignment) String

func (a Alignment) String() string

type Flags

type Flags uint16
const (
	FlagTowardOrigin Flags = 1 << iota

	FlagLineBreak

	FlagRunBreak

	FlagClusterBreak

	FlagParagraphBreak

	FlagParagraphStart

	FlagTruncator
)

func (Flags) String

func (f Flags) String() string

type FontFace

type FontFace = giofont.FontFace

type Glyph

type Glyph struct {
	ID GlyphID

	X fixed.Int26_6

	Y int32

	Advance fixed.Int26_6

	Ascent fixed.Int26_6

	Descent fixed.Int26_6

	Offset fixed.Point26_6

	Bounds fixed.Rectangle26_6

	Runes uint16

	Flags Flags
}

type GlyphID

type GlyphID uint64

type Parameters

type Parameters struct {
	Font giofont.Font

	Alignment Alignment

	PxPerEm fixed.Int26_6

	MaxLines int

	Truncator string

	WrapPolicy WrapPolicy

	MinWidth, MaxWidth int

	Locale system.Locale

	LineHeightScale float32

	LineHeight fixed.Int26_6

	DisableSpaceTrim bool
	// contains filtered or unexported fields
}

type Range

type Range struct {
	Count  int
	Offset int
}

type Shaper

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

func NewShaper

func NewShaper(options ...ShaperOption) *Shaper

func (*Shaper) Bitmaps

func (l *Shaper) Bitmaps(gs []Glyph) op.CallOp

func (*Shaper) Layout

func (l *Shaper) Layout(params Parameters, txt io.Reader)

func (*Shaper) LayoutString

func (l *Shaper) LayoutString(params Parameters, str string)

func (*Shaper) NextGlyph

func (l *Shaper) NextGlyph() (_ Glyph, ok bool)

func (*Shaper) ReleaseLayoutBuffers added in v1.1.0

func (l *Shaper) ReleaseLayoutBuffers()

ReleaseLayoutBuffers drops the per-shape document held inside the shaper after the last NextGlyph call. The next Layout/LayoutString call repopulates from scratch, so this is safe to invoke from the caller (e.g. the editor) once it has copied the glyphs it needs into its own index. For multi-MB texts this frees hundreds of MB that otherwise sit in Shaper.txt until the next shape.

func (*Shaper) ResetLayoutCache added in v1.1.0

func (l *Shaper) ResetLayoutCache()

ResetLayoutCache drops cached paragraph layouts. Useful when an editor is about to switch wrap modes or when a large text replaces the current one, so the document/glyph data captured for previous (text, width) keys can be reclaimed by the GC instead of waiting for LRU eviction.

func (*Shaper) Shape

func (l *Shaper) Shape(gs []Glyph) clip.PathSpec

type ShaperOption

type ShaperOption func(*Shaper)

func NoSystemFonts

func NoSystemFonts() ShaperOption

func WithCollection

func WithCollection(collection []FontFace) ShaperOption

type WrapPolicy

type WrapPolicy uint8
const (
	WrapHeuristically WrapPolicy = iota

	WrapWords

	WrapGraphemes
)

Jump to

Keyboard shortcuts

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