style

package
v0.1.122 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TextDecorationNone Defines a horizontal line to be drawn on the text.
	TextDecorationNone = &TextDecoration{mask: TextDecorationMaskNone}

	// TextDecorationUnderline Draws a horizontal line below the text.
	TextDecorationUnderline = &TextDecoration{mask: TextDecorationMaskUnderline}

	// TextDecorationLineThrough Draws a horizontal line over the text.
	TextDecorationLineThrough = &TextDecoration{mask: TextDecorationMaskLineThrough}

	TextDecorationUnspecified = &TextDecoration{mask: TextDecorationMaskUnspecified}
)
View Source
var (
	LineHeightStyleAlignmentUnspecified = &LineHeightStyleAlignment{TopRatio: -1}

	// LineHeightStyleAlignmentTop aligns the line to the top of the space reserved for that line.
	LineHeightStyleAlignmentTop = &LineHeightStyleAlignment{TopRatio: 0}
	// LineHeightStyleAlignmentCenter aligns the line to the center of the space reserved for the line.
	LineHeightStyleAlignmentCenter = &LineHeightStyleAlignment{TopRatio: 0.5}
	// LineHeightStyleAlignmentProportional aligns the line proportional to the ascent and descent values of the line.
	LineHeightStyleAlignmentProportional = &LineHeightStyleAlignment{TopRatio: -1}
	// LineHeightStyleAlignmentBottom aligns the line to the bottom of the space reserved for that line.
	LineHeightStyleAlignmentBottom = &LineHeightStyleAlignment{TopRatio: 1}
)
View Source
var (
	TextMotionUnspecified = &TextMotion{
		Linearity:               LinearityUnspecified,
		SubpixelTextPositioning: SubpixelTextPositioningUnspecified,
	}
	// TextMotionStatic optimizes glyph shaping, placement, and overall rendering
	// for maximum readability. Intended for text that is not animated.
	// This is the default TextMotion.
	TextMotionStatic = &TextMotion{
		Linearity:               LinearityFontHinting,
		SubpixelTextPositioning: SubpixelTextPositioningFalse,
	}

	// TextMotionAnimated renders text for maximum linearity which provides smooth
	// animations for text. Trade-off is the readability of the text on some low
	// DPI devices. Use this TextMotion if you are planning to scale, translate,
	// or rotate text.
	TextMotionAnimated = &TextMotion{
		Linearity:               LinearityLinear,
		SubpixelTextPositioning: SubpixelTextPositioningTrue,
	}
)
View Source
var BaselineShiftUnspecified = BaselineShift(floatutils.Float32Unspecified)

BaselineShiftUnspecified represents an unset baseline shift (NaN value)

Looser breaking rules, suitable for short text such as titles or narrow newspaper columns. For longer lines of text, use [Paragraph] for improved readability.

Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.

Basic, fast line breaking. Ideal for text input fields, as it will cause minimal text reflow when editing.

View Source
var TextGeometricTransformNone = &TextGeometricTransform{
	ScaleX: 1,
	SkewX:  0,
}
View Source
var TextGeometricTransformUnspecified = &TextGeometricTransform{
	ScaleX: floatutils.Float32Unspecified,
	SkewX:  floatutils.Float32Unspecified,
}
View Source
var TextIndentNone = &TextIndent{FirstLine: unit.Sp(0), RestLine: unit.Sp(0)}

TextIndentNone is a constant for no text indent.

View Source
var TextIndentUnspecified = &TextIndent{FirstLine: unit.TextUnitUnspecified, RestLine: unit.TextUnitUnspecified}

Functions

func EqualLineHeightStyle

func EqualLineHeightStyle(a, b *LineHeightStyle) bool

func EqualTextDecoration

func EqualTextDecoration(a, b *TextDecoration) bool

func EqualTextForegroundStyle

func EqualTextForegroundStyle(a, b *TextForegroundStyle) bool

func EqualTextGeometricTransform

func EqualTextGeometricTransform(a, b *TextGeometricTransform) bool

func EqualTextIndent

func EqualTextIndent(a, b *TextIndent) bool

func EqualTextMotion

func EqualTextMotion(a, b *TextMotion) bool

func IsBaselineShift

func IsBaselineShift(bs BaselineShift) bool

IsBaselineShift returns true if this baseline shift is not Unspecified (i.e., not NaN)

func IsSpecifiedLineHeightStyle

func IsSpecifiedLineHeightStyle(s *LineHeightStyle) bool

func IsSpecifiedLineHeightStyleAlignment

