TextStyle


Styling configuration for a Text.

import androidx.compose.material.Text
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp

Text(
    text = "Demo Text",
    style =
        TextStyle(
            color = Color.Red,
            fontSize = 16.sp,
            fontFamily = FontFamily.Monospace,
            fontWeight = FontWeight.W800,
            fontStyle = FontStyle.Italic,
            letterSpacing = 0.5.em,
            background = Color.LightGray,
            textDecoration = TextDecoration.Underline
        )
)

Summary

Public companion properties

TextStyle

Constant for default text style.

Cmn

Public constructors

TextStyle(
    color: Color,
    fontSize: TextUnit,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?,
    fontFamily: FontFamily?,
    fontFeatureSettings: String?,
    letterSpacing: TextUnit,
    baselineShift: BaselineShift?,
    textGeometricTransform: TextGeometricTransform?,
    localeList: LocaleList?,
    background: Color,
    textDecoration: TextDecoration?,
    shadow: Shadow?,
    drawStyle: DrawStyle?,
    textAlign: TextAlign,
    textDirection: TextDirection,
    lineHeight: TextUnit,
    textIndent: TextIndent?,
    platformStyle: PlatformTextStyle?,
    lineHeightStyle: LineHeightStyle?,
    lineBreak: LineBreak,
    hyphens: Hyphens,
    textMotion: TextMotion?
)

Styling configuration for a Text.

Cmn
TextStyle(
    brush: Brush?,
    alpha: Float,
    fontSize: TextUnit,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?,
    fontFamily: FontFamily?,
    fontFeatureSettings: String?,
    letterSpacing: TextUnit,
    baselineShift: BaselineShift?,
    textGeometricTransform: TextGeometricTransform?,
    localeList: LocaleList?,
    background: Color,
    textDecoration: TextDecoration?,
    shadow: Shadow?,
    drawStyle: DrawStyle?,
    textAlign: TextAlign,
    textDirection: TextDirection,
    lineHeight: TextUnit,
    textIndent: TextIndent?,
    platformStyle: PlatformTextStyle?,
    lineHeightStyle: LineHeightStyle?,
    lineBreak: LineBreak,
    hyphens: Hyphens,
    textMotion: TextMotion?
)

Styling configuration for a Text.

Cmn

Public functions

TextStyle
copy(
    color: Color,
    fontSize: TextUnit,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?,
    fontFamily: FontFamily?,
    fontFeatureSettings: String?,
    letterSpacing: TextUnit,
    baselineShift: BaselineShift?,
    textGeometricTransform: TextGeometricTransform?,
    localeList: LocaleList?,
    background: Color,
    textDecoration: TextDecoration?,
    shadow: Shadow?,
    drawStyle: DrawStyle?,
    textAlign: TextAlign,
    textDirection: TextDirection,
    lineHeight: TextUnit,
    textIndent: TextIndent?,
    platformStyle: PlatformTextStyle?,
    lineHeightStyle: LineHeightStyle?,
    lineBreak: LineBreak,
    hyphens: Hyphens,
    textMotion: TextMotion?
)
Cmn
TextStyle
copy(
    brush: Brush?,
    alpha: Float,
    fontSize: TextUnit,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?,
    fontFamily: FontFamily?,
    fontFeatureSettings: String?,
    letterSpacing: TextUnit,
    baselineShift: BaselineShift?,
    textGeometricTransform: TextGeometricTransform?,
    localeList: LocaleList?,
    background: Color,
    textDecoration: TextDecoration?,
    shadow: Shadow?,
    drawStyle: DrawStyle?,
    textAlign: TextAlign,
    textDirection: TextDirection,
    lineHeight: TextUnit,
    textIndent: TextIndent?,
    platformStyle: PlatformTextStyle?,
    lineHeightStyle: LineHeightStyle?,
    lineBreak: LineBreak,
    hyphens: Hyphens,
    textMotion: TextMotion?
)
Cmn
open operator Boolean
equals(other: Any?)
Cmn
Boolean
Cmn
Boolean

