Documentation ¶
Overview ¶
Package styledtext provides rendering of text containing multiple fonts and styles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Horizontal = _l.Horizontal Vertical = _l.Vertical Start = _l.Start End = _l.End Middle = _l.Middle Baseline = _l.Baseline SpaceSides = _l.SpaceSides SpaceStart = _l.SpaceStart SpaceEvenly = _l.SpaceEvenly SpaceAround = _l.SpaceAround SpaceBetween = _l.SpaceBetween SpaceEnd = _l.SpaceEnd )
var ( Exact = _l.Exact Pt = _i.Pt )
Functions ¶
This section is empty.
Types ¶
type Constraints ¶
type Constraints = _l.Constraints
type Dim ¶
type Dim = _l.Dimensions
type SpanStyle ¶
type SpanStyle struct { Font font.Font Size unit.Sp Color color.NRGBA Content string // contains filtered or unexported fields }
SpanStyle describes the appearance of a span of styled text.
type TextStyle ¶
type TextStyle struct { Styles []SpanStyle Alignment text.Alignment WrapPolicy WrapPolicy *text.Shaper }
TextStyle presents rich text.
func (TextStyle) Layout ¶
Layout renders the TextStyle.
The spanFn function, if not nil, gets called for each span after it has been drawn, with the offset set to the span's top left corner. This can be used to set up input handling, for example.
The context's maximum constraint is set to the span's dimensions, while the dims argument additionally provides the text's baseline. The idx argument is the span's index in TextStyle.Styles. The function may get called multiple times with the same index if a span has to be broken across multiple lines.
type WrapPolicy ¶
type WrapPolicy uint8
WrapPolicy defines line wrapping policies for styledtext. Due to complexities of the styledtext implementation, there are fewer options available than in widget.mleku.dev/text.WrapPolicy.
const ( // WrapWords implements behavior like [widget.mleku.dev/text/.WrapWords]. This is the default, // as it prevents words from being split across lines. WrapWords WrapPolicy = iota // WrapGraphemes implements behavior like [widget.mleku.dev/text/.WrapGraphemes]. This often gives // unpleasant results, as it will choose to split words across lines whenever it can. Some // use-cases may still want this, however. WrapGraphemes )