Class

ResourceFont

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

Common
class ResourceFont
internal constructor(
    val resId: Int,
    override val weight: FontWeight = FontWeight.Normal,
    override val style: FontStyle = FontStyle.Normal,
    val variationSettings: FontVariation.Settings = FontVariation.Settings(weight, style),
    loadingStrategy: FontLoadingStrategy = FontLoadingStrategy.Async,
) : Font

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

Parameters

resId The resource ID of the font file in font resources. i.e. "R.font.myfont".
weight The weight of the font. The system uses this to match a font to a font request that is given in a androidx.compose.ui.text.TextStyle.
style 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 androidx.compose.ui.text.TextStyle.
loadingStrategy Load strategy for this font

Functions

copy

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

copy

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