Documentation
¶
Index ¶
- type Alignment
- type Face
- type Font
- type FontRegistry
- func (s *FontRegistry) Layout(c unit.Converter, font Font, txt io.Reader, opts LayoutOptions) ([]Line, error)
- func (s *FontRegistry) LayoutString(c unit.Converter, font Font, str string, opts LayoutOptions) []Line
- func (s *FontRegistry) Metrics(c unit.Converter, font Font) font.Metrics
- func (s *FontRegistry) Register(font Font, tf Face)
- func (s *FontRegistry) Shape(c unit.Converter, font Font, layout []Glyph) op.CallOp
- func (s *FontRegistry) ShapeString(c unit.Converter, font Font, str string, layout []Glyph) op.CallOp
- type Glyph
- type LayoutOptions
- type Line
- type Shaper
- type Style
- type Typeface
- type Variant
- type Weight
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Face ¶
type Face interface {
Layout(ppem fixed.Int26_6, txt io.Reader, opts LayoutOptions) ([]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 ¶
type Font struct {
Typeface Typeface
Variant Variant
Size unit.Value
Style Style
// Weight is the text weight. If zero, Normal is used instead.
Weight Weight
}
Font specify a particular typeface, style and size.
type FontRegistry ¶
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 ¶
func (s *FontRegistry) Layout(c unit.Converter, font Font, txt io.Reader, opts LayoutOptions) ([]Line, error)
func (*FontRegistry) LayoutString ¶
func (s *FontRegistry) LayoutString(c unit.Converter, font Font, str string, opts LayoutOptions) []Line
func (*FontRegistry) Register ¶
func (s *FontRegistry) Register(font Font, tf Face)
func (*FontRegistry) ShapeString ¶
type LayoutOptions ¶
type LayoutOptions struct {
// MaxWidth is the available width of the layout.
MaxWidth int
}
LayoutOptions specify the constraints of a text layout.
type Line ¶
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 ¶
type Shaper interface {
// Layout a text according to a set of options.
Layout(c unit.Converter, font Font, txt io.Reader, opts LayoutOptions) ([]Line, error)
// Shape a line of text and return a clipping operation for its outline.
Shape(c unit.Converter, font Font, layout []Glyph) op.CallOp
// LayoutString is like Layout, but for strings..
LayoutString(c unit.Converter, font Font, str string, opts LayoutOptions) []Line
// ShapeString is like Shape for lines previously laid out by LayoutString.
ShapeString(c unit.Converter, font Font, str string, layout []Glyph) op.CallOp
// Metrics returns the font metrics for font.
Metrics(c unit.Converter, font Font) font.Metrics
}
Shaper implements layout and shaping of text.
type Typeface ¶
type Typeface string
Typeface identifies a particular typeface design. The empty string denotes the default typeface.
Click to show internal directories.
Click to hide internal directories.