<div class='sourceset sourceset-android'>Android</div>

```kotlin
interface TypefaceLoader
```

Loader for loading an [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) and producing an [android.graphics.Typeface](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Typeface).

This interface is not intended to be used by application developers for text display. To load
a typeface for display use [FontFamily.Resolver](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/FontFamily.Resolver).

[TypefaceLoader](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/AndroidFont.TypefaceLoader) allows the introduction of new types of font descriptors for use in
[FontListFontFamily](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontListFontFamily). A [TypefaceLoader](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/AndroidFont.TypefaceLoader) allows a new subclass of [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) to be used by
normal compose text rendering methods.

Examples of new types of fonts that [TypefaceLoader](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/AndroidFont.TypefaceLoader) can add:
- `FontLoadingStrategy.Blocking` [Font](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Font) that loads Typeface from a local resource not supported by an existing font
- `FontLoadingStrategy.OptionalLocal` [Font](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Font) that "loads" a platform Typeface only available on some devices.
- `FontLoadingStrategy.Async` [Font](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Font) that loads a font from a backend via a network request.

During resolution from [FontFamily.Resolver](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/FontFamily.Resolver), an [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) subclass will be queried for
an appropriate loader.

The loader attached to an instance of an [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) is only required to be able to load
that instance, though it is advised to create one loader for all instances of the same
subclass and share them between [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) instances to avoid allocations or allow
caching.

## Functions

<h2 id="loadblocking-context-font">loadBlocking</h2>

```kotlin
fun loadBlocking(context: Context, font: AndroidFont): Typeface?
```

Immediately load the font in a blocking manner such that it will be available this frame.

This method will be called on a UI-critical thread, however it has been determined that
this font is required for the current frame. This method is allowed to perform small
amounts of I/O to load a font file from disk.

This method should never perform expensive I/O operations, such as loading from a remote
source. If expensive operations are required to complete the font, this method may choose
to throw. Note that this method will never be called for fonts with
`FontLoadingStrategy.Async`.

It is possible for [loadBlocking](#loadblocking) to be called for the same instance of [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) in
parallel. Implementations should support parallel concurrent loads, or de-dup.

#### Parameters

| | |
| --- | --- |
| context | current Android context for loading the font |
| font | the font to load which contains this loader as [AndroidFont.typefaceLoader](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) |

#### Returns

| | |
| --- | --- |
|  | [android.graphics.Typeface](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Typeface) for loaded font, or null if the font fails to load |

<hr class="docs-overload-divider">

<h2 id="awaitload-context-font">awaitLoad</h2>

```kotlin
suspend fun awaitLoad(context: Context, font: AndroidFont): Typeface?
```

Asynchronously load the font, from either local or remote sources such that it will cause
text reflow when loading completes.

This method will be called on a UI-critical thread, and should not block the thread for
font loading from sources slower than the local filesystem. More expensive loads should
dispatch to an appropriate thread.

This method is always called in a timeout context and must return it's final value within
15 seconds. If the Typeface is not resolved within 15 seconds, the async load is
cancelled and considered a permanent failure. Implementations should use structured
concurrency to cooperatively cancel work.

Compose does not know what resources are required to satisfy a font load. Subclasses
implementing `FontLoadingStrategy.Async` behavior should ensure requests are de-duped for
the same resource.

It is possible for [awaitLoad](#awaitload) to be called for the same instance of [AndroidFont](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) in
parallel. Implementations should support parallel concurrent loads, or de-dup.

#### Parameters

| | |
| --- | --- |
| context | current Android context for loading the font |
| font | the font to load which contains this loader as [AndroidFont.typefaceLoader](/jetpack-compose/androidx.compose.ui/ui-text/classes/AndroidFont) |

#### Returns

| | |
| --- | --- |
|  | [android.graphics.Typeface](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Typeface) for loaded font, or null if not available |