# TextAppearanceSpanCompat

Artifact: [androidx.appcompat:appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) [View Source](https://cs.android.com/search?q=file:androidx/appcompat/text/TextAppearanceSpanCompat.kt+class:androidx.appcompat.text.TextAppearanceSpanCompat) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.8.0)

*** ** * ** ***


```
public final class TextAppearanceSpanCompat extends MetricAffectingSpan
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) |||
|   | ↳ | [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) ||
|   |   | ↳ | [androidx.appcompat.text.TextAppearanceSpanCompat](https://developer.android.com/reference/androidx/appcompat/text/TextAppearanceSpanCompat) |

*** ** * ** ***

A TextAppearanceSpan works with Android X Downloadable Font

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/text/TextAppearanceSpanCompat` | `https://developer.android.com/reference/androidx/appcompat/text/TextAppearanceSpanCompat#create(android.content.Context,kotlin.Int,kotlin.Int,java.util.concurrent.Executor,java.lang.Runnable)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context, int appearance, int colorList, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html onComplete )` Creates a TextAppearanceSpanCompat. |
| `void` | `https://developer.android.com/reference/androidx/appcompat/text/TextAppearanceSpanCompat#updateDrawState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint.html ds)` |
| `void` | `https://developer.android.com/reference/androidx/appcompat/text/TextAppearanceSpanCompat#updateMeasureState(android.text.TextPaint)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/text/TextPaint.html ds)` |

### Inherited methods

From [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html) `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html` `https://developer.android.com/reference/android/text/style/MetricAffectingSpan.html#getUnderlying()()`

## Public methods

### create

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.8.0)

```
public static final @NonNull TextAppearanceSpanCompat create(
    @NonNull Context context,
    int appearance,
    int colorList,
    @NonNull Executor executor,
    @NonNull Runnable onComplete
)
```

Creates a TextAppearanceSpanCompat.

The android:fontFamily may need to fetched asynchronously. The returned TextAppearanceSpanCompat may not immediately reflect the custom font, but it will be updated once the font is fetched. The provided callback will not be executed if the asynchronous fetch is not needed.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html context` | The context to use. |
| `int appearance` | The resource ID of a TextAppearance style. |
| `int colorList` | The resource ID of a ColorStateList. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | The executor to use for fetching the font. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html onComplete` | A runnable to be executed when the font fetching is complete. This runnable will be executed on the executor's thread. The client is responsible for invalidating the text layout if necessary. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appcompat/text/TextAppearanceSpanCompat` | A TextAppearanceSpanCompat. |

### updateDrawState

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.8.0)

```
public void updateDrawState(TextPaint ds)
```

### updateMeasureState

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.8.0)

```
public void updateMeasureState(@NonNull TextPaint ds)
```