func IsSpecifiedLineHeightStyleAlignment(a *LineHeightStyleAlignment) bool

func IsSpecifiedTextDecoration

func IsSpecifiedTextDecoration(t *TextDecoration) bool

func IsSpecifiedTextGeometricTransform

func IsSpecifiedTextGeometricTransform(gt *TextGeometricTransform) bool

func IsSpecifiedTextIndent

func IsSpecifiedTextIndent(indent *TextIndent) bool

func IsSpecifiedTextMotion

func IsSpecifiedTextMotion(s *TextMotion) bool

func LerpTextUnitInheritable

func LerpTextUnitInheritable(a, b unit.TextUnit, fraction float32) unit.TextUnit

LerpTextUnitInheritable linearly interpolates between two TextUnits, with special handling for Unspecified values.

This function exists to support style merging and animation scenarios where TextUnit values may be Unspecified (meaning "inherit from parent style"). Since there is no meaningful way to linearly interpolate between a concrete value (e.g., 16.sp) and an abstract "unspecified" sentinel, this function falls back to discrete interpolation when either value is Unspecified.

Behavior:

  • If BOTH values are specified: performs standard linear interpolation
  • If EITHER value is Unspecified: performs discrete interpolation (snaps at 0.5)

Discrete interpolation example (animating from Unspecified to 16.sp):

  • fraction 0.0 to 0.49 → returns Unspecified (inherits from parent)
  • fraction 0.5 to 1.0 → returns 16.sp

This matches Kotlin's lerpTextUnitInheritable behavior in Jetpack Compose.

func ModulateColor

func ModulateColor(color graphics.Color, alpha float32) graphics.Color

ModulateColor modulates a color's alpha by the given alpha value. If alpha is NaN or >= 1.0, returns the color unchanged. Otherwise, multiplies the color's alpha by the given alpha.

func SameLineHeightStyle

func SameLineHeightStyle(a, b *LineHeightStyle) bool

Identity (2 ns)

func SameTextDecoration

func SameTextDecoration(a, b *TextDecoration) bool

Identity (2 ns)

func SameTextForegroundStyle

func SameTextForegroundStyle(a, b *TextForegroundStyle) bool

Identity (2 ns)

func SameTextGeometricTransform

func SameTextGeometricTransform(a, b *TextGeometricTransform) bool

Identity (2 ns)

func SameTextIndent

func SameTextIndent(a, b *TextIndent) bool

func SameTextMotion

func SameTextMotion(a, b *TextMotion) bool

Identity (2 ns)

func SemanticEqualLineHeightStyle

func SemanticEqualLineHeightStyle(a, b *LineHeightStyle) bool

Semantic equality (field-by-field, 20 ns)

func SemanticEqualTextDecoration

func SemanticEqualTextDecoration(a, b *TextDecoration) bool

Semantic equality (field-by-field, 20 ns)

func SemanticEqualTextForegroundStyle

func SemanticEqualTextForegroundStyle(a, b *TextForegroundStyle) bool

Semantic equality (field-by-field, 20 ns)

func SemanticEqualTextGeometricTransform

func SemanticEqualTextGeometricTransform(a, b *TextGeometricTransform) bool

Semantic equality (field-by-field, 20 ns)

func SemanticEqualTextIndent

func SemanticEqualTextIndent(a, b *TextIndent) bool

Semantic equality (field-by-field, 20 ns)

func SemanticEqualTextMotion

func SemanticEqualTextMotion(a, b *TextMotion) bool

Semantic equality (field-by-field, 20 ns)

func StringBaselineShift

func StringBaselineShift(bs BaselineShift) string

StringBaselineShift returns a string representation of the BaselineShift

func StringLineHeightStyle

func StringLineHeightStyle(s *LineHeightStyle) string

func StringLineHeightStyleAlignment

func StringLineHeightStyleAlignment(a *LineHeightStyleAlignment) string

func StringTextDecoration

func StringTextDecoration(t *TextDecoration) string

func StringTextGeometricTransform

func StringTextGeometricTransform(gt *TextGeometricTransform) string

func StringTextIndent

func StringTextIndent(s *TextIndent) string

String returns a string representation of the TextIndent.

func StringTextMotion

func StringTextMotion(s *TextMotion) string

Types

type BaselineShift

type BaselineShift float32

BaselineShift represents the amount by which text is shifted up or down from the current baseline. The shift is calculated as: multiplier * (baseline - ascent) This is a 32-bit float value class equivalent to Kotlin's BaselineShift.

