gioui.org: gioui.org/text Index | Files

package text

import "gioui.org/text"

Index

Package Files

lru.go shaper.go text.go

type Alignment Uses

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

func (Alignment) String Uses

func (a Alignment) String() string

type Face Uses

type Face interface {
    Layout(ppem fixed.Int26_6, maxWidth int, txt io.Reader) ([]Line, error)
    Shape(ppem fixed.Int26_6, str []Glyph) op.CallOp
    Metrics(ppem fixed.Int26_6) font.Metrics
}

Face implements text layout and shaping for a particular font.

type Font Uses

type Font struct {
    Typeface Typeface
    Variant  Variant
    Style    Style
    // Weight is the text weight. If zero, Normal is used instead.
    Weight Weight
}

Font specify a particular typeface variant, style and weight.

type FontRegistry Uses

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

FontRegistry implements layout and shaping of text from a set of registered fonts.

If a font matches no registered shape, FontRegistry falls back to the first registered face.

The LayoutString and ShapeString results are cached and re-used if possible.

func (*FontRegistry) Layout Uses

func (s *FontRegistry) Layout(font Font, size fixed.Int26_6, maxWidth int, txt io.Reader) ([]Line, error)

func (*FontRegistry) LayoutString Uses

func (s *FontRegistry) LayoutString(font Font, size fixed.Int26_6, maxWidth int, str string) []Line

func (*FontRegistry) Metrics Uses

func (s *FontRegistry) Metrics(font Font, size fixed.Int26_6) font.Metrics

func (*FontRegistry) Register Uses

func (s *FontRegistry) Register(font Font, tf Face)

func (*FontRegistry) Shape Uses

func (s *FontRegistry) Shape(font Font, size fixed.Int26_6, layout []Glyph) op.CallOp

func (*FontRegistry) ShapeString Uses

func (s *FontRegistry) ShapeString(font Font, size fixed.Int26_6, str string, layout []Glyph) op.CallOp

type Glyph Uses

type Glyph struct {
    Rune    rune
    Advance fixed.Int26_6
}

type Line Uses

type Line struct {
    Layout []Glyph
    // Len is the length in UTF8 bytes of the line.
    Len int
    // Width is the width of the line.
    Width fixed.Int26_6
    // Ascent is the height above the baseline.
    Ascent fixed.Int26_6
    // Descent is the height below the baseline, including
    // the line gap.
    Descent fixed.Int26_6
    // Bounds is the visible bounds of the line.
    Bounds fixed.Rectangle26_6
}

A Line contains the measurements of a line of text.

type Shaper Uses

type Shaper interface {
    // Layout a text according to a set of options.
    Layout(font Font, size fixed.Int26_6, maxWidth int, txt io.Reader) ([]Line, error)
    // Shape a line of text and return a clipping operation for its outline.
    Shape(font Font, size fixed.Int26_6, layout []Glyph) op.CallOp

    // LayoutString is like Layout, but for strings..
    LayoutString(font Font, size fixed.Int26_6, maxWidth int, str string) []Line
    // ShapeString is like Shape for lines previously laid out by LayoutString.
    ShapeString(font Font, size fixed.Int26_6, str string, layout []Glyph) op.CallOp

    // Metrics returns the font metrics for font.
    Metrics(font Font, size fixed.Int26_6) font.Metrics
}

Shaper implements layout and shaping of text.

type Style Uses

type Style int

Style is the font style.

const (
    Regular Style = iota
    Italic
)

type Typeface Uses

type Typeface string

Typeface identifies a particular typeface design. The empty string denotes the default typeface.

type Variant Uses

type Variant string

Variant denotes a typeface variant such as "Mono" or "Smallcaps".

type Weight Uses

type Weight int

Weight is a font weight, in CSS units.

const (
    Normal Weight = 400
    Medium Weight = 500
    Bold   Weight = 600
)

Package text imports 5 packages (graph) and is imported by 32 packages. Updated 2020-05-27. Refresh now. Tools for package owners.