Returns true if text layout affecting attributes between this TextStyle and other are the same.

Cmn
open Int
Cmn
TextStyle

Returns a new text style that is a combination of this style and the given other style.

Cmn
TextStyle
merge(other: SpanStyle)

Returns a new text style that is a combination of this style and the given other style.

Cmn
TextStyle
merge(other: TextStyle?)

Returns a new text style that is a combination of this style and the given other style.

Cmn
TextStyle
merge(
    color: Color,
    fontSize: TextUnit,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?,
    fontFamily: FontFamily?,
    fontFeatureSettings: String?,
    letterSpacing: TextUnit,
    baselineShift: BaselineShift?,
    textGeometricTransform: TextGeometricTransform?,
    localeList: LocaleList?,
    background: Color,
    textDecoration: TextDecoration?,
    shadow: Shadow?,
    drawStyle: DrawStyle?,
    textAlign: TextAlign,
    textDirection: TextDirection,
    lineHeight: TextUnit,
    textIndent: TextIndent?,
    lineHeightStyle: LineHeightStyle?,
    lineBreak: LineBreak,
    hyphens: Hyphens,
    platformStyle: PlatformTextStyle?,
    textMotion: TextMotion?
)

Fast merge non-default values and parameters.

Cmn
operator TextStyle

Plus operator overload that applies a merge.

Cmn
operator TextStyle
plus(other: SpanStyle)

Plus operator overload that applies a merge.

Cmn
operator TextStyle
plus(other: TextStyle)

Plus operator overload that applies a merge.

Cmn
ParagraphStyle
Cmn
SpanStyle
Cmn
open String
Cmn

Public properties

Float

Opacity of text.

Cmn
Color

The background color for the text.

Cmn
BaselineShift?

The amount by which the text is shifted up from the current baseline.

Cmn
Brush?

The brush to use when drawing text.

Cmn
Color

The text color.

Cmn
Hyphens?

This property is deprecated. Kept for backwards compatibility.

Cmn
LineBreak?

This property is deprecated. Kept for backwards compatibility.

Cmn
TextAlign?

This property is deprecated. Kept for backwards compatibility.

Cmn
TextDirection?

This property is deprecated. Kept for backwards compatibility.

Cmn
DrawStyle?

Drawing style of text, whether fill in the text while drawing or stroke around the edges.

Cmn
FontFamily?

The font family to be used when rendering the text.

Cmn
String?

The advanced typography settings provided by font.

Cmn
TextUnit

The size of glyphs to use when painting the text.

Cmn
FontStyle?

The typeface variant to use when drawing the letters (e.g., italic).

Cmn
FontSynthesis?

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

Cmn
FontWeight?

The typeface thickness to use when painting the text (e.g., bold).

Cmn
Hyphens

The hyphens configuration of the paragraph.

Cmn
TextUnit

The amount of space to add between each letter.

Cmn
LineBreak

The line breaking configuration of the paragraph.

Cmn
TextUnit

Line height for the Paragraph in TextUnit unit, e.g. SP or EM.

Cmn
LineHeightStyle?

The configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line.

Cmn
LocaleList?

The locale list used to select region-specific glyphs.

Cmn
PlatformTextStyle?

Platform specific TextStyle parameters.

Cmn
Shadow?

The shadow effect applied on the text.

Cmn
TextAlign

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

Cmn
TextDecoration?

The decorations to paint on the text (e.g., an underline).

Cmn
TextDirection

The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left.

Cmn
TextGeometricTransform?

The geometric transformation applied the text.

Cmn
TextIndent?

The indentation of the paragraph.

Cmn
TextMotion?

Text character placement configuration, whether to optimize for animated or static text.

Cmn

Public companion properties

Default

val DefaultTextStyle

Constant for default text style.

Public constructors

TextStyle