const (
	// Superscript shifts text upward by 0.5 * (baseline - ascent)
	BaselineShiftSuperscript BaselineShift = 0.5
	// Subscript shifts text downward by -0.5 * (baseline - ascent)
	BaselineShiftSubscript BaselineShift = -0.5
	// None applies no baseline shift
	BaselineShiftNone BaselineShift = 0.0
)

Predefined baseline shift constants

func LerpBaselineShift

func LerpBaselineShift(start, stop BaselineShift, fraction float32) BaselineShift

LerpBaselineShift linearly interpolates between two BaselineShifts. If either start or stop is Unspecified (NaN), the result will be Unspecified.

func MergeBaselineShift

func MergeBaselineShift(a, b BaselineShift) BaselineShift

MergeBaselineShift returns the first argument if it is specified, otherwise the second.

func NewBaselineShift

func NewBaselineShift(multiplier float32) BaselineShift

NewBaselineShift creates a new BaselineShift with the given multiplier

func TakeOrElseBaselineShift

func TakeOrElseBaselineShift(bs, block BaselineShift) BaselineShift

TakeOrElseBaselineShift returns this BaselineShift if it's specified, otherwise returns the result of block. This is equivalent to Kotlin's inline function with lambda.

func (BaselineShift) Multiplier

func (bs BaselineShift) Multiplier() float32

Multiplier returns the underlying multiplier value for use in calculations

func (BaselineShift) String

func (bs BaselineShift) String() string

String returns a string representation of the BaselineShift

type Hyphens

type Hyphens int

Automatic hyphenation configuration.

Hyphenation is a dash-like punctuation mark used to join two-words into one or separate syl-lab-les of a word.

Automatic hyphenation is added between syllables at appropriate hyphenation points, following language rules.

However, user can override automatic break point selection, suggesting line break opportunities (see Suggesting line break opportunities below).

Suggesting line break opportunities:

  • "\u2010" ("hard" hyphen) Indicates a visible line break opportunity. Even if the line is not actually broken at that point, the hyphen is still rendered.
  • "\u00AD" ("soft" hyphen) This character is not rendered visibly; instead, it marks a place where the word can be broken if hyphenation is necessary.

The default configuration for Hyphens = HyphensNone

const (
	// This represents an unset value, a usual replacement for "null" when a primitive value is
	// desired.
	HyphensUnspecified Hyphens = 0

	// Lines will break with no hyphenation.
	//
	// "Hard" hyphens will still be respected. However, no automatic hyphenation will be
	// attempted. If a word must be broken due to being longer than a line, it will break at any
	// character and will not attempt to break at a syllable boundary.
	//
	// +---------+
	// | Experim |
	// | ental   |
	// +---------+
	HyphensNone Hyphens = 1

	// The words will be automatically broken at appropriate hyphenation points.
	//
	// However, suggested line break opportunities (see Suggesting line break opportunities
	// above) will override automatic break point selection when present.
	//
	// +---------+
	// | Experi- |
	// | mental  |
	// +---------+
	HyphensAuto Hyphens = 2
)

func (Hyphens) IsSpecified

func (h Hyphens) IsSpecified() bool

Returns true if it is not HyphensUnspecified.

func (Hyphens) String

func (h Hyphens) String() string

func (Hyphens) TakeOrElse

func (h Hyphens) TakeOrElse(block Hyphens) Hyphens

If [IsSpecified] is true then this is returned, otherwise [block] is executed and its result is returned.

type LineBreak

type LineBreak int32

LineBreak configuration for line breaking. https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/next/text/style/LineBreak.kt

const LineBreakUnspecified LineBreak = 0

This represents an unset value, a usual replacement for "null" when a primitive value is desired.

func LineBreakOf

func LineBreakOf(strategy LineBreakStrategy, strictness LineBreakStrictness, wordBreak LineBreakWordBreak) LineBreak

LineBreakOf creates a LineBreak from individual components.

func (LineBreak) Copy

func (l LineBreak) Copy(
	strategy LineBreakStrategy,
	strictness LineBreakStrictness,
	wordBreak LineBreakWordBreak,
) LineBreak

Copy creates a copy of this LineBreak with the specified fields replaced.

func (LineBreak) IsSpecified

func (l LineBreak) IsSpecified() bool

IsSpecified returns true if it is not LineBreakUnspecified.

func (LineBreak) Strategy

func (l LineBreak) Strategy() LineBreakStrategy

Strategy returns the strategy used for line breaking.

