ReusableTextStyleScope


Mutable TextStyleScope implementation reused across layout and draw passes to avoid allocations.

Summary

Public constructors

Cmn

Public functions

Unit

Copies all attributes from other into this ReusableTextStyleScope.

Cmn
Boolean

Returns whether this scope and other have equivalent draw-affecting attributes.

Cmn
Boolean

Returns whether this scope and style have equivalent draw-affecting attributes.

Cmn
Boolean

Returns whether this scope and other have equivalent layout-affecting attributes.

Cmn
Boolean

Returns whether this scope and style have equivalent layout-affecting attributes.

Cmn
Unit

Resets all text attributes to their initial unspecified values.

Cmn
open Unit
setAlpha(alpha: Float)

Sets the opacity of the text (0.0 to 1.0) applied when a brush is configured (via setBrush or setTextStyle).

Cmn
open Unit
setBackground(background: Color)

Sets the background color covering the entire line height from start to end.

Cmn
open Unit

Sets the vertical shift amount from the baseline (e.g., BaselineShift.Superscript).

Cmn
open Unit
setBrush(brush: Brush)

Sets the Brush for painting the text, clearing any color previously set via setColor or setTextStyle (resetting it to Color.Unspecified).

Cmn
open Unit
setColor(color: Color)

Sets the color to apply to the text.

Cmn
open Unit
setDrawStyle(drawStyle: DrawStyle)

Sets the drawing style of the text (fill or stroke).

Cmn
open Unit

Sets the font family used when rendering text.

Cmn
open Unit
setFontFeatureSettings(fontFeatureSettings: String)

Sets advanced typography settings in CSS format (e.g., "smcp" for small caps).

Cmn
open Unit
setFontSize(fontSize: TextUnit)

Sets the size of glyphs to use when painting the text (e.g., 16.sp).

Cmn
open Unit
setFontStyle(fontStyle: FontStyle)

Sets the typeface variant to use when drawing letters (e.g., FontStyle.Italic).

Cmn
open Unit

Sets the font synthesis rules determining if and how bold/italic styles are synthesized when the font family does not natively support them.

Cmn
open Unit

Sets the typeface thickness to use when painting the text (e.g., FontWeight.Bold).

Cmn
open Unit
setHyphens(hyphens: Hyphens)

Sets the hyphenation configuration of the paragraph.

Cmn
open Unit
setLetterSpacing(letterSpacing: TextUnit)

Sets the amount of space to add between letters (in SP or EM).

Cmn
open Unit
setLineBreak(lineBreak: LineBreak)

Sets the line breaking configuration of the paragraph.

Cmn
open Unit
setLineHeight(lineHeight: TextUnit)

Sets the line height for the paragraph (e.g., 24.sp).

Cmn
open Unit

Sets the line height distribution configuration.

Cmn
open Unit

Sets the locale list used to select region-specific glyphs.

Cmn
open Unit

Sets platform-specific text styling parameters.

Cmn
open Unit
setShadow(shadow: Shadow)

Sets the shadow effect applied to the text.

Cmn
open Unit
setTextAlign(textAlign: TextAlign)

Sets the alignment of the text within lines of the paragraph.

Cmn
open Unit

Sets the decorations to paint on the text (e.g., TextDecoration.Underline).

Cmn
open Unit

Sets the algorithm used to resolve text direction.

Cmn
open Unit
setTextGeometricTransform(
    textGeometricTransform: TextGeometricTransform
)

Sets the geometric transformation to apply to the text.

Cmn
open Unit

Sets the paragraph indentation.

Cmn
open Unit

Sets the text character placement optimization for animated or static text.

Cmn
open Unit

Sets all text attributes from style.

Cmn

Public properties

Float

Opacity of the text (0.0 to 1.0) applied when brush is provided, or Float.NaN if not set.

Cmn
Color

Background color covering the entire line height from start to end, or Color.Unspecified if not set.

Cmn
BaselineShift

Vertical shift amount from the baseline, or BaselineShift.Unspecified if not set.

Cmn
Brush?

Brush for painting the text, or null if not set.

Cmn
Color

Color to apply to the text, or Color.Unspecified if not set.

Cmn
DrawStyle?

Drawing style of the text (fill or stroke), or null if not set.

Cmn
FontFamily?

Font family used when rendering text, or null if not set.

Cmn
String?

Advanced typography settings in CSS format, or null if not set.

Cmn
TextUnit

Size of glyphs to use when painting the text, or TextUnit.Unspecified if not set.

Cmn
FontStyle?

Typeface variant to use when drawing letters, or null if not set.

Cmn
FontSynthesis?

Font synthesis rules determining if and how bold/italic styles are synthesized when the font family does not natively support them, or null if not set.

Cmn
FontWeight?

Typeface thickness to use when painting the text, or null if not set.

Cmn
Hyphens

Hyphenation configuration of the paragraph, or Hyphens.Unspecified if not set.

Cmn
TextUnit

Amount of space to add between letters, or TextUnit.Unspecified if not set.