TextStyle(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign = TextAlign.Unspecified,
    textDirection: TextDirection = TextDirection.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak = LineBreak.Unspecified,
    hyphens: Hyphens = Hyphens.Unspecified,
    textMotion: TextMotion? = null
)

Styling configuration for a Text.

import androidx.compose.material.Text
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp

Text(
    text = "Demo Text",
    style =
        TextStyle(
            color = Color.Red,
            fontSize = 16.sp,
            fontFamily = FontFamily.Monospace,
            fontWeight = FontWeight.W800,
            fontStyle = FontStyle.Italic,
            letterSpacing = 0.5.em,
            background = Color.LightGray,
            textDecoration = TextDecoration.Underline
        )
)
Parameters
color: Color = Color.Unspecified

The text color.

fontSize: TextUnit = TextUnit.Unspecified

The size of glyphs to use when painting the text. This may be TextUnit.Unspecified for inheriting from another TextStyle.

fontWeight: FontWeight? = null

The typeface thickness to use when painting the text (e.g., bold).

fontStyle: FontStyle? = null

The typeface variant to use when drawing the letters (e.g., italic).

fontSynthesis: FontSynthesis? = null

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

fontFamily: FontFamily? = null

The font family to be used when rendering the text.

fontFeatureSettings: String? = null

The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop

letterSpacing: TextUnit = TextUnit.Unspecified

The amount of space to add between each letter.

baselineShift: BaselineShift? = null

The amount by which the text is shifted up from the current baseline.

textGeometricTransform: TextGeometricTransform? = null

The geometric transformation applied the text.

localeList: LocaleList? = null

The locale list used to select region-specific glyphs.

background: Color = Color.Unspecified

The background color for the text.

textDecoration: TextDecoration? = null

The decorations to paint on the text (e.g., an underline).

shadow: Shadow? = null

The shadow effect applied on the text.

drawStyle: DrawStyle? = null

Drawing style of text, whether fill in the text while drawing or stroke around the edges.

textAlign: TextAlign = TextAlign.Unspecified

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

textDirection: TextDirection = TextDirection.Unspecified

The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left. If no value is provided the system will use the LayoutDirection as the primary signal.

lineHeight: TextUnit = TextUnit.Unspecified

Line height for the Paragraph in TextUnit unit, e.g. SP or EM.

textIndent: TextIndent? = null

The indentation of the paragraph.

platformStyle: PlatformTextStyle? = null

Platform specific TextStyle parameters.

lineHeightStyle: LineHeightStyle? = null

the configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line. The configuration is applied only when a lineHeight is defined. When null, LineHeightStyle.Default is used.

lineBreak: LineBreak = LineBreak.Unspecified

The line breaking configuration for the text.

hyphens: Hyphens = Hyphens.Unspecified

The configuration of hyphenation.

textMotion: TextMotion? = null

Text character placement, whether to optimize for animated or static text.

TextStyle

TextStyle(
    brush: Brush?,
    alpha: Float = Float.NaN,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign = TextAlign.Unspecified,
    textDirection: TextDirection = TextDirection.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    platformStyle: PlatformTextStyle? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak = LineBreak.Unspecified,
    hyphens: Hyphens = Hyphens.Unspecified,
    textMotion: TextMotion? = null
)

Styling configuration for a Text.

import androidx.compose.material.Text
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp

Text(
    text = "Demo Text",
    style =
        TextStyle(
            brush = Brush.linearGradient(listOf(Color.Red, Color.Blue, Color.Green)),
            alpha = 0.8f,
            fontSize = 16.sp,
            fontFamily = FontFamily.Monospace,
            fontWeight = FontWeight.W800,
            fontStyle = FontStyle.Italic,
            letterSpacing = 0.5.em,
            textDecoration = TextDecoration.Underline
        )
)
Parameters
brush: Brush?

The brush to use when painting the text. If brush is given as null, it will be treated as unspecified. It is equivalent to calling the alternative color constructor with Color.Unspecified

alpha: Float = Float.NaN