func (LineBreak) Strictness

func (l LineBreak) Strictness() LineBreakStrictness

Strictness returns the strictness of line breaking.

func (LineBreak) String

func (l LineBreak) String() string

func (LineBreak) TakeOrElse

func (l LineBreak) TakeOrElse(other LineBreak) LineBreak

func (LineBreak) WordBreak

func (l LineBreak) WordBreak() LineBreakWordBreak

WordBreak returns how line breaks should be inserted within words.

type LineBreakStrategy

type LineBreakStrategy int32

LineBreakStrategy The strategy used for line breaking.

const (
	// LineBreakStrategySimple Basic, fast break strategy. Hyphenation, if enabled, is done only for words that
	// don't fit on an entire line by themselves.
	LineBreakStrategySimple LineBreakStrategy = 1

	// LineBreakStrategyHighQuality Does whole paragraph optimization for more readable text, including hyphenation if
	// enabled.
	LineBreakStrategyHighQuality LineBreakStrategy = 2

	// LineBreakStrategyBalanced Attempts to balance the line lengths of the text, also applying automatic hyphenation
	// if enabled. Suitable for small screens.
	LineBreakStrategyBalanced LineBreakStrategy = 3

	// LineBreakStrategyUnspecified This represents an unset value, a usual replacement for "null" when a primitive value
	// is desired.
	LineBreakStrategyUnspecified LineBreakStrategy = 0
)

func (LineBreakStrategy) String

func (s LineBreakStrategy) String() string

type LineBreakStrictness

type LineBreakStrictness int32

LineBreakStrictness Describes the strictness of line breaking, determining before which characters line breaks can be inserted. It is useful when working with CJK scripts.

const (
	// LineBreakStrictnessDefault Default breaking rules for the locale, which may correspond to [Normal] or [Strict].
	LineBreakStrictnessDefault LineBreakStrictness = 1

	// LineBreakStrictnessLoose The least restrictive rules, suitable for short lines.
	//
	// For example, in Japanese it allows breaking before iteration marks, such as 々, 〻.
	LineBreakStrictnessLoose LineBreakStrictness = 2

	// LineBreakStrictnessNormal The most common rules for line breaking.
	//
	// For example, in Japanese it allows breaking before characters like small hiragana
	// (ぁ), small katakana (ァ), halfwidth variants (ァ).
	LineBreakStrictnessNormal LineBreakStrictness = 3

	// LineBreakStrictnessStrict The most stringent rules for line breaking.
	//
	// For example, in Japanese it does not allow breaking before characters like small
	// hiragana (ぁ), small katakana (ァ), halfwidth variants (ァ).
	LineBreakStrictnessStrict LineBreakStrictness = 4

	// LineBreakStrictnessUnspecified This represents an unset value, a usual replacement for "null" when a primitive value
	// is desired.
	LineBreakStrictnessUnspecified LineBreakStrictness = 0
)

func (LineBreakStrictness) String

func (s LineBreakStrictness) String() string

type LineBreakWordBreak

type LineBreakWordBreak int32

LineBreakWordBreak Describes how line breaks should be inserted within words.

const (
	// LineBreakWordBreakDefault Default word breaking rules for the locale. In latin scripts this means inserting
	// line breaks between words, while in languages that don't use whitespace (e.g.
	// Japanese) the line can break between characters.
	LineBreakWordBreakDefault LineBreakWordBreak = 1

	// LineBreakWordBreakPhrase Line breaking is based on phrases. In languages that don't use whitespace (e.g.
	// Japanese), line breaks are not inserted between characters that are part of the same
	// phrase unit. This is ideal for short text such as titles and UI labels.
	LineBreakWordBreakPhrase LineBreakWordBreak = 2

	// LineBreakWordBreakUnspecified This represents an unset value, a usual replacement for "null" when a primitive value
	// is desired.
	LineBreakWordBreakUnspecified LineBreakWordBreak = 0
)

func (LineBreakWordBreak) String

func (w LineBreakWordBreak) String() string

type LineHeightStyleAlignment

type LineHeightStyleAlignment struct {
	TopRatio float32
}

LineHeightStyleAlignment defines how to align the line in the space provided by the line height.

func TakeOrElseLineHeightStyleAlignment

func TakeOrElseLineHeightStyleAlignment(a, b *LineHeightStyleAlignment) *LineHeightStyleAlignment

type LineHeightStyleMode

type LineHeightStyleMode int

LineHeightStyleMode defines if the specified line height value should be enforced.