Cmn
LineBreak

Line breaking configuration of the paragraph, or LineBreak.Unspecified if not set.

Cmn
TextUnit

Line height for the paragraph, or TextUnit.Unspecified if not set.

Cmn
LineHeightStyle?

Line height distribution configuration, or null if not set.

Cmn
LocaleList?

Locale list used to select region-specific glyphs, or null if not set.

Cmn
PlatformTextStyle?

Platform-specific text styling parameters, or null if not set.

Cmn
Shadow?

Shadow effect applied to the text, or null if not set.

Cmn
TextAlign

Alignment of the text within lines of the paragraph, or TextAlign.Unspecified if not set.

Cmn
TextDecoration?

Decorations to paint on the text, or null if not set.

Cmn
TextDirection

Algorithm used to resolve text direction, or TextDirection.Unspecified if not set.

Cmn
TextGeometricTransform?

Geometric transformation to apply to the text, or null if not set.

Cmn
TextIndent?

Paragraph indentation, or null if not set.

Cmn
TextMotion?

Text character placement optimization for animated or static text, or null if not set.

Cmn

Public constructors

ReusableTextStyleScope

ReusableTextStyleScope()

Public functions

copyFrom

fun copyFrom(other: ReusableTextStyleScope): Unit

Copies all attributes from other into this ReusableTextStyleScope.

Parameters
other: ReusableTextStyleScope

source scope to copy attributes from

hasSameDrawAffectingAttributes

fun hasSameDrawAffectingAttributes(other: ReusableTextStyleScope): Boolean

Returns whether this scope and other have equivalent draw-affecting attributes.

Parameters
other: ReusableTextStyleScope

style scope to compare against

Returns
Boolean

true if all draw-affecting attributes match

hasSameDrawAffectingAttributes

fun hasSameDrawAffectingAttributes(style: TextStyle): Boolean

Returns whether this scope and style have equivalent draw-affecting attributes.

Parameters
style: TextStyle

text style to compare against

Returns
Boolean

true if all draw-affecting attributes match

hasSameLayoutAffectingAttributes

fun hasSameLayoutAffectingAttributes(other: ReusableTextStyleScope): Boolean

Returns whether this scope and other have equivalent layout-affecting attributes.

Parameters
other: ReusableTextStyleScope

style scope to compare against

Returns
Boolean

true if all layout-affecting attributes match

hasSameLayoutAffectingAttributes

fun hasSameLayoutAffectingAttributes(style: TextStyle): Boolean

Returns whether this scope and style have equivalent layout-affecting attributes.

Parameters
style: TextStyle

text style to compare against

Returns
Boolean

true if all layout-affecting attributes match

reset

fun reset(): Unit

Resets all text attributes to their initial unspecified values.

setAlpha

open fun setAlpha(alpha: Float): Unit

Sets the opacity of the text (0.0 to 1.0) applied when a brush is configured (via setBrush or setTextStyle). Cleared when a specified color is set via setColor or when setTextStyle sets a style without a brush.

setBackground

open fun setBackground(background: Color): Unit

Sets the background color covering the entire line height from start to end.

setBaselineShift

open fun setBaselineShift(baselineShift: BaselineShift): Unit

Sets the vertical shift amount from the baseline (e.g., BaselineShift.Superscript). If BaselineShift.Unspecified, inherits from parent or default style.

setBrush

open fun setBrush(brush: Brush): Unit

Sets the Brush for painting the text, clearing any color previously set via setColor or setTextStyle (resetting it to Color.Unspecified).

setColor

open fun setColor(color: Color): Unit

Sets the color to apply to the text.

If color is specified (color.isSpecified), this clears any brush and alpha previously set via setBrush, setAlpha, or setTextStyle. If color is Color.Unspecified, any existing brush and alpha are preserved.

setDrawStyle

open fun setDrawStyle(drawStyle: DrawStyle): Unit

Sets the drawing style of the text (fill or stroke).

setFontFamily

open fun setFontFamily(fontFamily: FontFamily): Unit

Sets the font family used when rendering text.

setFontFeatureSettings

open fun setFontFeatureSettings(fontFeatureSettings: String): Unit

Sets advanced typography settings in CSS format (e.g., "smcp" for small caps).

setFontSize

open fun setFontSize(fontSize: TextUnit): Unit

Sets the size of glyphs to use when painting the text (e.g., 16.sp).

setFontStyle

open fun setFontStyle(fontStyle: FontStyle): Unit

Sets the typeface variant to use when drawing letters (e.g., FontStyle.Italic).

setFontSynthesis

open fun setFontSynthesis(fontSynthesis: FontSynthesis): Unit

Sets the font synthesis rules determining if and how bold/italic styles are synthesized when the font family does not natively support them.

setFontWeight

open fun setFontWeight(fontWeight: FontWeight): Unit

Sets the typeface thickness to use when painting the text (e.g., FontWeight.Bold).

setHyphens

open fun setHyphens(hyphens: Hyphens): Unit

Sets the hyphenation configuration of the paragraph.

