Documentation
¶
Overview ¶
Package text provides rich text styling and annotation capabilities.
Index ¶
- Variables
- func EqualParagraphStyle(a, b *ParagraphStyle) bool
- func EqualPlatformParagraphStyle(a, b *PlatformParagraphStyle) bool
- func EqualPlatformSpanStyle(a, b *PlatformSpanStyle) bool
- func EqualPlatformTextStyle(a, b *PlatformTextStyle) bool
- func EqualSpanStyle(a, b *SpanStyle) bool
- func EqualTextStyle(a, b *TextStyle) bool
- func IsSpecifiedParagraphStyle(s *ParagraphStyle) bool
- func IsSpecifiedPlatformParagraphStyle(s *PlatformParagraphStyle) bool
- func IsSpecifiedPlatformSpanStyle(s *PlatformSpanStyle) bool
- func IsSpecifiedPlatformTextStyle(s *PlatformTextStyle) bool
- func IsSpecifiedSpanStyle(s *SpanStyle) bool
- func IsSpecifiedTextStyle(style *TextStyle) bool
- func MapEachParagraphStyle[T any](as AnnotatedString, defaultParagraphStyle ParagraphStyle, ...) []T
- func SameParagraphStyle(a, b *ParagraphStyle) bool
- func SameSpanStyle(a, b *SpanStyle) bool
- func SameTextStyle(a, b *TextStyle) bool
- func SemanticEqualParagraphStyle(a, b *ParagraphStyle) bool
- func SemanticEqualSpanStyle(a, b *SpanStyle) bool
- func SemanticEqualTextStyle(a, b *TextStyle) bool
- func StringParagraphStyle(s *ParagraphStyle) string
- func StringPlatformParagraphStyle(s *PlatformParagraphStyle) string
- func StringSpanStyle(s *SpanStyle) string
- type AnnotatedString
- func (as AnnotatedString) Append(other AnnotatedString) AnnotatedString
- func (as AnnotatedString) Capitalize() AnnotatedString
- func (as AnnotatedString) CharAt(index int) byte
- func (as AnnotatedString) Decapitalize() AnnotatedString
- func (as AnnotatedString) FlatMapAnnotations(transform func(Range[Annotation]) []Range[Annotation]) AnnotatedString
- func (as AnnotatedString) GetLinkAnnotations(start, end int) []Range[LinkAnnotation]
- func (as AnnotatedString) GetLocalAnnotations(start, end int, predicate func(Annotation) bool) []Range[Annotation]
- func (as AnnotatedString) GetLocalParagraphStyles(start, end int) []Range[ParagraphStyle]
- func (as AnnotatedString) GetStringAnnotations(tag string, start, end int) []Range[string]
- func (as AnnotatedString) HasEqualAnnotations(other AnnotatedString) bool
- func (as AnnotatedString) HasInlineContent() bool
- func (as AnnotatedString) HasLinkAnnotations(start, end int) bool
- func (as AnnotatedString) HasLinks() bool
- func (as AnnotatedString) HasStringAnnotations(tag string, start, end int) bool
- func (as AnnotatedString) Len() int
- func (as AnnotatedString) MapAnnotations(transform func(Range[Annotation]) Range[Annotation]) AnnotatedString
- func (as AnnotatedString) NormalizedParagraphStyles(defaultParagraphStyle ParagraphStyle) []Range[ParagraphStyle]
- func (as AnnotatedString) ParagraphStyles() []Range[ParagraphStyle]
- func (as AnnotatedString) SpanStyles() []Range[SpanStyle]
- func (as AnnotatedString) String() string
- func (as AnnotatedString) SubSequence(start, end int) AnnotatedString
- func (as AnnotatedString) SubstringWithoutParagraphStyles(start, end int) AnnotatedString
- func (as AnnotatedString) Text() string
- func (as AnnotatedString) ToLower() AnnotatedString
- func (as AnnotatedString) ToUpper() AnnotatedString
- type Annotation
- type Builder
- func (b *Builder) AddBullet(bullet Bullet, start, end int)
- func (b *Builder) AddLink(link LinkAnnotation, start, end int)
- func (b *Builder) AddParagraphStyle(style ParagraphStyle, start, end int)
- func (b *Builder) AddStringAnnotation(tag, annotation string, start, end int)
- func (b *Builder) AddStyle(style SpanStyle, start, end int)
- func (b *Builder) AddTtsAnnotation(tts TtsAnnotation, start, end int)
- func (b *Builder) Append(s string)
- func (b *Builder) AppendAnnotatedString(as AnnotatedString)
- func (b *Builder) FlatMapAnnotations(transform func(Range[Annotation]) []Range[Annotation])
- func (b *Builder) Len() int
- func (b *Builder) MapAnnotations(transform func(Range[Annotation]) Range[Annotation])
- func (b *Builder) Pop()
- func (b *Builder) PopTo(index int)
- func (b *Builder) PushBullet(bullet Bullet) int
- func (b *Builder) PushLink(link LinkAnnotation) int
- func (b *Builder) PushParagraphStyle(style ParagraphStyle) int
- func (b *Builder) PushStringAnnotation(tag, annotation string) int
- func (b *Builder) PushStyle(style SpanStyle) int
- func (b *Builder) PushTtsAnnotation(tts TtsAnnotation) int
- func (b *Builder) ToAnnotatedString() AnnotatedString
- func (b *Builder) WithAnnotation(tag, annotation string, block func())
- func (b *Builder) WithBulletList(indentation unit.TextUnit, bullet Bullet, block func(*BulletScope))
- func (b *Builder) WithLink(link LinkAnnotation, block func())
- func (b *Builder) WithParagraphStyle(style ParagraphStyle, block func())
- func (b *Builder) WithStyle(style SpanStyle, block func())
- func (b *Builder) WithTtsAnnotation(tts TtsAnnotation, block func())
- type Bullet
- type BulletScope
- type LinkAnnotation
- type MultiParagraph
- type ParagraphStyle
- func CoalesceParagraphStyle(ptr, def *ParagraphStyle) *ParagraphStyle
- func LerpParagraphStyle(start, stop *ParagraphStyle, fraction float32) *ParagraphStyle
- func MergeParagraphStyle(a, b *ParagraphStyle) *ParagraphStyle
- func ParagraphStyleResolveDefaults(ps *ParagraphStyle, direction unit.LayoutDirection) *ParagraphStyle
- func ResolveParagraphStyleDefaults(s *ParagraphStyle, direction unit.LayoutDirection) *ParagraphStyle
- func TakeOrElseParagraphStyle(s, def *ParagraphStyle) *ParagraphStyle
- type ParagraphStyleOption
- func ParagraphStyleWithHyphens(hyphens style.Hyphens) ParagraphStyleOption
- func ParagraphStyleWithLineBreak(lineBreak style.LineBreak) ParagraphStyleOption
- func ParagraphStyleWithLineHeight(lineHeight unit.TextUnit) ParagraphStyleOption
- func ParagraphStyleWithLineHeightStyle(lineHeightStyle *style.LineHeightStyle) ParagraphStyleOption
- func ParagraphStyleWithPlatformStyle(platformStyle *PlatformParagraphStyle) ParagraphStyleOption
- func ParagraphStyleWithTextAlign(textAlign style.TextAlign) ParagraphStyleOption
- func ParagraphStyleWithTextDirection(textDirection style.TextDirection) ParagraphStyleOption
- func ParagraphStyleWithTextIndent(textIndent *style.TextIndent) ParagraphStyleOption
- func ParagraphStyleWithTextMotion(textMotion *style.TextMotion) ParagraphStyleOption
- type ParagraphStyleOptions
- type Placeholder
- type PlaceholderVerticalAlign
- type PlatformParagraphStyle
- type PlatformSpanStyle
- type PlatformTextStyle
- type Range
- type SpanStyle
- func CoalesceSpanStyle(ptr, def *SpanStyle) *SpanStyle
- func LerpSpanStyle(width, start, stop *SpanStyle, fraction float32) *SpanStyle
- func MergeSpanStyle(a, b *SpanStyle) *SpanStyle
- func ResolveSpanStyleDefaults(s *SpanStyle) *SpanStyle
- func SpanStyleResolveDefaults(ss *SpanStyle) *SpanStyle
- func TakeOrElseSpanStyle(s, def *SpanStyle) *SpanStyle
- type SpanStyleOption
- func SpanStyleWithBackground(background graphics.Color) SpanStyleOption
- func SpanStyleWithBaselineShift(baselineShift style.BaselineShift) SpanStyleOption
- func SpanStyleWithBrush(brush graphics.Brush, alpha float32) SpanStyleOption
- func SpanStyleWithColor(color graphics.Color) SpanStyleOption
- func SpanStyleWithDrawStyle(drawStyle graphics.DrawStyle) SpanStyleOption
- func SpanStyleWithFontFamily(fontFamily font.FontFamily) SpanStyleOption
- func SpanStyleWithFontFeatureSettings(fontFeatureSettings string) SpanStyleOption
- func SpanStyleWithFontSize(fontSize unit.TextUnit) SpanStyleOption
- func SpanStyleWithFontStyle(fontStyle font.FontStyle) SpanStyleOption
- func SpanStyleWithFontSynthesis(fontSynthesis *font.FontSynthesis) SpanStyleOption
- func SpanStyleWithFontWeight(fontWeight font.FontWeight) SpanStyleOption
- func SpanStyleWithLetterSpacing(letterSpacing unit.TextUnit) SpanStyleOption
- func SpanStyleWithLocaleList(localeList *intl.LocaleList) SpanStyleOption
- func SpanStyleWithPlatformStyle(platformStyle *PlatformSpanStyle) SpanStyleOption
- func SpanStyleWithShadow(shadow *graphics.Shadow) SpanStyleOption
- func SpanStyleWithTextDecoration(textDecoration *style.TextDecoration) SpanStyleOption
- func SpanStyleWithTextGeometricTransform(textGeometricTransform *style.TextGeometricTransform) SpanStyleOption
- type SpanStyleOptions
- type StringAnnotation
- type TextLayoutInput
- type TextLayoutResult
- func (r TextLayoutResult) Copy(layoutInput *TextLayoutInput, size *unit.IntSize) TextLayoutResult
- func (r TextLayoutResult) DidOverflowHeight() bool
- func (r TextLayoutResult) DidOverflowWidth() bool
- func (r TextLayoutResult) Equals(other TextLayoutResult) bool
- func (r TextLayoutResult) FirstBaseline() float32
- func (r TextLayoutResult) GetBidiRunDirection(offset int) style.ResolvedTextDirection
- func (r TextLayoutResult) GetBoundingBox(offset int) geometry.Rect
- func (r TextLayoutResult) GetCursorRect(offset int) geometry.Rect
- func (r TextLayoutResult) GetHorizontalPosition(offset int, usePrimaryDirection bool) float32
- func (r TextLayoutResult) GetLineBaseline(lineIndex int) float32
- func (r TextLayoutResult) GetLineBottom(lineIndex int) float32
- func (r TextLayoutResult) GetLineEnd(lineIndex int, visibleEnd bool) int
- func (r TextLayoutResult) GetLineForOffset(offset int) int
- func (r TextLayoutResult) GetLineForVerticalPosition(vertical float32) int
- func (r TextLayoutResult) GetLineLeft(lineIndex int) float32
- func (r TextLayoutResult) GetLineRight(lineIndex int) float32
- func (r TextLayoutResult) GetLineStart(lineIndex int) int
- func (r TextLayoutResult) GetLineTop(lineIndex int) float32
- func (r TextLayoutResult) GetOffsetForPosition(position geometry.Offset) int
- func (r TextLayoutResult) GetParagraphDirection(offset int) style.ResolvedTextDirection
- func (r TextLayoutResult) GetPathForRange(start, end int) graphics.Path
- func (r TextLayoutResult) GetWordBoundary(offset int) TextRange
- func (r TextLayoutResult) HasVisualOverflow() bool
- func (r TextLayoutResult) IsLineEllipsized(lineIndex int) bool
- func (r TextLayoutResult) LastBaseline() float32
- func (r TextLayoutResult) LayoutInput() TextLayoutInput
- func (r TextLayoutResult) LineCount() int
- func (r TextLayoutResult) MultiParagraph() MultiParagraph
- func (r TextLayoutResult) PlaceholderRects() []*geometry.Rect
- func (r TextLayoutResult) Size() unit.IntSize
- func (r TextLayoutResult) String() string
- type TextRange
- func (r TextRange) CoerceIn(minimumValue, maximumValue int) TextRange
- func (r TextRange) Collapsed() bool
- func (r TextRange) Contains(other TextRange) bool
- func (r TextRange) ContainsOffset(offset int) bool
- func (r TextRange) Equals(other TextRange) bool
- func (r TextRange) Intersects(other TextRange) bool
- func (r TextRange) Length() int
- func (r TextRange) Max() int
- func (r TextRange) Min() int
- func (r TextRange) Reversed() bool
- func (r TextRange) String() string
- func (r TextRange) Substring(s string) string
- type TextShaper
- type TextStyle
- func (ts TextStyle) Alpha() float32
- func (ts TextStyle) Background() graphics.Color
- func (ts TextStyle) BaselineShift() style.BaselineShift
- func (ts TextStyle) Brush() graphics.Brush
- func (ts TextStyle) Color() graphics.Color
- func (ts TextStyle) Copy() *TextStyle
- func (ts TextStyle) DrawStyle() graphics.DrawStyle
- func (ts TextStyle) FontFamily() font.FontFamily
- func (ts TextStyle) FontFeatureSettings() string
- func (ts TextStyle) FontSize() unit.TextUnit
- func (ts TextStyle) FontStyle() font.FontStyle
- func (ts TextStyle) FontSynthesis() *font.FontSynthesis
- func (ts TextStyle) FontWeight() font.FontWeight
- func (ts TextStyle) Hyphens() style.Hyphens
- func (ts TextStyle) LetterSpacing() unit.TextUnit
- func (ts TextStyle) LineBreak() style.LineBreak
- func (ts TextStyle) LineHeight() unit.TextUnit
- func (ts TextStyle) LineHeightStyle() *style.LineHeightStyle
- func (ts TextStyle) LocaleList() *intl.LocaleList
- func (ts TextStyle) MergeParagraphStyle(other *ParagraphStyle) *TextStyle
- func (ts TextStyle) MergeSpanStyle(other *SpanStyle) *TextStyle
- func (ts *TextStyle) Plus(other *TextStyle) *TextStyle
- func (ts TextStyle) PlusParagraphStyle(other *ParagraphStyle) *TextStyle
- func (ts TextStyle) PlusSpanStyle(other *SpanStyle) *TextStyle
- func (ts TextStyle) Shadow() *graphics.Shadow
- func (ts TextStyle) TextAlign() style.TextAlign
- func (ts TextStyle) TextDecoration() *style.TextDecoration
- func (ts TextStyle) TextDirection() style.TextDirection
- func (ts TextStyle) TextGeometricTransform() *style.TextGeometricTransform
- func (ts TextStyle) TextIndent() *style.TextIndent
- func (ts TextStyle) TextMotion() *style.TextMotion
- func (ts TextStyle) ToParagraphStyle() *ParagraphStyle
- func (ts TextStyle) ToPlatformTextStyle() *PlatformTextStyle
- func (ts TextStyle) ToSpanStyle() *SpanStyle
- func (s TextStyle) ToString() string
- type TextStyleInterface
- type TtsAnnotation
Constants ¶
This section is empty.
Variables ¶
var DefaultBackgroundColor = graphics.ColorTransparent
var DefaultColor = graphics.ColorBlack
var DefaultColorForegroundStyle = style.TextForegroundStyleFromColor(DefaultColor)
var DefaultFontSize = unit.Sp(14)
var DefaultHyphens = style.HyphensNone
var DefaultLetterSpacing = unit.Sp(0)
var DefaultLineBreak = style.LineBreakParagraph
var DefaultLineHeight = unit.TextUnitUnspecified // TODO: Should this stay unspecified ?
var DefaultTextAlign = style.TextAlignStart
var DefaultTextIndent = style.TextIndentNone
var DefaultTextMotion = style.TextMotionStatic
var TextRangeZero = TextRange{Start: 0, End: 0}
TextRangeZero is a TextRange with both start and end at 0.
Functions ¶
func EqualParagraphStyle ¶
func EqualParagraphStyle(a, b *ParagraphStyle) bool
func EqualPlatformParagraphStyle ¶
func EqualPlatformParagraphStyle(a, b *PlatformParagraphStyle) bool
func EqualPlatformSpanStyle ¶
func EqualPlatformSpanStyle(a, b *PlatformSpanStyle) bool
func EqualPlatformTextStyle ¶
func EqualPlatformTextStyle(a, b *PlatformTextStyle) bool
func EqualSpanStyle ¶
func EqualTextStyle ¶
func IsSpecifiedParagraphStyle ¶
func IsSpecifiedParagraphStyle(s *ParagraphStyle) bool
func IsSpecifiedPlatformParagraphStyle ¶
func IsSpecifiedPlatformParagraphStyle(s *PlatformParagraphStyle) bool
func IsSpecifiedPlatformSpanStyle ¶
func IsSpecifiedPlatformSpanStyle(s *PlatformSpanStyle) bool
func IsSpecifiedPlatformTextStyle ¶
func IsSpecifiedPlatformTextStyle(s *PlatformTextStyle) bool
func IsSpecifiedSpanStyle ¶
func IsSpecifiedTextStyle ¶
func MapEachParagraphStyle ¶
func MapEachParagraphStyle[T any]( as AnnotatedString, defaultParagraphStyle ParagraphStyle, block func(annotatedString AnnotatedString, paragraphStyle Range[ParagraphStyle]) T, ) []T
MapEachParagraphStyle iterates normalized paragraph styles.
func SemanticEqualParagraphStyle ¶
func SemanticEqualParagraphStyle(a, b *ParagraphStyle) bool
Semantic equality (field-by-field, 20 ns)
func SemanticEqualSpanStyle ¶
Semantic equality (field-by-field, 20 ns)
func SemanticEqualTextStyle ¶
Semantic equality (field-by-field, 20 ns)
func StringParagraphStyle ¶
func StringParagraphStyle(s *ParagraphStyle) string
func StringPlatformParagraphStyle ¶
func StringPlatformParagraphStyle(s *PlatformParagraphStyle) string
func StringSpanStyle ¶
Types ¶
type AnnotatedString ¶
type AnnotatedString struct {
// contains filtered or unexported fields
}
AnnotatedString is immutable text with style and metadata annotations. Use Builder to construct instances efficiently.
func NewAnnotatedString ¶
func NewAnnotatedString(text string, spanStyles []Range[SpanStyle], paragraphStyles []Range[ParagraphStyle]) AnnotatedString
NewAnnotatedString creates an AnnotatedString from text and optional style ranges.
func (AnnotatedString) Append ¶
func (as AnnotatedString) Append(other AnnotatedString) AnnotatedString
Append concatenates another AnnotatedString.
func (AnnotatedString) Capitalize ¶
func (as AnnotatedString) Capitalize() AnnotatedString
Capitalize returns a new AnnotatedString with the first character capitalized.
func (AnnotatedString) CharAt ¶
func (as AnnotatedString) CharAt(index int) byte
CharAt returns the byte at index (useful for ASCII).
func (AnnotatedString) Decapitalize ¶
func (as AnnotatedString) Decapitalize() AnnotatedString
Decapitalize returns a new AnnotatedString with the first character lowercased.
func (AnnotatedString) FlatMapAnnotations ¶
func (as AnnotatedString) FlatMapAnnotations(transform func(Range[Annotation]) []Range[Annotation]) AnnotatedString
FlatMapAnnotations returns a new AnnotatedString with annotations transformed to multiple annotations.
func (AnnotatedString) GetLinkAnnotations ¶
func (as AnnotatedString) GetLinkAnnotations(start, end int) []Range[LinkAnnotation]
GetLinkAnnotations queries LinkAnnotations within [start, end).
func (AnnotatedString) GetLocalAnnotations ¶
func (as AnnotatedString) GetLocalAnnotations(start, end int, predicate func(Annotation) bool) []Range[Annotation]
GetLocalAnnotations finds annotations in range matching predicate and converts to local range.
func (AnnotatedString) GetLocalParagraphStyles ¶
func (as AnnotatedString) GetLocalParagraphStyles(start, end int) []Range[ParagraphStyle]
GetLocalParagraphStyles finds ParagraphStyles in range and converts them to local range.
func (AnnotatedString) GetStringAnnotations ¶
func (as AnnotatedString) GetStringAnnotations(tag string, start, end int) []Range[string]
GetStringAnnotations queries string annotations by tag within [start, end).
func (AnnotatedString) HasEqualAnnotations ¶
func (as AnnotatedString) HasEqualAnnotations(other AnnotatedString) bool
HasEqualAnnotations compares annotation lists for deep equality.
func (AnnotatedString) HasInlineContent ¶
func (as AnnotatedString) HasInlineContent() bool
func (AnnotatedString) HasLinkAnnotations ¶
func (as AnnotatedString) HasLinkAnnotations(start, end int) bool
HasLinkAnnotations checks if any link annotations exist in range.
func (AnnotatedString) HasLinks ¶
func (as AnnotatedString) HasLinks() bool
func (AnnotatedString) HasStringAnnotations ¶
func (as AnnotatedString) HasStringAnnotations(tag string, start, end int) bool
HasStringAnnotations checks if any string annotations with tag exist in range.
func (AnnotatedString) Len ¶
func (as AnnotatedString) Len() int
Len returns the length of the text.
func (AnnotatedString) MapAnnotations ¶
func (as AnnotatedString) MapAnnotations(transform func(Range[Annotation]) Range[Annotation]) AnnotatedString
MapAnnotations returns a new AnnotatedString with annotations transformed.
func (AnnotatedString) NormalizedParagraphStyles ¶
func (as AnnotatedString) NormalizedParagraphStyles(defaultParagraphStyle ParagraphStyle) []Range[ParagraphStyle]
NormalizedParagraphStyles determines the paragraph boundaries and merges styles. It handles gaps (using defaultParagraphStyle) and nested paragraphs.
func (AnnotatedString) ParagraphStyles ¶
func (as AnnotatedString) ParagraphStyles() []Range[ParagraphStyle]
ParagraphStyles returns all ParagraphStyle ranges (may be empty slice).
func (AnnotatedString) SpanStyles ¶
func (as AnnotatedString) SpanStyles() []Range[SpanStyle]
SpanStyles returns all SpanStyle ranges (may be empty slice).
func (AnnotatedString) String ¶
func (as AnnotatedString) String() string
String returns the plain text (implements fmt.Stringer).
func (AnnotatedString) SubSequence ¶
func (as AnnotatedString) SubSequence(start, end int) AnnotatedString
SubSequence returns a substring with annotations in range [start, end).
func (AnnotatedString) SubstringWithoutParagraphStyles ¶
func (as AnnotatedString) SubstringWithoutParagraphStyles(start, end int) AnnotatedString
SubstringWithoutParagraphStyles returns a substring without paragraph styles.
func (AnnotatedString) ToLower ¶
func (as AnnotatedString) ToLower() AnnotatedString
ToLower returns a new AnnotatedString with text converted to lowercase.
func (AnnotatedString) ToUpper ¶
func (as AnnotatedString) ToUpper() AnnotatedString
ToUpper returns a new AnnotatedString with text converted to uppercase.
type Annotation ¶
type Annotation interface {
// contains filtered or unexported methods
}
Annotation is a marker interface for all annotation types.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs AnnotatedString instances.
func NewBuilder ¶
NewBuilder creates a Builder with optional initial capacity.
func NewBuilderFromAnnotatedString ¶
func NewBuilderFromAnnotatedString(as AnnotatedString) *Builder
NewBuilderFromAnnotatedString creates a Builder initialized with the given AnnotatedString.
func (*Builder) AddLink ¶
func (b *Builder) AddLink(link LinkAnnotation, start, end int)
AddLink adds a LinkAnnotation to range [start, end).
func (*Builder) AddParagraphStyle ¶
func (b *Builder) AddParagraphStyle(style ParagraphStyle, start, end int)
AddParagraphStyle adds a ParagraphStyle to range [start, end).
func (*Builder) AddStringAnnotation ¶
AddStringAnnotation adds a string annotation with a tag.
func (*Builder) AddTtsAnnotation ¶
func (b *Builder) AddTtsAnnotation(tts TtsAnnotation, start, end int)
AddTtsAnnotation adds a TtsAnnotation to range [start, end).
func (*Builder) AppendAnnotatedString ¶
func (b *Builder) AppendAnnotatedString(as AnnotatedString)
AppendAnnotatedString adds another AnnotatedString with offset annotations.
func (*Builder) FlatMapAnnotations ¶
func (b *Builder) FlatMapAnnotations(transform func(Range[Annotation]) []Range[Annotation])
FlatMapAnnotations transforms annotations into multiple annotations.
func (*Builder) MapAnnotations ¶
func (b *Builder) MapAnnotations(transform func(Range[Annotation]) Range[Annotation])
MapAnnotations transforms annotations in the builder.
func (*Builder) PushBullet ¶
PushBullet pushes a Bullet annotation onto the stack.
func (*Builder) PushLink ¶
func (b *Builder) PushLink(link LinkAnnotation) int
PushLink pushes a LinkAnnotation onto the stack.
func (*Builder) PushParagraphStyle ¶
func (b *Builder) PushParagraphStyle(style ParagraphStyle) int
PushParagraphStyle pushes a ParagraphStyle onto the stack.
func (*Builder) PushStringAnnotation ¶
PushStringAnnotation pushes a string annotation onto the stack.
func (*Builder) PushTtsAnnotation ¶
func (b *Builder) PushTtsAnnotation(tts TtsAnnotation) int
PushTtsAnnotation pushes a TtsAnnotation onto the stack.
func (*Builder) ToAnnotatedString ¶
func (b *Builder) ToAnnotatedString() AnnotatedString
ToAnnotatedString builds the final immutable AnnotatedString.
func (*Builder) WithAnnotation ¶
WithAnnotation pushes annotation, executes block, and pops.
func (*Builder) WithBulletList ¶
func (b *Builder) WithBulletList( indentation unit.TextUnit, bullet Bullet, block func(*BulletScope), )
WithBulletList creates a bullet list scope.
func (*Builder) WithLink ¶
func (b *Builder) WithLink(link LinkAnnotation, block func())
WithLink pushes link annotation, executes block, and pops.
func (*Builder) WithParagraphStyle ¶
func (b *Builder) WithParagraphStyle(style ParagraphStyle, block func())
WithParagraphStyle pushes paragraph style, executes block, and pops.
func (*Builder) WithTtsAnnotation ¶
func (b *Builder) WithTtsAnnotation(tts TtsAnnotation, block func())
WithTtsAnnotation pushes tts annotation, executes block, and pops.
type BulletScope ¶
type BulletScope struct {
// contains filtered or unexported fields
}
BulletScope is the scope for a bullet list.
func (*BulletScope) WithBulletListItem ¶
func (s *BulletScope) WithBulletListItem( bullet *Bullet, block func(), )
WithBulletListItem adds a bullet list item.
type LinkAnnotation ¶
type LinkAnnotation struct {
URL string
}
LinkAnnotation marks clickable links in text.
type MultiParagraph ¶
type MultiParagraph interface {
// LineCount returns the number of lines in the text layout.
LineCount() int
// IsLineEllipsized returns true if the given line is ellipsized.
IsLineEllipsized(lineIndex int) bool
// DidExceedMaxLines returns true if the text exceeded the maximum number of lines.
DidExceedMaxLines() bool
// FirstBaseline returns the distance from the top to the alphabetic baseline of the first line.
FirstBaseline() float32
// LastBaseline returns the distance from the top to the alphabetic baseline of the last line.
LastBaseline() float32
// Height returns the total height of the text layout.
Height() float32
// Width returns the total width of the text layout.
Width() float32
// PlaceholderRects returns bounding boxes for placeholders.
PlaceholderRects() []*geometry.Rect
// GetLineStart returns the start offset of the given line, inclusive.
GetLineStart(lineIndex int) int
// GetLineEnd returns the end offset of the given line.
// If visibleEnd is true, trailing whitespaces are not counted.
GetLineEnd(lineIndex int, visibleEnd bool) int
// GetLineTop returns the top y coordinate of the given line.
GetLineTop(lineIndex int) float32
// GetLineBaseline returns the baseline y coordinate of the given line.
GetLineBaseline(lineIndex int) float32
// GetLineBottom returns the bottom y coordinate of the given line.
GetLineBottom(lineIndex int) float32
// GetLineLeft returns the left x coordinate of the given line.
GetLineLeft(lineIndex int) float32
// GetLineRight returns the right x coordinate of the given line.
GetLineRight(lineIndex int) float32
// GetLineForOffset returns the line number for the specified text offset.
GetLineForOffset(offset int) int
// GetLineForVerticalPosition returns the line number closest to the given vertical position.
GetLineForVerticalPosition(vertical float32) int
// GetHorizontalPosition returns the horizontal position for the specified text offset.
GetHorizontalPosition(offset int, usePrimaryDirection bool) float32
// GetParagraphDirection returns the text direction of the paragraph containing the offset.
GetParagraphDirection(offset int) style.ResolvedTextDirection
// GetBidiRunDirection returns the text direction of the BiDi run at the offset.
GetBidiRunDirection(offset int) style.ResolvedTextDirection
// GetOffsetForPosition returns the character offset closest to the given graphical position.
GetOffsetForPosition(position geometry.Offset) int
// GetBoundingBox returns the bounding box of the character at the given offset.
GetBoundingBox(offset int) geometry.Rect
// GetWordBoundary returns the text range of the word at the given offset.
GetWordBoundary(offset int) TextRange
// GetCursorRect returns the rectangle of the cursor area at the given offset.
GetCursorRect(offset int) geometry.Rect
// GetPathForRange returns a path that encloses the given text range.
GetPathForRange(start, end int) graphics.Path
}
MultiParagraph is the interface for multi-paragraph text layout.
type ParagraphStyle ¶
type ParagraphStyle struct {
TextAlign style.TextAlign
TextDirection style.TextDirection
LineHeight unit.TextUnit
TextIndent *style.TextIndent
PlatformStyle *PlatformParagraphStyle
LineHeightStyle *style.LineHeightStyle
LineBreak style.LineBreak
Hyphens style.Hyphens
TextMotion *style.TextMotion
}
ParagraphStyle configuration for a paragraph.
var ParagraphStyleUnspecified *ParagraphStyle = &ParagraphStyle{ TextAlign: style.TextAlignUnspecified, TextDirection: style.TextDirectionUnspecified, LineHeight: unit.TextUnitUnspecified, TextIndent: nil, LineHeightStyle: nil, LineBreak: style.LineBreakUnspecified, Hyphens: style.HyphensUnspecified, TextMotion: nil, }
func CoalesceParagraphStyle ¶
func CoalesceParagraphStyle(ptr, def *ParagraphStyle) *ParagraphStyle
func LerpParagraphStyle ¶
func LerpParagraphStyle(start, stop *ParagraphStyle, fraction float32) *ParagraphStyle
LerpParagraphStyle interpolates between two ParagraphStyles.
func MergeParagraphStyle ¶
func MergeParagraphStyle(a, b *ParagraphStyle) *ParagraphStyle
func ParagraphStyleResolveDefaults ¶
func ParagraphStyleResolveDefaults(ps *ParagraphStyle, direction unit.LayoutDirection) *ParagraphStyle
func ResolveParagraphStyleDefaults ¶
func ResolveParagraphStyleDefaults(s *ParagraphStyle, direction unit.LayoutDirection) *ParagraphStyle
func TakeOrElseParagraphStyle ¶
func TakeOrElseParagraphStyle(s, def *ParagraphStyle) *ParagraphStyle
func (ParagraphStyle) Copy ¶
func (s ParagraphStyle) Copy(options ...ParagraphStyleOption) *ParagraphStyle
type ParagraphStyleOption ¶
type ParagraphStyleOption = func(*ParagraphStyleOptions)
func ParagraphStyleWithHyphens ¶
func ParagraphStyleWithHyphens(hyphens style.Hyphens) ParagraphStyleOption
func ParagraphStyleWithLineBreak ¶
func ParagraphStyleWithLineBreak(lineBreak style.LineBreak) ParagraphStyleOption
func ParagraphStyleWithLineHeight ¶
func ParagraphStyleWithLineHeight(lineHeight unit.TextUnit) ParagraphStyleOption
func ParagraphStyleWithLineHeightStyle ¶
func ParagraphStyleWithLineHeightStyle(lineHeightStyle *style.LineHeightStyle) ParagraphStyleOption
func ParagraphStyleWithPlatformStyle ¶
func ParagraphStyleWithPlatformStyle(platformStyle *PlatformParagraphStyle) ParagraphStyleOption
func ParagraphStyleWithTextAlign ¶
func ParagraphStyleWithTextAlign(textAlign style.TextAlign) ParagraphStyleOption
func ParagraphStyleWithTextDirection ¶
func ParagraphStyleWithTextDirection(textDirection style.TextDirection) ParagraphStyleOption
func ParagraphStyleWithTextIndent ¶
func ParagraphStyleWithTextIndent(textIndent *style.TextIndent) ParagraphStyleOption
func ParagraphStyleWithTextMotion ¶
func ParagraphStyleWithTextMotion(textMotion *style.TextMotion) ParagraphStyleOption
type ParagraphStyleOptions ¶
type ParagraphStyleOptions struct {
TextAlign style.TextAlign
TextDirection style.TextDirection
LineHeight unit.TextUnit
TextIndent *style.TextIndent
PlatformStyle *PlatformParagraphStyle
LineHeightStyle *style.LineHeightStyle
LineBreak style.LineBreak
Hyphens style.Hyphens
TextMotion *style.TextMotion
}
type Placeholder ¶
type Placeholder struct {
// Width of the placeholder, must be specified in sp or em.
Width unit.TextUnit
// Height of the placeholder, must be specified in sp or em.
Height unit.TextUnit
// PlaceholderVerticalAlign specifies the vertical alignment of the placeholder within the text line.
PlaceholderVerticalAlign PlaceholderVerticalAlign
}
Placeholder is a rectangle box inserted into text, which tells the text processor to leave an empty space. It is typically used to insert inline images, custom emojis, etc. into the text paragraph.
func NewPlaceholder ¶
func NewPlaceholder(width, height unit.TextUnit, placeholderVerticalAlign PlaceholderVerticalAlign) Placeholder
NewPlaceholder creates a new Placeholder with validation. Panics if width or height is unspecified.
func (Placeholder) Copy ¶
func (p Placeholder) Copy(width, height unit.TextUnit, placeholderVerticalAlign PlaceholderVerticalAlign) Placeholder
Copy creates a copy of the Placeholder with optional field overrides.
func (Placeholder) Equals ¶
func (p Placeholder) Equals(other Placeholder) bool
Equals checks equality with another Placeholder.
func (Placeholder) String ¶
func (p Placeholder) String() string
String returns a string representation of the Placeholder.
type PlaceholderVerticalAlign ¶
type PlaceholderVerticalAlign int
PlaceholderVerticalAlign specifies how a placeholder is vertically aligned within a text line.
const ( // PlaceholderVerticalAlignAboveBaseline aligns the bottom of the placeholder with the baseline. PlaceholderVerticalAlignAboveBaseline PlaceholderVerticalAlign = iota + 1 // PlaceholderVerticalAlignTop aligns the top of the placeholder with the top of the entire line. PlaceholderVerticalAlignTop // PlaceholderVerticalAlignBottom aligns the bottom of the placeholder with the bottom of the entire line. PlaceholderVerticalAlignBottom // PlaceholderVerticalAlignCenter aligns the center of the placeholder with the center of the entire line. PlaceholderVerticalAlignCenter // PlaceholderVerticalAlignTextTop aligns the top of the placeholder with the top of the proceeding text. // Different from Top when there are texts with different font sizes in the same line. PlaceholderVerticalAlignTextTop // PlaceholderVerticalAlignTextBottom aligns the bottom of the placeholder with the bottom of the proceeding text. // Different from Bottom when there are texts with different font sizes in the same line. PlaceholderVerticalAlignTextBottom // PlaceholderVerticalAlignTextCenter aligns the center of the placeholder with the center of the proceeding text. // Different from Center when there are texts with different font sizes in the same line. PlaceholderVerticalAlignTextCenter )
func (PlaceholderVerticalAlign) String ¶
func (p PlaceholderVerticalAlign) String() string
String returns the string representation of the PlaceholderVerticalAlign.
type PlatformParagraphStyle ¶
type PlatformParagraphStyle struct {
}
PlatformParagraphStyle contains platform-specific paragraph styling.
var PlatformParagraphStyleUnspecified *PlatformParagraphStyle = &PlatformParagraphStyle{}
func TakeOrElsePlatformParagraphStyle ¶
func TakeOrElsePlatformParagraphStyle(s, def *PlatformParagraphStyle) *PlatformParagraphStyle
type PlatformSpanStyle ¶
type PlatformSpanStyle struct {
}
PlatformSpanStyle contains platform-specific text styling.
var PlatformSpanStyleUnspecified *PlatformSpanStyle = &PlatformSpanStyle{}
func LerpPlatformSpanStyle ¶
func LerpPlatformSpanStyle(start, stop *PlatformSpanStyle, fraction float32) *PlatformSpanStyle
func TakeOrElsePlatformSpanStyle ¶
func TakeOrElsePlatformSpanStyle(s, def *PlatformSpanStyle) *PlatformSpanStyle
type PlatformTextStyle ¶
type PlatformTextStyle struct {
SpanStyle *PlatformSpanStyle
ParagraphStyle *PlatformParagraphStyle
}
PlatformTextStyle contains platform-specific text styling combining span and paragraph styles.
var PlatformTextStyleUnspecified *PlatformTextStyle = &PlatformTextStyle{ SpanStyle: PlatformSpanStyleUnspecified, ParagraphStyle: PlatformParagraphStyleUnspecified, }
func TakeOrElsePlatformTextStyle ¶
func TakeOrElsePlatformTextStyle(s, def *PlatformTextStyle) *PlatformTextStyle
type Range ¶
Range represents an annotation applied to a half-open range [Start, End).
type SpanStyle ¶
type SpanStyle struct {
FontSize unit.TextUnit
FontWeight font.FontWeight
FontStyle font.FontStyle
FontSynthesis *font.FontSynthesis
FontFamily font.FontFamily
FontFeatureSettings string
LetterSpacing unit.TextUnit
BaselineShift style.BaselineShift
TextGeometricTransform *style.TextGeometricTransform
LocaleList *intl.LocaleList
Background graphics.Color
TextDecoration *style.TextDecoration
Shadow *graphics.Shadow
PlatformStyle *PlatformSpanStyle
DrawStyle graphics.DrawStyle
// contains filtered or unexported fields
}
var SpanStyleUnspecified *SpanStyle = &SpanStyle{ textForegroundStyle: nil, FontSize: unit.TextUnitUnspecified, FontWeight: font.FontWeightUnspecified, FontStyle: font.FontStyleUnspecified, FontSynthesis: nil, FontFamily: nil, FontFeatureSettings: "", LetterSpacing: unit.TextUnitUnspecified, BaselineShift: style.BaselineShiftUnspecified, TextGeometricTransform: nil, LocaleList: nil, Background: graphics.ColorUnspecified, TextDecoration: nil, Shadow: nil, PlatformStyle: nil, DrawStyle: nil, }
func CoalesceSpanStyle ¶
func LerpSpanStyle ¶
func MergeSpanStyle ¶
func TakeOrElseSpanStyle ¶
func (SpanStyle) Copy ¶
func (s SpanStyle) Copy(options ...SpanStyleOption) *SpanStyle
type SpanStyleOption ¶
type SpanStyleOption = func(*SpanStyleOptions)
func SpanStyleWithBackground ¶
func SpanStyleWithBackground(background graphics.Color) SpanStyleOption
func SpanStyleWithBaselineShift ¶
func SpanStyleWithBaselineShift(baselineShift style.BaselineShift) SpanStyleOption
func SpanStyleWithBrush ¶
func SpanStyleWithBrush(brush graphics.Brush, alpha float32) SpanStyleOption
func SpanStyleWithColor ¶
func SpanStyleWithColor(color graphics.Color) SpanStyleOption
func SpanStyleWithDrawStyle ¶
func SpanStyleWithDrawStyle(drawStyle graphics.DrawStyle) SpanStyleOption
func SpanStyleWithFontFamily ¶
func SpanStyleWithFontFamily(fontFamily font.FontFamily) SpanStyleOption
func SpanStyleWithFontFeatureSettings ¶
func SpanStyleWithFontFeatureSettings(fontFeatureSettings string) SpanStyleOption
func SpanStyleWithFontSize ¶
func SpanStyleWithFontSize(fontSize unit.TextUnit) SpanStyleOption
func SpanStyleWithFontStyle ¶
func SpanStyleWithFontStyle(fontStyle font.FontStyle) SpanStyleOption
func SpanStyleWithFontSynthesis ¶
func SpanStyleWithFontSynthesis(fontSynthesis *font.FontSynthesis) SpanStyleOption
func SpanStyleWithFontWeight ¶
func SpanStyleWithFontWeight(fontWeight font.FontWeight) SpanStyleOption
func SpanStyleWithLetterSpacing ¶
func SpanStyleWithLetterSpacing(letterSpacing unit.TextUnit) SpanStyleOption
func SpanStyleWithLocaleList ¶
func SpanStyleWithLocaleList(localeList *intl.LocaleList) SpanStyleOption
func SpanStyleWithPlatformStyle ¶
func SpanStyleWithPlatformStyle(platformStyle *PlatformSpanStyle) SpanStyleOption
func SpanStyleWithShadow ¶
func SpanStyleWithShadow(shadow *graphics.Shadow) SpanStyleOption
func SpanStyleWithTextDecoration ¶
func SpanStyleWithTextDecoration(textDecoration *style.TextDecoration) SpanStyleOption
func SpanStyleWithTextGeometricTransform ¶
func SpanStyleWithTextGeometricTransform(textGeometricTransform *style.TextGeometricTransform) SpanStyleOption
type SpanStyleOptions ¶
type SpanStyleOptions struct {
FontSize unit.TextUnit
FontWeight font.FontWeight
FontStyle font.FontStyle
FontSynthesis *font.FontSynthesis
FontFamily font.FontFamily
FontFeatureSettings string
LetterSpacing unit.TextUnit
BaselineShift style.BaselineShift
TextGeometricTransform *style.TextGeometricTransform
LocaleList *intl.LocaleList
Background graphics.Color
TextDecoration *style.TextDecoration
Shadow *graphics.Shadow
PlatformStyle *PlatformSpanStyle
DrawStyle graphics.DrawStyle
// contains filtered or unexported fields
}
type StringAnnotation ¶
type StringAnnotation string
StringAnnotation is simple string metadata attached to text.
type TextLayoutInput ¶
type TextLayoutInput struct {
// Text is the annotated string used for computing text layout.
Text AnnotatedString
// Style is the text style used for computing this text layout.
Style TextStyle
// Placeholders is a list of placeholders inserted into text layout that reserve space
// to embed icons or custom emojis.
Placeholders []Range[Placeholder]
// MaxLines is the maximum number of lines for the text layout.
MaxLines int
// SoftWrap indicates whether the text should break at soft line breaks.
SoftWrap bool
// Overflow indicates how visual overflow should be handled.
Overflow style.TextOverFlow
// Density is the density used for computing this text layout.
Density unit.Density
// LayoutDirection is the layout direction used for computing this text layout.
LayoutDirection unit.LayoutDirection
// FontFamilyResolver is the font resolver used for computing this text layout.
// This is a placeholder interface for platform-specific implementations.
FontFamilyResolver interface{}
// Constraints are the layout constraints for this text layout.
Constraints unit.Constraints
}
TextLayoutInput holds the parameters used for computing a text layout result.
Note: The Kotlin source includes deprecated resourceLoader field and DeprecatedBridgeFontResourceLoader class. These are omitted in the Go port.
func NewTextLayoutInput ¶
func NewTextLayoutInput( text AnnotatedString, textStyle TextStyle, placeholders []Range[Placeholder], maxLines int, softWrap bool, overflow style.TextOverFlow, density unit.Density, layoutDirection unit.LayoutDirection, fontFamilyResolver interface{}, constraints unit.Constraints, ) TextLayoutInput
NewTextLayoutInput creates a new TextLayoutInput with the given parameters.
func (TextLayoutInput) Equals ¶
func (i TextLayoutInput) Equals(other TextLayoutInput) bool
Equals checks equality with another TextLayoutInput.
func (TextLayoutInput) String ¶
func (i TextLayoutInput) String() string
String returns a string representation of TextLayoutInput.
type TextLayoutResult ¶
type TextLayoutResult struct {
// contains filtered or unexported fields
}
TextLayoutResult holds the result of text layout computation.
func NewTextLayoutResult ¶
func NewTextLayoutResult(layoutInput TextLayoutInput, multiParagraph MultiParagraph, size unit.IntSize) TextLayoutResult
NewTextLayoutResult creates a new TextLayoutResult.
func (TextLayoutResult) Copy ¶
func (r TextLayoutResult) Copy(layoutInput *TextLayoutInput, size *unit.IntSize) TextLayoutResult
Copy creates a copy of the TextLayoutResult with optional overrides.
func (TextLayoutResult) DidOverflowHeight ¶
func (r TextLayoutResult) DidOverflowHeight() bool
DidOverflowHeight returns true if the text is too tall and couldn't fit with given height.
func (TextLayoutResult) DidOverflowWidth ¶
func (r TextLayoutResult) DidOverflowWidth() bool
DidOverflowWidth returns true if the text is too wide and couldn't fit with given width.
func (TextLayoutResult) Equals ¶
func (r TextLayoutResult) Equals(other TextLayoutResult) bool
Equals checks equality with another TextLayoutResult.
func (TextLayoutResult) FirstBaseline ¶
func (r TextLayoutResult) FirstBaseline() float32
FirstBaseline returns the distance from the top to the alphabetic baseline of the first line.
func (TextLayoutResult) GetBidiRunDirection ¶
func (r TextLayoutResult) GetBidiRunDirection(offset int) style.ResolvedTextDirection
GetBidiRunDirection returns the text direction of the BiDi run at the offset.
func (TextLayoutResult) GetBoundingBox ¶
func (r TextLayoutResult) GetBoundingBox(offset int) geometry.Rect
GetBoundingBox returns the bounding box of the character at the given offset.
func (TextLayoutResult) GetCursorRect ¶
func (r TextLayoutResult) GetCursorRect(offset int) geometry.Rect
GetCursorRect returns the rectangle of the cursor area at the given offset.
func (TextLayoutResult) GetHorizontalPosition ¶
func (r TextLayoutResult) GetHorizontalPosition(offset int, usePrimaryDirection bool) float32
GetHorizontalPosition returns the horizontal position for the specified text offset.
func (TextLayoutResult) GetLineBaseline ¶
func (r TextLayoutResult) GetLineBaseline(lineIndex int) float32
GetLineBaseline returns the baseline y coordinate of the given line.
func (TextLayoutResult) GetLineBottom ¶
func (r TextLayoutResult) GetLineBottom(lineIndex int) float32
GetLineBottom returns the bottom y coordinate of the given line.
func (TextLayoutResult) GetLineEnd ¶
func (r TextLayoutResult) GetLineEnd(lineIndex int, visibleEnd bool) int
GetLineEnd returns the end offset of the given line.
func (TextLayoutResult) GetLineForOffset ¶
func (r TextLayoutResult) GetLineForOffset(offset int) int
GetLineForOffset returns the line number for the specified text offset.
func (TextLayoutResult) GetLineForVerticalPosition ¶
func (r TextLayoutResult) GetLineForVerticalPosition(vertical float32) int
GetLineForVerticalPosition returns the line number closest to the given vertical position.
func (TextLayoutResult) GetLineLeft ¶
func (r TextLayoutResult) GetLineLeft(lineIndex int) float32
GetLineLeft returns the left x coordinate of the given line.
func (TextLayoutResult) GetLineRight ¶
func (r TextLayoutResult) GetLineRight(lineIndex int) float32
GetLineRight returns the right x coordinate of the given line.
func (TextLayoutResult) GetLineStart ¶
func (r TextLayoutResult) GetLineStart(lineIndex int) int
GetLineStart returns the start offset of the given line, inclusive.
func (TextLayoutResult) GetLineTop ¶
func (r TextLayoutResult) GetLineTop(lineIndex int) float32
GetLineTop returns the top y coordinate of the given line.
func (TextLayoutResult) GetOffsetForPosition ¶
func (r TextLayoutResult) GetOffsetForPosition(position geometry.Offset) int
GetOffsetForPosition returns the character offset closest to the given graphical position.
func (TextLayoutResult) GetParagraphDirection ¶
func (r TextLayoutResult) GetParagraphDirection(offset int) style.ResolvedTextDirection
GetParagraphDirection returns the text direction of the paragraph containing the offset.
func (TextLayoutResult) GetPathForRange ¶
func (r TextLayoutResult) GetPathForRange(start, end int) graphics.Path
GetPathForRange returns a path that encloses the given text range.
func (TextLayoutResult) GetWordBoundary ¶
func (r TextLayoutResult) GetWordBoundary(offset int) TextRange
GetWordBoundary returns the text range of the word at the given offset.
func (TextLayoutResult) HasVisualOverflow ¶
func (r TextLayoutResult) HasVisualOverflow() bool
HasVisualOverflow returns true if either vertical or horizontal overflow happens.
func (TextLayoutResult) IsLineEllipsized ¶
func (r TextLayoutResult) IsLineEllipsized(lineIndex int) bool
IsLineEllipsized returns true if the given line is ellipsized.
func (TextLayoutResult) LastBaseline ¶
func (r TextLayoutResult) LastBaseline() float32
LastBaseline returns the distance from the top to the alphabetic baseline of the last line.
func (TextLayoutResult) LayoutInput ¶
func (r TextLayoutResult) LayoutInput() TextLayoutInput
LayoutInput returns the parameters used for computing this text layout result.
func (TextLayoutResult) LineCount ¶
func (r TextLayoutResult) LineCount() int
LineCount returns the number of lines in this text layout.
func (TextLayoutResult) MultiParagraph ¶
func (r TextLayoutResult) MultiParagraph() MultiParagraph
MultiParagraph returns the underlying multi-paragraph object.
func (TextLayoutResult) PlaceholderRects ¶
func (r TextLayoutResult) PlaceholderRects() []*geometry.Rect
PlaceholderRects returns the bounding boxes for placeholders.
func (TextLayoutResult) Size ¶
func (r TextLayoutResult) Size() unit.IntSize
Size returns the size of this text layout in pixels.
func (TextLayoutResult) String ¶
func (r TextLayoutResult) String() string
String returns a string representation of TextLayoutResult.
type TextRange ¶
TextRange is an immutable text range, representing a range from Start (inclusive) to End (exclusive). End can be smaller than Start; use Min() and Max() to get ordered values.
func NewTextRange ¶
NewTextRange creates a new TextRange with the given start and end. Panics if start or end is negative.
func NewTextRangeCollapsed ¶
NewTextRangeCollapsed creates a TextRange where start equals end.
func (TextRange) CoerceIn ¶
CoerceIn ensures that Start and End values lie in the specified range. For each value: - if value is smaller than minimumValue, value is replaced by minimumValue - if value is greater than maximumValue, value is replaced by maximumValue
func (TextRange) Contains ¶
Contains returns true if this range covers including equals with the given range.
func (TextRange) ContainsOffset ¶
ContainsOffset returns true if the given offset is a part of this range.
func (TextRange) Intersects ¶
Intersects returns true if the given range has intersection with this range.
func (TextRange) Reversed ¶
Reversed returns true if the start offset is larger than the end offset.
type TextShaper ¶
type TextStyle ¶
type TextStyle struct {
// contains filtered or unexported fields
}
var TextStyleUnspecified *TextStyle = &TextStyle{ spanStyle: SpanStyleUnspecified, paragraphStyle: ParagraphStyleUnspecified, platformStyle: nil, }
func CoalesceTextStyle ¶
func MergeTextStyle ¶
func TakeOrElseTextStyle ¶
func TextStyleResolveDefaults ¶
func TextStyleResolveDefaults(ts *TextStyle, direction unit.LayoutDirection) *TextStyle
func (TextStyle) Background ¶
func (TextStyle) BaselineShift ¶
func (ts TextStyle) BaselineShift() style.BaselineShift
func (TextStyle) FontFamily ¶
func (ts TextStyle) FontFamily() font.FontFamily
func (TextStyle) FontFeatureSettings ¶
func (TextStyle) FontSynthesis ¶
func (ts TextStyle) FontSynthesis() *font.FontSynthesis
func (TextStyle) FontWeight ¶
func (ts TextStyle) FontWeight() font.FontWeight
func (TextStyle) LetterSpacing ¶
func (TextStyle) LineHeight ¶
func (TextStyle) LineHeightStyle ¶
func (ts TextStyle) LineHeightStyle() *style.LineHeightStyle
func (TextStyle) LocaleList ¶
func (ts TextStyle) LocaleList() *intl.LocaleList
func (TextStyle) MergeParagraphStyle ¶
func (ts TextStyle) MergeParagraphStyle(other *ParagraphStyle) *TextStyle
func (TextStyle) MergeSpanStyle ¶
func (TextStyle) PlusParagraphStyle ¶
func (ts TextStyle) PlusParagraphStyle(other *ParagraphStyle) *TextStyle
func (TextStyle) PlusSpanStyle ¶
func (TextStyle) TextDecoration ¶
func (ts TextStyle) TextDecoration() *style.TextDecoration
func (TextStyle) TextDirection ¶
func (ts TextStyle) TextDirection() style.TextDirection
func (TextStyle) TextGeometricTransform ¶
func (ts TextStyle) TextGeometricTransform() *style.TextGeometricTransform
func (TextStyle) TextIndent ¶
func (ts TextStyle) TextIndent() *style.TextIndent
func (TextStyle) TextMotion ¶
func (ts TextStyle) TextMotion() *style.TextMotion
func (TextStyle) ToParagraphStyle ¶
func (ts TextStyle) ToParagraphStyle() *ParagraphStyle
func (TextStyle) ToPlatformTextStyle ¶
func (ts TextStyle) ToPlatformTextStyle() *PlatformTextStyle
func (TextStyle) ToSpanStyle ¶
type TextStyleInterface ¶
type TextStyleInterface interface {
Alpha() float32
Background() graphics.Color
BaselineShift() style.BaselineShift
Brush() graphics.Brush
Color() graphics.Color
Copy() *TextStyle
DrawStyle() graphics.DrawStyle
FontFamily() font.FontFamily
FontFeatureSettings() string
FontSize() unit.TextUnit
FontStyle() font.FontStyle
FontSynthesis() *font.FontSynthesis
FontWeight() font.FontWeight
Hyphens() style.Hyphens
LetterSpacing() unit.TextUnit
LineBreak() style.LineBreak
LineHeight() unit.TextUnit
LineHeightStyle() *style.LineHeightStyle
LocaleList() *intl.LocaleList
MergeParagraphStyle(other *ParagraphStyle) *TextStyle
MergeSpanStyle(other *SpanStyle) *TextStyle
Plus(other *TextStyle) *TextStyle
PlusParagraphStyle(other *ParagraphStyle) *TextStyle
PlusSpanStyle(other *SpanStyle) *TextStyle
Shadow() *graphics.Shadow
TextAlign() style.TextAlign
TextDecoration() *style.TextDecoration
TextDirection() style.TextDirection
TextGeometricTransform() *style.TextGeometricTransform
TextIndent() *style.TextIndent
TextMotion() *style.TextMotion
ToParagraphStyle() *ParagraphStyle
ToPlatformTextStyle() *PlatformTextStyle
ToSpanStyle() *SpanStyle
ToString() string
}