const (
	LineHeightStyleModeUnspecified LineHeightStyleMode = -1
	// LineHeightStyleModeFixed guarantees that taller glyphs won't be trimmed at the boundaries.
	LineHeightStyleModeFixed LineHeightStyleMode = 0
	// LineHeightStyleModeMinimum prevents the overflow of tall glyphs in middle lines.
	LineHeightStyleModeMinimum LineHeightStyleMode = 1
	// LineHeightStyleModeTight gets rid of the safety rails that are added by Fixed.
	LineHeightStyleModeTight LineHeightStyleMode = 2
)

func (LineHeightStyleMode) IsSpecified

func (m LineHeightStyleMode) IsSpecified() bool

func (LineHeightStyleMode) String

func (m LineHeightStyleMode) String() string

func (LineHeightStyleMode) TakeOrElse

type LineHeightStyleTrim

type LineHeightStyleTrim int

LineHeightStyleTrim defines whether to trim the extra space from the top of the first line and the bottom of the last line of text.

const (
	LineHeightStyleTrimFirstLineTop   LineHeightStyleTrim = flagTrimTop
	LineHeightStyleTrimLastLineBottom LineHeightStyleTrim = flagTrimBottom
	LineHeightStyleTrimBoth           LineHeightStyleTrim = flagTrimTop | flagTrimBottom
	LineHeightStyleTrimNone           LineHeightStyleTrim = 0
	LineHeightStyleTrimUnspecified    LineHeightStyleTrim = -1
)

func (LineHeightStyleTrim) IsTrimFirstLineTop

func (t LineHeightStyleTrim) IsTrimFirstLineTop() bool

func (LineHeightStyleTrim) IsTrimLastLineBottom

func (t LineHeightStyleTrim) IsTrimLastLineBottom() bool

func (LineHeightStyleTrim) IsTrimUnspecified

func (t LineHeightStyleTrim) IsTrimUnspecified() bool

func (LineHeightStyleTrim) String

func (t LineHeightStyleTrim) String() string

func (LineHeightStyleTrim) TakeOrElse

type Linearity

type Linearity int

Linearity defines the possible valid configurations for text linearity. Both font hinting and Linear text cannot be enabled at the same time.

const (
	LinearityUnspecified Linearity = 0
	// LinearityLinear is equal to applying LINEAR_TEXT_FLAG and turning hinting off.
	LinearityLinear Linearity = 1
	// LinearityFontHinting is equal to removing LINEAR_TEXT_FLAG and turning hinting on.
	LinearityFontHinting Linearity = 2
	// LinearityNone is equal to removing LINEAR_TEXT_FLAG and turning hinting off.
	LinearityNone Linearity = 3
)

func (Linearity) IsSpecified

func (l Linearity) IsSpecified() bool

func (Linearity) String

func (l Linearity) String() string

String returns a string representation of the Linearity.

func (Linearity) TakeOrElse

func (l Linearity) TakeOrElse(defaultLinearity Linearity) Linearity

type ResolvedTextDirection

type ResolvedTextDirection int

ResolvedTextDirection describes the resolved/actual directionality of text.

Unlike TextDirection which specifies the algorithm to determine direction, ResolvedTextDirection represents the final resolved direction.

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/next/text/style/ResolvedTextDirection.kt

const (
	// ResolvedTextDirectionLtr represents text that is left-to-right.
	ResolvedTextDirectionLtr ResolvedTextDirection = iota

	// ResolvedTextDirectionRtl represents text that is right-to-left.
	ResolvedTextDirectionRtl
)

func (ResolvedTextDirection) String

func (d ResolvedTextDirection) String() string

String returns the string representation of the ResolvedTextDirection.

type SubpixelTextPositioning

type SubpixelTextPositioning int
const (
	SubpixelTextPositioningUnspecified SubpixelTextPositioning = 0
	SubpixelTextPositioningTrue        SubpixelTextPositioning = 1
	SubpixelTextPositioningFalse       SubpixelTextPositioning = 2
)

func (SubpixelTextPositioning) IsSpecified

func (s SubpixelTextPositioning) IsSpecified() bool

func (SubpixelTextPositioning) String

func (s SubpixelTextPositioning) String() string

func (SubpixelTextPositioning) TakeOrElse

func (s SubpixelTextPositioning) TakeOrElse(defaultSubpixelTextPositioning SubpixelTextPositioning) SubpixelTextPositioning

type TextAlign

type TextAlign int

TextAlign defines how to align text horizontally. TextAlign controls how text aligns in the space it appears.