setLetterSpacing

open fun setLetterSpacing(letterSpacing: TextUnit): Unit

Sets the amount of space to add between letters (in SP or EM).

setLineBreak

open fun setLineBreak(lineBreak: LineBreak): Unit

Sets the line breaking configuration of the paragraph.

setLineHeight

open fun setLineHeight(lineHeight: TextUnit): Unit

Sets the line height for the paragraph (e.g., 24.sp).

setLineHeightStyle

open fun setLineHeightStyle(lineHeightStyle: LineHeightStyle): Unit

Sets the line height distribution configuration.

setLocaleList

open fun setLocaleList(localeList: LocaleList): Unit

Sets the locale list used to select region-specific glyphs.

setPlatformStyle

open fun setPlatformStyle(platformStyle: PlatformTextStyle): Unit

Sets platform-specific text styling parameters.

setShadow

open fun setShadow(shadow: Shadow): Unit

Sets the shadow effect applied to the text.

setTextAlign

open fun setTextAlign(textAlign: TextAlign): Unit

Sets the alignment of the text within lines of the paragraph.

setTextDecoration

open fun setTextDecoration(textDecoration: TextDecoration): Unit

Sets the decorations to paint on the text (e.g., TextDecoration.Underline).

setTextDirection

open fun setTextDirection(textDirection: TextDirection): Unit

Sets the algorithm used to resolve text direction.

setTextGeometricTransform

open fun setTextGeometricTransform(
    textGeometricTransform: TextGeometricTransform
): Unit

Sets the geometric transformation to apply to the text.

setTextIndent

open fun setTextIndent(textIndent: TextIndent): Unit

Sets the paragraph indentation.

setTextMotion

open fun setTextMotion(textMotion: TextMotion): Unit

Sets the text character placement optimization for animated or static text.

setTextStyle

open fun setTextStyle(style: TextStyle): Unit

Sets all text attributes from style.

Overwrites all attributes in this scope with the values from style, resetting attributes that are unspecified or null in style. Call individual setter methods after setTextStyle to override specific attributes.

Parameters
style: TextStyle

text style to copy attributes from

Public properties

alpha

val alpha: Float

Opacity of the text (0.0 to 1.0) applied when brush is provided, or Float.NaN if not set.

background

val background: Color

Background color covering the entire line height from start to end, or Color.Unspecified if not set.

baselineShift

val baselineShift: BaselineShift

Vertical shift amount from the baseline, or BaselineShift.Unspecified if not set.

brush

val brush: Brush?

Brush for painting the text, or null if not set.

color

val color: Color

Color to apply to the text, or Color.Unspecified if not set.

drawStyle

val drawStyle: DrawStyle?

Drawing style of the text (fill or stroke), or null if not set.

fontFamily

val fontFamily: FontFamily?

Font family used when rendering text, or null if not set.

fontFeatureSettings

val fontFeatureSettings: String?

Advanced typography settings in CSS format, or null if not set.

fontSize

val fontSize: TextUnit

Size of glyphs to use when painting the text, or TextUnit.Unspecified if not set.

fontStyle

val fontStyle: FontStyle?

Typeface variant to use when drawing letters, or null if not set.

fontSynthesis

val fontSynthesis: FontSynthesis?

Font synthesis rules determining if and how bold/italic styles are synthesized when the font family does not natively support them, or null if not set.

fontWeight

val fontWeight: FontWeight?

Typeface thickness to use when painting the text, or null if not set.

hyphens

val hyphens: Hyphens

Hyphenation configuration of the paragraph, or Hyphens.Unspecified if not set.

letterSpacing

val letterSpacing: TextUnit

Amount of space to add between letters, or TextUnit.Unspecified if not set.

lineBreak

val lineBreak: LineBreak

Line breaking configuration of the paragraph, or LineBreak.Unspecified if not set.

lineHeight

val lineHeight: TextUnit

Line height for the paragraph, or TextUnit.Unspecified if not set.

lineHeightStyle

val lineHeightStyle: LineHeightStyle?

Line height distribution configuration, or null if not set.

localeList

val localeList: LocaleList?

Locale list used to select region-specific glyphs, or null if not set.

platformStyle

val platformStyle: PlatformTextStyle?

Platform-specific text styling parameters, or null if not set.

shadow

val shadow: Shadow?

Shadow effect applied to the text, or null if not set.

textAlign

val textAlign: TextAlign

Alignment of the text within lines of the paragraph, or TextAlign.Unspecified if not set.

textDecoration

val textDecoration: TextDecoration?

Decorations to paint on the text, or null if not set.

textDirection

val textDirection: TextDirection

Algorithm used to resolve text direction, or TextDirection.Unspecified if not set.

textGeometricTransform

val textGeometricTransform: TextGeometricTransform?

Geometric transformation to apply to the text, or null if not set.

textIndent

val textIndent: TextIndent?

Paragraph indentation, or null if not set.

textMotion

val textMotion: TextMotion?

Text character placement optimization for animated or static text, or null if not set.