# androidx.compose.ui.text.font

Common/AllAndroid/JVM

## Interfaces

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/AndroidFont.TypefaceLoader` | Loader for loading an `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/AndroidFont` and producing an `https://developer.android.com/reference/android/graphics/Typeface.html`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | The interface of the font resource. | Cmn |
| `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. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily.Resolver` | Main interface for resolving `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` into a platform-specific typeface for use in Compose-based applications. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Setting` | Represents a single point in a variation, such as 0.7 or 100 | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` | A class that can be used for changing the font used in text. | Cmn |

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/AndroidFont` | Font for use on Android. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/DeviceFontFamilyName` | An Android system installed font family name as used by `https://developer.android.com/reference/android/graphics/Typeface.html#create(android.graphics.Typeface, int)`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FileBasedFontFamily` | A base class of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`s that is created from file sources. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | The primary typography interface for Compose applications. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontListFontFamily` | Defines a font family with list of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/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`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle` | Defines whether the font is `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle#Italic()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle#Normal()`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis` | Possible options for font synthesis. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings` | A collection of settings to apply to a single font. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight` | The thickness of the glyphs, in a range of 1, 1000. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/GenericFontFamily` | Defines a font family with a generic font family name. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/LoadedFontFamily` | Defines a font family that is already loaded Typeface. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont` | Defines a font to be used while rendering text with resource ID. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/SystemFontFamily` | A base class of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`s installed on the system. | Cmn |

## Objects

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation` | Set font variation settings. | Cmn |

## Top-level functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(androidx.compose.ui.text.font.DeviceFontFamilyName,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)( familyName: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/DeviceFontFamilyName, weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings )` Describes a system-installed font that may be present on some Android devices. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(android.os.ParcelFileDescriptor,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)( fileDescriptor: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html, weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings )` Create a Font declaration from a `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(java.io.File,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)( file: https://developer.android.com/reference/java/io/File.html, weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings )` Create a Font declaration from a file. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(kotlin.Int,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontLoadingStrategy)( resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, loadingStrategy: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy )` Creates a Font using a resource ID. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(kotlin.String,android.content.res.AssetManager,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)( path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, assetManager: https://developer.android.com/reference/android/content/res/AssetManager.html, weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings )` Create a Font declaration from a file in the assets directory. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(kotlin.Int,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontLoadingStrategy,androidx.compose.ui.text.font.FontVariation.Settings)( resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, loadingStrategy: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy, variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings )` Creates a Font using a resource ID and variation settings. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#FontFamily(kotlin.Array)(vararg fonts: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font)` Construct a font family that contains list of custom font files. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#FontFamily(kotlin.collections.List)(fonts: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font>)` Construct a font family that contains list of custom font files. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#FontFamily(android.graphics.Typeface)(typeface: https://developer.android.com/reference/android/graphics/Typeface.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#FontFamily(android.graphics.Typeface)` from Android `https://developer.android.com/reference/android/graphics/Typeface.html`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#FontFamily(androidx.compose.ui.text.font.Typeface)(typeface: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface)` Construct a font family that contains loaded font family: Typeface. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Typeface(android.graphics.Typeface)(typeface: https://developer.android.com/reference/android/graphics/Typeface.html)` Returns a Compose `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` from Android `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Typeface(android.graphics.Typeface)`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` | `[Typeface](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Typeface(android.content.Context,androidx.compose.ui.text.font.FontFamily,kotlin.collections.List))( context: https://developer.android.com/reference/android/content/Context.html, fontFamily: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily, styles: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle>>? )` **This function is deprecated.** This API is deprecated with the introduction of async fonts which cannot resolve in this context. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily.Resolver` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#createFontFamilyResolver(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)` Create a new fontFamilyResolver for use outside of composition context | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily.Resolver` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#createFontFamilyResolver(android.content.Context,kotlin.coroutines.CoroutineContext)( context: https://developer.android.com/reference/android/content/Context.html, coroutineContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html )` Create a new fontFamilyResolver for use outside of composition context with a coroutine context. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily.Resolver` | `[createFontFamilyResolver](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#createFontFamilyResolver(androidx.compose.ui.text.font.Font.ResourceLoader,android.content.Context))( fontResourceLoader: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font.ResourceLoader, context: https://developer.android.com/reference/android/content/Context.html )` **This function is deprecated.** This exists to bridge existing Font.ResourceLoader subclasses to be used as aFontFamily.ResourceLoader during upgrade. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)(start: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, stop: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, fraction: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Linearly interpolate between two font weights. | Cmn |

## Extension functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/State<https://developer.android.com/reference/android/graphics/Typeface.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily.Resolver.https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#(androidx.compose.ui.text.font.FontFamily.Resolver).resolveAsTypeface(androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontSynthesis)( fontFamily: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily?, fontWeight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, fontStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle, fontSynthesis: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis )` Resolve a font to an Android Typeface | android |
| `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/package-summary#(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 |

## Top-level functions

### Font

android 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/DeviceFontFamilyNameFont.android.kt+function:Font) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun Font(
    familyName: DeviceFontFamilyName,
    weight: FontWeight = FontWeight.Normal,
    style: FontStyle = FontStyle.Normal,
    variationSettings: FontVariation.Settings = FontVariation.Settings()
): Font
```

Describes a system-installed font that may be present on some Android devices.

You should assume this will not resolve on some devices and provide an appropriate fallback font.

Family name lookup is device and platform-specific, and different OEMs may install different fonts. All fonts described this way are considered `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#OptionalLocal()` and will continue to the next font in the chain if they are not present on a device.

Use this method to prefer locally pre-loaded system fonts when they are available. System fonts are always more efficient to load than reading a font file, or downloadable fonts.

A system installed font resolution will never trigger text reflow.

This descriptor will trust the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(androidx.compose.ui.text.font.DeviceFontFamilyName,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(androidx.compose.ui.text.font.DeviceFontFamilyName,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)` parameters as accurate. However, it is not required that the loaded fonts actually support the requested weight and style and this may trigger platform level font-synthesis of fake bold or fake italic during font resolution.

This Font can not describe the system-installed `https://developer.android.com/reference/android/graphics/Typeface.html#DEFAULT`. All other system-installed fonts are allowed.

Note: When setting `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Font(androidx.compose.ui.text.font.DeviceFontFamilyName,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontVariation.Settings)` any unset axis may be reset to the font default, ignoring any axis restrictions in `fonts.xml` or `font_customizations.xml`. This may have surprising side-effects when named fonts differ only by the default axis settings in XML. When setting variation axis for device fonts, ensure you set all possible settings for the font.

| Parameters |
|---|---|
| `familyName: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/DeviceFontFamilyName` | Android system-installed font family name |
| `weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | weight to load |
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | style to load |
| `variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings = FontVariation.Settings()` | font variation settings, unset by default to load default VF from system |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if familyName is empty |

### Font

android 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/AndroidFont.android.kt+function:Font) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
@RequiresApi(value = 26)
fun Font(
    fileDescriptor: ParcelFileDescriptor,
    weight: FontWeight = FontWeight.Normal,
    style: FontStyle = FontStyle.Normal,
    variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style)
): Font
```

Create a Font declaration from a `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html`. The content of the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` is read during construction.

| Parameters |
|---|---|
| `fileDescriptor: https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` | the file descriptor for the font file. |
| `weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | 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`. |
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | 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: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings = FontVariation.Settings(weight, style)` | these settings are applied to a variable font when the font is loaded |

### Font

android 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/AndroidFont.android.kt+function:Font) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun Font(
    file: File,
    weight: FontWeight = FontWeight.Normal,
    style: FontStyle = FontStyle.Normal,
    variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style)
): Font
```

Create a Font declaration from a file. The content of the `https://developer.android.com/reference/java/io/File.html` is read during construction.