const (
	// TextAlignUnspecified represents an unset value, a usual replacement for "null"
	// when a primitive value is desired.
	TextAlignUnspecified TextAlign = 0

	// TextAlignLeft aligns the text on the left edge of the container.
	TextAlignLeft TextAlign = 1

	// TextAlignRight aligns the text on the right edge of the container.
	TextAlignRight TextAlign = 2

	// TextAlignCenter aligns the text in the center of the container.
	TextAlignCenter TextAlign = 3

	// TextAlignJustify stretches lines of text that end with a soft line break
	// to fill the width of the container.
	// Lines that end with hard line breaks are aligned towards the Start edge.
	TextAlignJustify TextAlign = 4

	// TextAlignStart aligns the text on the leading edge of the container.
	// For Left to Right text, this is the left edge.
	// For Right to Left text, like Arabic, this is the right edge.
	TextAlignStart TextAlign = 5

	// TextAlignEnd aligns the text on the trailing edge of the container.
	// For Left to Right text, this is the right edge.
	// For Right to Left text, like Arabic, this is the left edge.
	TextAlignEnd TextAlign = 6
)

TextAlign constants

func TextAlignValueOf

func TextAlignValueOf(value int) (TextAlign, error)

TextAlignValueOf creates a TextAlign from the given integer value. This can be useful if you need to serialize/deserialize TextAlign values. Returns an error if the given value is not recognized by the preset TextAlign values.

func TextAlignValues

func TextAlignValues() []TextAlign

TextAlignValues returns a list containing all possible values of TextAlign.

func (TextAlign) IsSpecified

func (t TextAlign) IsSpecified() bool

IsSpecified returns true if this TextAlign is not TextAlignUnspecified.

func (TextAlign) String

func (t TextAlign) String() string

String returns the string representation of the TextAlign.

func (TextAlign) TakeOrElse

func (t TextAlign) TakeOrElse(other TextAlign) TextAlign

TakeOrElse returns this TextAlign if IsSpecified() is true, otherwise executes the provided function and returns its result.

type TextDecoration

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

TextDecoration defines a horizontal line to be drawn on the text.

func CoalesceTextDecoration

func CoalesceTextDecoration(ptr, def *TextDecoration) *TextDecoration

func Combine

func Combine(decorations []*TextDecoration) *TextDecoration

Combine creates a decoration that includes all the given decorations.

func MergeTextDecoration

func MergeTextDecoration(a, b *TextDecoration) *TextDecoration

func NewTextDecoration

func NewTextDecoration(mask TextDecorationMask) TextDecoration

NewTextDecoration constructs a TextDecoration instance from the underlying mask. This method ensures the mask is valid.

func TakeOrElseTextDecoration

func TakeOrElseTextDecoration(s, def *TextDecoration) *TextDecoration

func (TextDecoration) Contains

func (t TextDecoration) Contains(other *TextDecoration) bool

Contains checks whether this TextDecoration contains the given decoration.

func (TextDecoration) Plus

func (t TextDecoration) Plus(decoration *TextDecoration) *TextDecoration

Plus creates a decoration that includes both of the TextDecorations.

type TextDecorationMask

type TextDecorationMask int
const (
	TextDecorationMaskUnspecified TextDecorationMask = -1
	TextDecorationMaskNone        TextDecorationMask = 0x0
	TextDecorationMaskUnderline   TextDecorationMask = 0x1
	TextDecorationMaskLineThrough TextDecorationMask = 0x2
)

type TextDirection

type TextDirection int

TextDirection defines the algorithm to be used while determining the text direction.

const (
	// TextDirectionUnspecified represents an unset value, a usual replacement for "null"
	// when a primitive value is desired.
	TextDirectionUnspecified TextDirection = 0

	// TextDirectionLtr always sets the text direction to be Left to Right.
	TextDirectionLtr TextDirection = 1

	// TextDirectionRtl always sets the text direction to be Right to Left.
	TextDirectionRtl TextDirection = 2

	// TextDirectionContent indicates that the text direction depends on the first strong
	// directional character in the text according to the Unicode Bidirectional Algorithm.
	// If no strong directional character is present, then LayoutDirection is used to
	// resolve the final TextDirection.
	// * if used while creating a Paragraph object, LocaleList will be used to resolve
	//   the direction as a fallback instead of LayoutDirection.
	TextDirectionContent TextDirection = 3

	// TextDirectionContentOrLtr indicates that the text direction depends on the first
	// strong directional character in the text according to the Unicode Bidirectional
	// Algorithm. If no strong directional character is present, then Left to Right will
	// be used as the default direction.
	TextDirectionContentOrLtr TextDirection = 4

	// TextDirectionContentOrRtl indicates that the text direction depends on the first
	// strong directional character in the text according to the Unicode Bidirectional
	// Algorithm. If no strong directional character is present, then Right to Left will
	// be used as the default direction.
	TextDirectionContentOrRtl TextDirection = 5
)

