# FontLoadingStrategy

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/FontLoadingStrategy.kt+class:androidx.compose.ui.text.font.FontLoadingStrategy) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.0) Common/AllAndroid/JVM
- Cmn

  ```
  value class FontLoadingStrategy
  ```

*** ** * ** ***

Font loading strategy for a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` in a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontListFontFamily`.

This controls how font loading resolves when displaying text in Compose.

For more information about font family resolution see `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`.

## Summary

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()` Loading this font will never block, and will load on a background thread. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Blocking()` Resolving this font will always block until the font loads. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` Resolving this font is best-effort and will attempt to load from a local resource that MAY be available. | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#value()` | Cmn |

## Public companion properties

### Async

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

```
val Async: FontLoadingStrategy
```

Loading this font will never block, and will load on a background thread.

During loading, the app will not block but instead will find the next available font that is immediately available (`https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Blocking()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()`). When the font finishes loading, text will reflow with the resolved typeface.

If no fallback fonts are available immediately, the platform default typeface will be used to draw text during loading.

If loading fails, the failure is stored permanently, and future uses of the font will always use the fallback.

This should typically not be used for fonts that are stored on-device and needed for the first frame. Instead use `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Blocking()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()`.

This should always be used for fonts that are fetched from a remote source such as over http.

### Blocking

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

```
val Blocking: FontLoadingStrategy
```

Resolving this font will always block until the font loads.

This means that the first frame that uses this font will always display using the desired font, and text will never reflow.

This should typically be used for fonts that stored on-device. It is acceptable to block the first frame of an application to read a font from disk.

This should typically not be used for fonts that are fetched from a remote source such as over http, as it will block all rendering until the font loads. Instead use `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()`.

### OptionalLocal

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

```
val OptionalLocal: FontLoadingStrategy
```

Resolving this font is best-effort and will attempt to load from a local resource that MAY be available.

Resolving this font will always block until the font resolves, and text will never reflow.

An `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` font describes a font that is installed locally, such as an optional system installed font. Resolution of an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` font is expected to fail whenever the resource is not available, which will fallback to the next font in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`.

Typical usages involve following the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` font with the same font loaded from a remote `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()` source. It may also be followed by other `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` fonts or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Blocking()` fonts that have less specific styling to avoid async delay.

Apps should expect that `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` fonts will fail to load on devices where the font is not available.

- 

This should typically not be used for fonts that are fetched from a remote source such as over http, as it will block all rendering until the font loads. Instead use `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()`.

## Public functions

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### value

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

```
val value: Int
```