| Parameters |
|---|---|
| `file: https://developer.android.com/reference/java/io/File.html` | the font file. |
| `weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | 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`. |
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | 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: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings = FontVariation.Settings(weight, style)` | on API 26 and above these settings are applied to a variable font when the font is loaded |

### Font

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:Font) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun Font(
    resId: Int,
    weight: FontWeight = FontWeight.Normal,
    style: FontStyle = FontStyle.Normal,
    loadingStrategy: FontLoadingStrategy = FontLoadingStrategy.Blocking
): Font
```

Creates a Font using a resource ID.

Allows control over `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy` strategy. You may supply `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()` for fonts that are expected on the first frame.

`https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()`, will load the font in the background and cause text reflow when loading completes. Fonts loaded from a remote source via resources should use `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()`.

| Parameters |
|---|---|
| `resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource ID of the font file in font resources. i.e. "R.font.myfont". |
| `weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | 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`. |
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | 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`. |
| `loadingStrategy: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy = FontLoadingStrategy.Blocking` | Load strategy for this font, may be async for async resource fonts |

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

### Font

android 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/AndroidFont.android.kt+function:Font) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun Font(
    path: String,
    assetManager: AssetManager,
    weight: FontWeight = FontWeight.Normal,
    style: FontStyle = FontStyle.Normal,
    variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style)
): Font
```

Create a Font declaration from a file in the assets directory. The content of the `https://developer.android.com/reference/java/io/File.html` is read during construction.

