ResourceFont


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

import androidx.compose.material.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
FontFamily

Summary

Public functions

ResourceFont
copy(resId: Int, weight: FontWeight, style: FontStyle)
Cmn
ResourceFont
@ExperimentalTextApi
copy(
    resId: Int,
    weight: FontWeight,
    style: FontStyle,
    loadingStrategy: FontLoadingStrategy,
    variationSettings: FontVariation.Settings
)
Cmn
open operator Boolean
equals(other: Any?)
Cmn
open Int
Cmn
open String
Cmn

Public properties

open FontLoadingStrategy

Loading strategy for this font.

Cmn
Int

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

Cmn
open FontStyle

The style of the font, normal or italic.

Cmn
FontVariation.Settings
Cmn
open FontWeight

The weight of the font.

Cmn

Public 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

equals

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

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

loadingStrategy

@ExperimentalTextApi
open val loadingStrategyFontLoadingStrategy

Loading strategy for this font.

resId

val resIdInt

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

style

open val styleFontStyle

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.

variationSettings

val variationSettingsFontVariation.Settings

weight

open val weightFontWeight

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.