Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bounds ¶
type Bounds struct { // Ascent is the maximum ascent away from the baseline. This value is typically // positive in coordiate systems that grow up. Ascent fixed.Int26_6 // Descent is the maximum descent away from the baseline. This value is typically // negative in coordinate systems that grow up. Descent fixed.Int26_6 // Gap is the height of empty pixels between lines. This value is typically positive // in coordinate systems that grow up. Gap fixed.Int26_6 }
Bounds describes the minor-axis bounds of a line of text. In a LTR or RTL layout, it describes the vertical axis. In a BTT or TTB layout, it describes the horizontal.
For horizontal text:
- Ascent GLYPH | GLYPH | GLYPH | GLYPH | GLYPH
- Baseline GLYPH | GLYPH | GLYPH | GLYPH
- Descent GLYPH |
- Gap
func (Bounds) LineHeight ¶
LineHeight returns the height of a horizontal line of text described by b.
type Glyph ¶
type Glyph struct { Width fixed.Int26_6 Height fixed.Int26_6 XBearing fixed.Int26_6 YBearing fixed.Int26_6 XAdvance fixed.Int26_6 YAdvance fixed.Int26_6 XOffset fixed.Int26_6 YOffset fixed.Int26_6 Cluster int Glyph fonts.GID Mask harfbuzz.GlyphMask }
Glyph describes the attributes of a single glyph from a single font face in a shaped output.
func (Glyph) LeftSideBearing ¶
LeftSideBearing returns the distance from the glyph's X origin to its leftmost edge. This value can be negative if the glyph extends across the origin.
func (Glyph) RightSideBearing ¶
RightSideBearing returns the distance from the glyph's right edge to the edge of the glyph's advance. This value can be negative if the glyph's right edge is before the end of its advance.
type Input ¶
type Input struct { // Text is the body of text being shaped. Only the range Text[RunStart:RunEnd] is considered // for shaping, with the rest provided as context for the shaper. This helps with, for example, // cross-run Arabic shaping or handling combining marks at the start of a run. Text []rune // RunStart and RunEnd indicate the subslice of Text being shaped. RunStart, RunEnd int // Direction is the directionality of the text. Direction di.Direction // Face is the font face to render the text in. Face font.Face // Size is the requested size of the font. // More generally, it is a scale factor applied to the resulting metrics. // For instance, given a device resolution (in dpi) and a point size (like 14), the `Size` to // get result in pixels is given by : pointSize * dpi / 72 Size fixed.Int26_6 // Script is an identifier for the writing system used in the text. Script language.Script // Language is an identifier for the language of the text. Language language.Language }
type InvalidRunError ¶
type InvalidRunError struct {
RunStart, RunEnd, TextLength int
}
InvalidRunError represents an invalid run of text, either because the end is before the start or because start or end is greater than the length.
func (InvalidRunError) Error ¶
func (i InvalidRunError) Error() string
type MissingGlyphError ¶
MissingGlyphError indicates that the font used in shaping did not have a glyph needed to complete the shaping.
func (MissingGlyphError) Error ¶
func (m MissingGlyphError) Error() string
type Output ¶
type Output struct { // Advance is the distance the Dot has advanced. Advance fixed.Int26_6 // Glyphs are the shaped output text. Glyphs []Glyph // LineBounds describes the font's suggested line bounding dimensions. The // dimensions described should contain any glyphs from the given font. LineBounds Bounds // GlyphBounds describes a tight bounding box on the specific glyphs contained // within this output. The dimensions may not be sufficient to contain all // glyphs within the chosen font. GlyphBounds Bounds }
Output describes the dimensions and content of shaped text.
func (*Output) RecalculateAll ¶
RecalculateAll updates the all other fields of the Output to match the current contents of the Glyphs field. This method will fail with UnimplementedDirectionError if the provided direction is unimplemented.
func (*Output) RecomputeAdvance ¶
RecomputeAdvance updates only the Advance field based on the current contents of the Glyphs field. It is faster than RecalculateAll(), and can be used to speed up line wrapping logic.
type UnimplementedDirectionError ¶
UnimplementedDirectionError is returned when a function does not support the provided layout direction yet.
func (UnimplementedDirectionError) Error ¶
func (u UnimplementedDirectionError) Error() string
Error formats the error into a string message.