Opacity to be applied to brush from 0.0f to 1.0f representing fully transparent to fully opaque respectively.

fontSize: TextUnit = TextUnit.Unspecified

The size of glyphs to use when painting the text. This may be TextUnit.Unspecified for inheriting from another TextStyle.

fontWeight: FontWeight? = null

The typeface thickness to use when painting the text (e.g., bold).

fontStyle: FontStyle? = null

The typeface variant to use when drawing the letters (e.g., italic).

fontSynthesis: FontSynthesis? = null

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

fontFamily: FontFamily? = null

The font family to be used when rendering the text.

fontFeatureSettings: String? = null

The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop

letterSpacing: TextUnit = TextUnit.Unspecified

The amount of space to add between each letter.

baselineShift: BaselineShift? = null

The amount by which the text is shifted up from the current baseline.

textGeometricTransform: TextGeometricTransform? = null

The geometric transformation applied the text.

localeList: LocaleList? = null

The locale list used to select region-specific glyphs.

background: Color = Color.Unspecified

The background color for the text.

textDecoration: TextDecoration? = null

The decorations to paint on the text (e.g., an underline).

shadow: Shadow? = null

The shadow effect applied on the text.

drawStyle: DrawStyle? = null

Drawing style of text, whether fill in the text while drawing or stroke around the edges.

textAlign: TextAlign = TextAlign.Unspecified

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

textDirection: TextDirection = TextDirection.Unspecified

The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left. If no value is provided the system will use the LayoutDirection as the primary signal.

lineHeight: TextUnit = TextUnit.Unspecified

Line height for the Paragraph in TextUnit unit, e.g. SP or EM.

textIndent: TextIndent? = null

The indentation of the paragraph.

platformStyle: PlatformTextStyle? = null

Platform specific TextStyle parameters.

lineHeightStyle: LineHeightStyle? = null

the configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line. The configuration is applied only when a lineHeight is defined.

lineBreak: LineBreak = LineBreak.Unspecified

The line breaking configuration for the text.

hyphens: Hyphens = Hyphens.Unspecified

The configuration of hyphenation.

textMotion: TextMotion? = null

Text character placement, whether to optimize for animated or static text.

Public functions

copy

fun copy(
    color: Color = this.spanStyle.color,
    fontSize: TextUnit = this.spanStyle.fontSize,
    fontWeight: FontWeight? = this.spanStyle.fontWeight,
    fontStyle: FontStyle? = this.spanStyle.fontStyle,
    fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
    fontFamily: FontFamily? = this.spanStyle.fontFamily,
    fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
    letterSpacing: TextUnit = this.spanStyle.letterSpacing,
    baselineShift: BaselineShift? = this.spanStyle.baselineShift,
    textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
    localeList: LocaleList? = this.spanStyle.localeList,
    background: Color = this.spanStyle.background,
    textDecoration: TextDecoration? = this.spanStyle.textDecoration,
    shadow: Shadow? = this.spanStyle.shadow,
    drawStyle: DrawStyle? = this.spanStyle.drawStyle,
    textAlign: TextAlign = this.paragraphStyle.textAlign,
    textDirection: TextDirection = this.paragraphStyle.textDirection,
    lineHeight: TextUnit = this.paragraphStyle.lineHeight,
    textIndent: TextIndent? = this.paragraphStyle.textIndent,
    platformStyle: PlatformTextStyle? = this.platformStyle,
    lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
    lineBreak: LineBreak = this.paragraphStyle.lineBreak,
    hyphens: Hyphens = this.paragraphStyle.hyphens,
    textMotion: TextMotion? = this.paragraphStyle.textMotion
): TextStyle

copy

