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

func (a Alignment) String() string

type Cache

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

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

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

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

    func NewCache

    func NewCache(collection []FontFace) *Cache

    func (*Cache) Layout

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

      Layout implements the Shaper interface.

      func (*Cache) LayoutString

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

        LayoutString is a caching implementation of the Shaper interface.

        func (*Cache) Shape

        func (s *Cache) Shape(font Font, size fixed.Int26_6, layout Layout) op.CallOp

          Shape is a caching implementation of the Shaper interface. Shape assumes that the layout argument is unchanged from a call to Layout or LayoutString.

          type Face

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

            Face implements text layout and shaping for a particular font. All methods must be safe for concurrent use.

            type Font

            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 FontFace

              type FontFace struct {
              	Font Font
              	Face Face
              }

                A FontFace is a Font and a matching Face.

                type Layout

                type Layout struct {
                	Text     string
                	Advances []fixed.Int26_6
                }

                type Line

                type Line struct {
                	Layout Layout
                	// 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

                  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)
                  	// LayoutString is Layout for strings.
                  	LayoutString(font Font, size fixed.Int26_6, maxWidth int, str string) []Line
                  	// Shape a line of text and return a clipping operation for its outline.
                  	Shape(font Font, size fixed.Int26_6, layout Layout) op.CallOp
                  }

                    Shaper implements layout and shaping of text.

                    type Style

                    type Style int

                      Style is the font style.

                      const (
                      	Regular Style = iota
                      	Italic
                      )

                      type Typeface

                      type Typeface string

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

                        type Variant

                        type Variant string

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

                          type Weight

                          type Weight int

                            Weight is a font weight, in CSS units subtracted 400 so the zero value is normal text weight.

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