func ResolveTextDirection

func ResolveTextDirection(layoutDirection unit.LayoutDirection, textDirection TextDirection) TextDirection

ResolveTextDirection resolves the TextDirection, using the LayoutDirection if necessary. If the TextDirection is unspecified, it defaults to Ltr.

func TextDirectionValueOf

func TextDirectionValueOf(value int) (TextDirection, error)

TextDirectionValueOf creates a TextDirection from the given integer value. This can be useful if you need to serialize/deserialize TextDirection values. Returns an error if the given value is not recognized by the preset TextDirection values.

func TextDirectionValues

func TextDirectionValues() []TextDirection

TextDirectionValues returns a list containing all possible values of TextDirection. Note: Does not include TextDirectionUnspecified.

func (TextDirection) IsSpecified

func (t TextDirection) IsSpecified() bool

TextDirection returns true if this TextDirection is not TextDirectionUnspecified.

func (TextDirection) String

func (t TextDirection) String() string

String returns the string representation of the TextDirection.

func (TextDirection) TakeOrElse

func (t TextDirection) TakeOrElse(block TextDirection) TextDirection

TakeOrElse returns this TextDirection if IsSpecified() is true, otherwise executes the provided function and returns its result.

type TextForegroundStyle

type TextForegroundStyle struct {
	Color graphics.Color
	Brush graphics.Brush
	Alpha float32
}
var TextForegroundStyleUnspecified *TextForegroundStyle = &TextForegroundStyle{
	Color: graphics.ColorUnspecified,
	Brush: nil,
	Alpha: floatutils.Float32Unspecified,
}

TextForegroundStyleUnspecified is the unspecified TextForegroundStyle.

func CoalesceTextForegroundStyle

func CoalesceTextForegroundStyle(ptr, def *TextForegroundStyle) *TextForegroundStyle

func LerpTextForegroundStyle

func LerpTextForegroundStyle(start, stop *TextForegroundStyle, fraction float32) *TextForegroundStyle

LerpTextForegroundStyle linearly interpolates between two TextForegroundStyles. If both styles are not BrushStyles, lerps the color values. Otherwise, lerps discretely.

func MergeTextForegroundStyle

func MergeTextForegroundStyle(current, other *TextForegroundStyle) *TextForegroundStyle

MergeTextForegroundStyle implements the merge logic for TextForegroundStyle. This prevents Color or Unspecified TextForegroundStyle from overriding an existing Brush.

func TakeOrElseTextForegroundStyle

func TakeOrElseTextForegroundStyle(style, defaultStyle *TextForegroundStyle) *TextForegroundStyle

func TextForegroundStyleFromBrush

func TextForegroundStyleFromBrush(brush graphics.Brush, alpha float32) *TextForegroundStyle

TextForegroundStyleFromBrush creates a TextForegroundStyle from a Brush and alpha. If brush is nil, returns Unspecified. If brush is a SolidColor, returns a ColorStyle with the color modulated by alpha. If brush is a ShaderBrush, returns a BrushStyle.

func TextForegroundStyleFromColor

func TextForegroundStyleFromColor(color graphics.Color) *TextForegroundStyle

TextForegroundStyleFromColor creates a TextForegroundStyle from a Color. Returns Unspecified if the color is unspecified.

type TextGeometricTransform

type TextGeometricTransform struct {
	ScaleX float32
	SkewX  float32
}

func CoalesceTextGeometricTransform

func CoalesceTextGeometricTransform(ptr, def *TextGeometricTransform) *TextGeometricTransform

func LerpGeometricTransform

func LerpGeometricTransform(
	start *TextGeometricTransform,
	stop *TextGeometricTransform,
	fraction float32,
) *TextGeometricTransform

func MergeTextGeometricTransform

func MergeTextGeometricTransform(a, b *TextGeometricTransform) *TextGeometricTransform

func TakeOrElseTextGeometricTransform

func TakeOrElseTextGeometricTransform(gt *TextGeometricTransform, defaultGT *TextGeometricTransform) *TextGeometricTransform