fun copy(
    brush: Brush?,
    alpha: Float = this.spanStyle.alpha,
    fontSize: TextUnit = this.spanStyle.fontSize,
    fontWeight: FontWeight? = this.spanStyle.fontWeight,
    fontStyle: FontStyle? = this.spanStyle.fontStyle,
    fontSynthesis: FontSynthesis? = this.spanStyle.fontSynthesis,
    fontFamily: FontFamily? = this.spanStyle.fontFamily,
    fontFeatureSettings: String? = this.spanStyle.fontFeatureSettings,
    letterSpacing: TextUnit = this.spanStyle.letterSpacing,
    baselineShift: BaselineShift? = this.spanStyle.baselineShift,
    textGeometricTransform: TextGeometricTransform? = this.spanStyle.textGeometricTransform,
    localeList: LocaleList? = this.spanStyle.localeList,
    background: Color = this.spanStyle.background,
    textDecoration: TextDecoration? = this.spanStyle.textDecoration,
    shadow: Shadow? = this.spanStyle.shadow,
    drawStyle: DrawStyle? = this.spanStyle.drawStyle,
    textAlign: TextAlign = this.paragraphStyle.textAlign,
    textDirection: TextDirection = this.paragraphStyle.textDirection,
    lineHeight: TextUnit = this.paragraphStyle.lineHeight,
    textIndent: TextIndent? = this.paragraphStyle.textIndent,
    platformStyle: PlatformTextStyle? = this.platformStyle,
    lineHeightStyle: LineHeightStyle? = this.paragraphStyle.lineHeightStyle,
    lineBreak: LineBreak = this.paragraphStyle.lineBreak,
    hyphens: Hyphens = this.paragraphStyle.hyphens,
    textMotion: TextMotion? = this.paragraphStyle.textMotion
): TextStyle

equals

open operator fun equals(other: Any?): Boolean

hasSameDrawAffectingAttributes

fun hasSameDrawAffectingAttributes(other: TextStyle): Boolean

hasSameLayoutAffectingAttributes

fun hasSameLayoutAffectingAttributes(other: TextStyle): Boolean

Returns true if text layout affecting attributes between this TextStyle and other are the same.

The attributes that do not require a layout change are color, textDecoration and shadow.

Majority of attributes change text layout, and examples are line height, font properties, font size, locale etc.

This function can be used to identify if a new text layout is required for a given TextStyle.

Parameters
other: TextStyle

The TextStyle to compare to.

hashCode

open fun hashCode(): Int

merge

fun merge(other: ParagraphStyle): TextStyle

Returns a new text style that is a combination of this style and the given other style.

See also
merge

merge

fun merge(other: SpanStyle): TextStyle

Returns a new text style that is a combination of this style and the given other style.

See also
merge

merge

fun merge(other: TextStyle? = null): TextStyle

Returns a new text style that is a combination of this style and the given other style.

other text style's null or inherit properties are replaced with the non-null properties of this text style. Another way to think of it is that the "missing" properties of the other style are filled by the properties of this style.

If the given text style is null, returns this text style.

merge

fun merge(
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null,
    fontFamily: FontFamily? = null,
    fontFeatureSettings: String? = null,
    letterSpacing: TextUnit = TextUnit.Unspecified,
    baselineShift: BaselineShift? = null,
    textGeometricTransform: TextGeometricTransform? = null,
    localeList: LocaleList? = null,
    background: Color = Color.Unspecified,
    textDecoration: TextDecoration? = null,
    shadow: Shadow? = null,
    drawStyle: DrawStyle? = null,
    textAlign: TextAlign = TextAlign.Unspecified,
    textDirection: TextDirection = TextDirection.Unspecified,
    lineHeight: TextUnit = TextUnit.Unspecified,
    textIndent: TextIndent? = null,
    lineHeightStyle: LineHeightStyle? = null,
    lineBreak: LineBreak = LineBreak.Unspecified,
    hyphens: Hyphens = Hyphens.Unspecified,
    platformStyle: PlatformTextStyle? = null,
    textMotion: TextMotion? = null
): TextStyle

Fast merge non-default values and parameters.

This is the same algorithm as merge but does not require allocating it's parameter and may return this instead of allocating a result when all values are default.