| Parameters |
|---|---|
| `path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | full path starting from the assets directory (i.e. dir/myfont.ttf for assets/dir/myfont.ttf). |
| `assetManager: https://developer.android.com/reference/android/content/res/AssetManager.html` | Android AssetManager |
| `weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | 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`. |
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | 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: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings = FontVariation.Settings(weight, style)` | on API 26 and above these settings are applied to a variable font when the font is loaded |

### Font

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:Font) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun Font(
    resId: Int,
    weight: FontWeight = FontWeight.Normal,
    style: FontStyle = FontStyle.Normal,
    loadingStrategy: FontLoadingStrategy = FontLoadingStrategy.Blocking,
    variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style)
): Font
```

Creates a Font using a resource ID and variation settings.

Allows control over `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy` strategy. You may supply `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()` for fonts that are expected on the first frame.

`https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()`, will load the font in the background and cause text reflow when loading completes. Fonts loaded from a remote source via resources should use `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy#Async()`.

| Parameters |
|---|---|
| `resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The resource ID of the font file in font resources. i.e. "R.font.myfont". |
| `weight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | 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`. |
| `style: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | 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`. |
| `loadingStrategy: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontLoadingStrategy = FontLoadingStrategy.Blocking` | Load strategy for this font, may be async for async resource fonts |
| `variationSettings: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontVariation.Settings = FontVariation.Settings(weight, style)` | Variation settings to apply to the font |

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

### FontFamily

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/FontFamily.kt+function:FontFamily) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun FontFamily(vararg fonts: Font): FontFamily
```

Construct a font family that contains list of custom font files.

| Parameters |
|---|---|
| `vararg fonts: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font` | list of font files |

### FontFamily

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/FontFamily.kt+function:FontFamily)

```
fun FontFamily(fonts: List<Font>): FontFamily
```

Construct a font family that contains list of custom font files.

| Parameters |
|---|---|
| `fonts: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font>` | list of font files |

### FontFamily

android 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/AndroidTypeface.android.kt+function:FontFamily)

```
fun FontFamily(typeface: Typeface): FontFamily
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#FontFamily(android.graphics.Typeface)` from Android `https://developer.android.com/reference/android/graphics/Typeface.html`.

| Parameters |
|---|---|
| `typeface: https://developer.android.com/reference/android/graphics/Typeface.html` | Android Typeface instance |

### FontFamily

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/FontFamily.kt+function:FontFamily) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun FontFamily(typeface: Typeface): FontFamily
```

Construct a font family that contains loaded font family: Typeface.

| Parameters |
|---|---|
| `typeface: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` | A typeface instance. |

### Typeface

android 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/AndroidTypeface.android.kt+function:Typeface)

```
fun Typeface(typeface: Typeface): Typeface
```

Returns a Compose `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` from Android `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Typeface(android.graphics.Typeface)`.

| Parameters |
|---|---|
| `typeface: https://developer.android.com/reference/android/graphics/Typeface.html` | Android Typeface instance |

### Typeface

android 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/AndroidTypeface.android.kt+function:Typeface)

```
fun [Typeface](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Typeface(android.content.Context,androidx.compose.ui.text.font.FontFamily,kotlin.collections.List))(
    context: Context,
    fontFamily: FontFamily,
    styles: List<Pair<FontWeight, FontStyle>>? = null
): Typeface
```

> [!CAUTION]
> **This function is deprecated.**   
> This API is deprecated with the introduction of async fonts which cannot resolve in this context. To preload fonts, use FontFamily.Resolver, use this instead:
>
> ```kotlin
> FontFamily.Resolver.preload(fontFamily, Font.AndroidResourceLoader(context))
> ```

Build an Android specific Typeface from FontFamily.

You can pass `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#Typeface(android.content.Context,androidx.compose.ui.text.font.FontFamily,kotlin.collections.List)` for loading only specific styles.

This function caches the internal native Typeface but always create the new Typeface object. Caller should cache if necessary.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | the context to be used for loading Typeface. |
| `fontFamily: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | the font family to be loaded |
| `styles: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight, https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle>>? = null` | optional style filter for loading subset of fontFamily. null means load all fonts in fontFamily. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Typeface` instance |

### createFontFamilyResolver

android 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/FontFamilyResolver.android.kt+function:createFontFamilyResolver)

```
fun createFontFamilyResolver(context: Context): FontFamily.Resolver
```

Create a new fontFamilyResolver for use outside of composition context

Example usages:

- Application.onCreate to preload fonts

- Creating Paragraph objects on background thread

Usages inside of Composition should use LocalFontFamilyResolver.current

All instances of FontFamily.Resolver created by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#createFontFamilyResolver(android.content.Context)` share the same typeface caches.

### createFontFamilyResolver

android 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/FontFamilyResolver.android.kt+function:createFontFamilyResolver)

```
fun createFontFamilyResolver(
    context: Context,
    coroutineContext: CoroutineContext
): FontFamily.Resolver
```

Create a new fontFamilyResolver for use outside of composition context with a coroutine context.

Example usages:

- Application.onCreate to preload fonts

- Creating Paragraph objects on background thread

- Configuring LocalFontFamilyResolver with a different CoroutineScope

Usages inside of Composition should use LocalFontFamilyResolver.current

Any `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-exception-handler/index.html` provided will be called with exceptions related to fallback font loading. These exceptions are not fatal, and indicate that font fallback continued to the next font load.

If no `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-exception-handler/index.html` is provided, a default implementation will be added that ignores all exceptions.

All instances of FontFamily.Resolver created by `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#createFontFamilyResolver(android.content.Context,kotlin.coroutines.CoroutineContext)` share the same typeface caches.

| Parameters |
|---|---|
| `context: https://developer.android.com/reference/android/content/Context.html` | Android context for resolving fonts |
| `coroutineContext: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html` | context to launch async requests in during resolution. |

### createFontFamilyResolver

android 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/DelegatingFontLoaderForDeprecatedUsage.android.kt+function:createFontFamilyResolver)

```
fun [createFontFamilyResolver](https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#createFontFamilyResolver(androidx.compose.ui.text.font.Font.ResourceLoader,android.content.Context))(
    fontResourceLoader: Font.ResourceLoader,
    context: Context
): FontFamily.Resolver
```

> [!CAUTION]
> **This function is deprecated.**   
> This exists to bridge existing Font.ResourceLoader subclasses to be used as aFontFamily.ResourceLoader during upgrade, use this instead:
>
> ```kotlin
> createFontFamilyResolver()
> ```

Bridge between subclasses of Font.ResourceLoader and the new FontFamily.Resolver API.

To use add as a CompositionLocal replacing the default FontFamily.Resolver:

```kotlin
LocalFontFamilyResolver provides createFontFamilyResolver(myFontResourceLoader, context)
```

This FontFamily.Resolver is capable of loading all fonts that the default FontFamily.Resolver is. In addition, it will delegate all resource fonts to the provided Font.ResourceLoader, preserving the behavior of Compose 1.0.

This method will be removed by Compose 2.0, and callers should migrate to using `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/AndroidFont` to implement the same behavior using font fallback chains.

A FontFamily.Resolver created this way will not share caches with other FontFamily.Resolvers.

### lerp

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/FontWeight.kt+function:lerp) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
fun lerp(start: FontWeight, stop: FontWeight, fraction: Float): FontWeight
```

Linearly interpolate between two font weights.

The `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)` argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)` (or something equivalent to `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)`), 1.0 meaning that the interpolation has finished, returning `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)` (or something equivalent to `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)`), and values in between meaning that the interpolation is at the relevant point on the timeline between `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)`. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#lerp(androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontWeight,kotlin.Float)` are usually obtained from an Animation, such as an `AnimationController`.

## Extension functions

### FontFamily.Resolver.resolveAsTypeface

android 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/FontFamilyResolver.android.kt+function:resolveAsTypeface)

```
fun FontFamily.Resolver.resolveAsTypeface(
    fontFamily: FontFamily? = null,
    fontWeight: FontWeight = FontWeight.Normal,
    fontStyle: FontStyle = FontStyle.Normal,
    fontSynthesis: FontSynthesis = FontSynthesis.All
): State<Typeface>
```

Resolve a font to an Android Typeface

On Android, font resolution always produces an `https://developer.android.com/reference/android/graphics/Typeface.html`.

This convenience method converts State to State to avoid casting the result.

| Parameters |
|---|---|
| `fontFamily: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily? = null` | fontFamily to resolve from |
| `fontWeight: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight = FontWeight.Normal` | font weight to resolve in `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#(androidx.compose.ui.text.font.FontFamily.Resolver).resolveAsTypeface(androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontSynthesis)`, will use closest match if not exact |
| `fontStyle: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle = FontStyle.Normal` | italic or upright text, to resolve in `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#(androidx.compose.ui.text.font.FontFamily.Resolver).resolveAsTypeface(androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontSynthesis)` |
| `fontSynthesis: https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis = FontSynthesis.All` | allow font synthesis if `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#(androidx.compose.ui.text.font.FontFamily.Resolver).resolveAsTypeface(androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontSynthesis)` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/package-summary#(androidx.compose.ui.text.font.FontFamily.Resolver).resolveAsTypeface(androidx.compose.ui.text.font.FontFamily,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle,androidx.compose.ui.text.font.FontSynthesis)` don't have an exact match. This will allow "fake bold" (drawing with too wide a brush) and "fake italic" (drawing then skewing) to be applied when no exact match is present for the weight and style. |

### 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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

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