> Documentation index: https://developer.android.com/reference/llms.txt

# TextStyleScope

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/TextStyleScope.kt+class:androidx.compose.ui.text.TextStyleScope) Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01) Common/AllAndroid/JVM
- Cmn

  ```
  sealed interface TextStyleScope
  ```
Known direct subclasses [ReusableTextStyleScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/ReusableTextStyleScope.md.txt)

|---|---|
| `ReusableTextStyleScope` | Mutable `TextStyleScope` implementation reused across layout and draw passes to avoid allocations. |

*** ** * ** ***

Configures layout- and draw-affecting text attributes for `BasicText`.

Use this scope in the `styleProvider` lambda parameter of `BasicText`. State reads performed within this scope are observed during the layout phase, skipping recomposition when invalidated and re-evaluating during measurement (recalculating text layout only when layout-affecting attributes change).

## Summary

| ### Public functions |
|---|---|---|
| `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 |
| `Unit` | `setBackground(background: Color)` Sets the background color covering the entire line height from start to end. | Cmn |
| `Unit` | `setBaselineShift(baselineShift: BaselineShift)` Sets the vertical shift amount from the baseline (e.g., `BaselineShift.Superscript`). | Cmn |
| `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 |
| `Unit` | `setColor(color: Color)` Sets the color to apply to the text. | Cmn |
| `Unit` | `setDrawStyle(drawStyle: DrawStyle)` Sets the drawing style of the text (fill or stroke). | Cmn |
| `Unit` | `setFontFamily(fontFamily: FontFamily)` Sets the font family used when rendering text. | Cmn |
| `Unit` | `setFontFeatureSettings(fontFeatureSettings: String)` Sets advanced typography settings in CSS format (e.g., `"smcp"` for small caps). | Cmn |
| `Unit` | `setFontSize(fontSize: TextUnit)` Sets the size of glyphs to use when painting the text (e.g., `16.sp`). | Cmn |
| `Unit` | `setFontStyle(fontStyle: FontStyle)` Sets the typeface variant to use when drawing letters (e.g., `FontStyle.Italic`). | Cmn |
| `Unit` | `setFontSynthesis(fontSynthesis: FontSynthesis)` Sets the font synthesis rules determining if and how bold/italic styles are synthesized when the font family does not natively support them. | Cmn |
| `Unit` | `setFontWeight(fontWeight: FontWeight)` Sets the typeface thickness to use when painting the text (e.g., `FontWeight.Bold`). | Cmn |
| `Unit` | `setHyphens(hyphens: Hyphens)` Sets the hyphenation configuration of the paragraph. | Cmn |
| `Unit` | `setLetterSpacing(letterSpacing: TextUnit)` Sets the amount of space to add between letters (in SP or EM). | Cmn |
| `Unit` | `setLineBreak(lineBreak: LineBreak)` Sets the line breaking configuration of the paragraph. | Cmn |
| `Unit` | `setLineHeight(lineHeight: TextUnit)` Sets the line height for the paragraph (e.g., `24.sp`). | Cmn |
| `Unit` | `setLineHeightStyle(lineHeightStyle: LineHeightStyle)` Sets the line height distribution configuration. | Cmn |
| `Unit` | `setLocaleList(localeList: LocaleList)` Sets the locale list used to select region-specific glyphs. | Cmn |
| `Unit` | `setPlatformStyle(platformStyle: PlatformTextStyle)` Sets platform-specific text styling parameters. | Cmn |
| `Unit` | `setShadow(shadow: Shadow)` Sets the shadow effect applied to the text. | Cmn |
| `Unit` | `setTextAlign(textAlign: TextAlign)` Sets the alignment of the text within lines of the paragraph. | Cmn |
| `Unit` | `setTextDecoration(textDecoration: TextDecoration)` Sets the decorations to paint on the text (e.g., `TextDecoration.Underline`). | Cmn |
| `Unit` | `setTextDirection(textDirection: TextDirection)` Sets the algorithm used to resolve text direction. | Cmn |
| `Unit` | `setTextGeometricTransform( textGeometricTransform: TextGeometricTransform )` Sets the geometric transformation to apply to the text. | Cmn |
| `Unit` | `setTextIndent(textIndent: TextIndent)` Sets the paragraph indentation. | Cmn |
| `Unit` | `setTextMotion(textMotion: TextMotion)` Sets the text character placement optimization for animated or static text. | Cmn |
| `Unit` | `setTextStyle(style: TextStyle)` Sets all text attributes from `style`. | Cmn |

## Public functions

### setAlpha

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setBackground(background: Color): Unit
```

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

### setBaselineShift

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setDrawStyle(drawStyle: DrawStyle): Unit
```

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

### setFontFamily

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setFontFamily(fontFamily: FontFamily): Unit
```

Sets the font family used when rendering text.

### setFontFeatureSettings

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setFontFeatureSettings(fontFeatureSettings: String): Unit
```

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

### setFontSize

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setFontSize(fontSize: TextUnit): Unit
```

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

### setFontStyle

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setFontStyle(fontStyle: FontStyle): Unit
```

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

### setFontSynthesis

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setFontWeight(fontWeight: FontWeight): Unit
```

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

### setHyphens

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setHyphens(hyphens: Hyphens): Unit
```

Sets the hyphenation configuration of the paragraph.

### setLetterSpacing

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setLetterSpacing(letterSpacing: TextUnit): Unit
```

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

### setLineBreak

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setLineBreak(lineBreak: LineBreak): Unit
```

Sets the line breaking configuration of the paragraph.

### setLineHeight

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setLineHeight(lineHeight: TextUnit): Unit
```

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

### setLineHeightStyle

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setLineHeightStyle(lineHeightStyle: LineHeightStyle): Unit
```

Sets the line height distribution configuration.

### setLocaleList

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setLocaleList(localeList: LocaleList): Unit
```

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

### setPlatformStyle

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setPlatformStyle(platformStyle: PlatformTextStyle): Unit
```

Sets platform-specific text styling parameters.

### setShadow

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setShadow(shadow: Shadow): Unit
```

Sets the shadow effect applied to the text.

### setTextAlign

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setTextAlign(textAlign: TextAlign): Unit
```

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

### setTextDecoration

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setTextDecoration(textDecoration: TextDecoration): Unit
```

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

### setTextDirection

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setTextDirection(textDirection: TextDirection): Unit
```

Sets the algorithm used to resolve text direction.

### setTextGeometricTransform

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setTextGeometricTransform(
    textGeometricTransform: TextGeometricTransform
): Unit
```

Sets the geometric transformation to apply to the text.

### setTextIndent

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setTextIndent(textIndent: TextIndent): Unit
```

Sets the paragraph indentation.

### setTextMotion

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
fun setTextMotion(textMotion: TextMotion): Unit
```

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

### setTextStyle

Cmn Added in [1.14.0-alpha01](https://developer.android.com/jetpack/androidx/releases/compose-ui.md.txt#1.14.0-alpha01)

```
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 |