# Font

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

  ```
  interface Font
  ```
Known direct subclasses [AndroidFont](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/AndroidFont), [ResourceFont](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/AndroidFont` | Font for use on Android. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont` | Defines a font to be used while rendering text with resource ID. |

*** ** * ** ***

The interface of the font resource.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont` |   |

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font.ResourceLoader` **This interface is deprecated.** Replaced with FontFamily.Resolver during the introduction of async fonts, all usages should be replaced. |

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font#MaximumAsyncTimeoutMillis()` This is the global timeout for fetching an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()` font. | Cmn |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font#loadingStrategy()` Loading strategy for this font. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font#style()` The style of the font, normal or italic. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font#variationSettings()` Variation settings to apply to this font. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font#weight()` The weight of the font. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font#(androidx.compose.ui.text.font.Font).toFontFamily()()` Create a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` from this single `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font`. | Cmn |

## Constants

### MaximumAsyncTimeoutMillis

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

```
const val MaximumAsyncTimeoutMillis: Long
```

This is the global timeout for fetching an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()` font.

This defines the "loading" window for a font. After this timeout, a font load may no longer trigger text reflow and is considered "resolved."

Each async font is given separate loading window and goes through these states:

```kotlin
(initial) -> (loading with timeout) -> (resolved)
```

- In the initial state, a fallback typeface is used to display text, which will reflow if the font successfully loads.

- In the loading state, the font continues to use the fallback typeface and may cause one text reflow by finishing load. After a successful load it is considered resolved and will not cause another text reflow.

- If the font fails to load by the timeout, the failure is permanent, and the font will never attempt to load again. Failure never causes text reflow.

After a font is in resolved, it will never cause text reflow unless it is evicted from the font cache and re-enters initial.

This timeout is not configurable, and timers are maintained globally.

## Public properties

### loadingStrategy

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

```
open val loadingStrategy: FontLoadingStrategy
```

Loading strategy for this font.

### style

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

```
val style: FontStyle
```

The style of the font, normal or italic. The system uses this to match a font to a font request that is given in a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle`.

### variationSettings

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.13.0-rc01)

```
open val variationSettings: FontVariation.Settings
```

Variation settings to apply to this font.

### weight

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

```
val weight: FontWeight
```

The weight of the font. The system uses this to match a font to a font request that is given in a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/SpanStyle`.

## Extension functions

### Font.toFontFamily

Cmn Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/font/Font.kt+function:toFontFamily)

```
fun Font.toFontFamily(): FontFamily
```

Create a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` from this single `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font`.