This is a similar algorithm to copy but when either this or a parameter are set to a default value, the other value will take precedent.

To explain better, consider the following examples:

Example 1:

Example 2:

Example 3:

You should always use this method over the merge overload when you do not already have a TextStyle allocated. You should chose this over copy when building a theming system and applying styling information to a specific usage.

Returns
TextStyle

this or a new TextLayoutResult with all parameters chosen to the non-default option provided.

See also
merge

plus

operator fun plus(other: ParagraphStyle): TextStyle

Plus operator overload that applies a merge.

plus

operator fun plus(other: SpanStyle): TextStyle

Plus operator overload that applies a merge.

plus

operator fun plus(other: TextStyle): TextStyle

Plus operator overload that applies a merge.

toParagraphStyle

fun toParagraphStyle(): ParagraphStyle

toSpanStyle

fun toSpanStyle(): SpanStyle

toString

open fun toString(): String

Public properties

alpha

val alphaFloat

Opacity of text. This value is either provided along side Brush, or via alpha channel in color.

background

val backgroundColor

The background color for the text.

baselineShift

val baselineShiftBaselineShift?

The amount by which the text is shifted up from the current baseline.

brush

val brushBrush?

The brush to use when drawing text. If not null, overrides color.

color

val colorColor

The text color.

deprecated_boxing_hyphens

val deprecated_boxing_hyphensHyphens?

deprecated_boxing_lineBreak

val deprecated_boxing_lineBreakLineBreak?

deprecated_boxing_textAlign

val deprecated_boxing_textAlignTextAlign?

deprecated_boxing_textDirection

val deprecated_boxing_textDirectionTextDirection?

drawStyle

val drawStyleDrawStyle?

Drawing style of text, whether fill in the text while drawing or stroke around the edges.

fontFamily

val fontFamilyFontFamily?

The font family to be used when rendering the text.

fontFeatureSettings

val fontFeatureSettingsString?

The advanced typography settings provided by font. The format is the same as the CSS font-feature-settings attribute: https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop

fontSize

val fontSizeTextUnit

The size of glyphs to use when painting the text. This may be TextUnit.Unspecified for inheriting from another TextStyle.

fontStyle

val fontStyleFontStyle?

The typeface variant to use when drawing the letters (e.g., italic).

fontSynthesis

val fontSynthesisFontSynthesis?

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

fontWeight

val fontWeightFontWeight?

The typeface thickness to use when painting the text (e.g., bold).

hyphens

val hyphensHyphens

The hyphens configuration of the paragraph.

letterSpacing

val letterSpacingTextUnit

The amount of space to add between each letter.

lineBreak

val lineBreakLineBreak

The line breaking configuration of the paragraph.

lineHeight

val lineHeightTextUnit

Line height for the Paragraph in TextUnit unit, e.g. SP or EM.

lineHeightStyle

val lineHeightStyleLineHeightStyle?

The configuration for line height such as vertical alignment of the line, whether to apply additional space as a result of line height to top of first line top and bottom of last line.

The configuration is applied only when a lineHeight is defined.

When null, LineHeightStyle.Default is used.

localeList

val localeListLocaleList?

The locale list used to select region-specific glyphs.

platformStyle

val platformStylePlatformTextStyle?

Platform specific TextStyle parameters.

shadow

val shadowShadow?

The shadow effect applied on the text.

textAlign

val textAlignTextAlign

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

textDecoration

val textDecorationTextDecoration?

The decorations to paint on the text (e.g., an underline).

textDirection

val textDirectionTextDirection

The algorithm to be used to resolve the final text and paragraph direction: Left To Right or Right To Left. If no value is provided the system will use the LayoutDirection as the primary signal.

textGeometricTransform

val textGeometricTransformTextGeometricTransform?

The geometric transformation applied the text.

textIndent

val textIndentTextIndent?

The indentation of the paragraph.

textMotion

val textMotionTextMotion?

Text character placement configuration, whether to optimize for animated or static text.