type TextIndent

type TextIndent struct {
	FirstLine unit.TextUnit
	RestLine  unit.TextUnit
}

TextIndent specifies the indentation of a paragraph. FirstLine is the amount of indentation applied to the first line. RestLine is the amount of indentation applied to every line except the first line.

func CoalesceTextIndent

func CoalesceTextIndent(ptr, def *TextIndent) *TextIndent

func LerpTextIndent

func LerpTextIndent(start, stop *TextIndent, fraction float32) *TextIndent

LerpTextIndent linearly interpolates between two TextIndents.

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid.

func NewTextIndent

func NewTextIndent(firstLine, restLine unit.TextUnit) *TextIndent

NewTextIndent creates a new TextIndent with the given first line and rest line indentation.

func TakeOrElseTextIndent

func TakeOrElseTextIndent(a, b *TextIndent) *TextIndent

func (TextIndent) Copy

func (ti TextIndent) Copy(firstLine, restLine *unit.TextUnit) *TextIndent

Copy returns a new TextIndent with optionally updated fields. Pass nil to use the current value for that field.

func (TextIndent) HashCode

func (ti TextIndent) HashCode() int

HashCode returns a hash code for the TextIndent.

type TextMotion

type TextMotion struct {
	// Linearity defines the text linearity mode.
	Linearity Linearity
	// SubpixelTextPositioning enables subpixel text positioning for smoother animations.
	SubpixelTextPositioning SubpixelTextPositioning
}

TextMotion configuration for text rendering.

func CoalesceTextMotion

func CoalesceTextMotion(ptr, def *TextMotion) *TextMotion

func TakeOrElseTextMotion

func TakeOrElseTextMotion(s, def *TextMotion) *TextMotion

func (TextMotion) Copy

func (t TextMotion) Copy(options ...TextMotionOption) *TextMotion

Copy creates a copy of the TextMotion with optional modifications.

type TextMotionOption

type TextMotionOption func(*TextMotionOptions)

func WithLinearity

func WithLinearity(linearity Linearity) TextMotionOption

func WithSubpixelTextPositioning

func WithSubpixelTextPositioning(subpixelTextPositioning bool) TextMotionOption

type TextMotionOptions

type TextMotionOptions struct {
	Linearity               Linearity
	SubpixelTextPositioning SubpixelTextPositioning
}

type TextOverFlow

type TextOverFlow int

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/next/text/style/TextOverflow.kt;drc=4970f6e96cdb06089723da0ab8ec93ae3f067c7a;l=23

const (
	// Clip the overflowing text to fix its container.
	OverFlowClip TextOverFlow = 1

	// Use an ellipsis at the end of the string to indicate that the text has overflowed.
	// For example, [This is a ...].
	OverFlowEllipsis TextOverFlow = 2

	// Display all text, even if there is not enough space in the specified bounds. When
	// overflow is visible, text may be rendered outside the bounds of the composable displaying
	// the text. This ensures that all text is displayed to the user, and is typically the right
	// choice for most text display. It does mean that the text may visually occupy a region
	// larger than the bounds of its composable. This can lead to situations where text
	// displays outside the bounds of the background and clickable on a Text composable with a
	// fixed height and width.
	//
	// To make the background and click region expand to match the size of the text, allow it to
	// expand vertically/horizontally using Modifier.heightIn/Modifier.widthIn or similar.
	//
	// Note: text that expands past its bounds using Visible may be clipped by other modifiers
	// such as Modifier.clipToBounds.
	OverFlowVisible TextOverFlow = 3

	// Use an ellipsis at the start of the string to indicate that the text has overflowed.
	// For example, [... is a text].
	//
	// Note that not all platforms support the ellipsis at the start. For example, on Android
	// the start ellipsis is only available for a single line text (i.e. when either a soft wrap
	// is disabled or a maximum number of lines maxLines set to 1). In case of multiline text it
	// will fallback to Clip.
	OverFlowStartEllipsis TextOverFlow = 4

	// Use an ellipsis in the middle of the string to indicate that the text has overflowed.
	// For example, [This ... text].
	//
	// Note that not all platforms support the ellipsis in the middle. For example, on Android
	// the middle ellipsis is only available for a single line text (i.e. when either a soft
	// wrap is disabled or a maximum number of lines maxLines set to 1). In case of multiline
	// text it will fallback to Clip.
	OverFlowMiddleEllipsis TextOverFlow = 5
)

func (TextOverFlow) String

func (t TextOverFlow) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL