# ResourceFont

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

  ```
  class ResourceFont : Font
  ```

*** ** * ** ***

Defines a font to be used while rendering text with resource ID.

```kotlin
import androidx.compose.material3.Text
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight

val fontFamily =
    FontFamily(
        Font(
            resId = R.font.my_font_400_regular,
            weight = FontWeight.W400,
            style = FontStyle.Normal,
        ),
        Font(
            resId = R.font.my_font_400_italic,
            weight = FontWeight.W400,
            style = FontStyle.Italic,
        ),
    )
Text(text = "Demo Text", fontFamily = fontFamily)
```

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

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#copy(kotlin.Int,androidx.compose.ui.text.font.FontWeight,androidx.compose.ui.text.font.FontStyle)(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)` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#copy(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 )` | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#hashCode()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#toString()()` | 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/ResourceFont#loadingStrategy()` Loading strategy for this font. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#resId()` The resource ID of the font file in font resources. i.e. "R.font.myfont". | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#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/ResourceFont#variationSettings()` Variation settings to apply to this font. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/ResourceFont#weight()` The weight of the font. | Cmn |

## Public functions

### copy

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

```
fun copy(
    resId: Int = this.resId,
    weight: FontWeight = this.weight,
    style: FontStyle = this.style
): ResourceFont
```

### copy

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

```
fun copy(
    resId: Int = this.resId,
    weight: FontWeight = this.weight,
    style: FontStyle = this.style,
    loadingStrategy: FontLoadingStrategy = this.loadingStrategy,
    variationSettings: FontVariation.Settings = this.variationSettings
): ResourceFont
```

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```

### toString

Cmn

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

## Public properties

### loadingStrategy

Cmn

```
open val loadingStrategy: FontLoadingStrategy
```

Loading strategy for this font.

### resId

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

```
val resId: Int
```

The resource ID of the font file in font resources. i.e. "R.font.myfont".

### style

Cmn

```
open 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/TextStyle`.

### variationSettings

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

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

Variation settings to apply to this font.

### weight

Cmn

```
open 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/TextStyle`.