FontListFontFamily

Class

Common
class FontListFontFamily
internal constructor(
    /** The fallback list of fonts used for resolving typefaces for this FontFamily. */
    val fonts: List<Font>
) : FileBasedFontFamily(), List<Font> by fonts

Defines a font family with list of Font.

Code Examples

CustomFontFamilySample

@Composable
fun CustomFontFamilySample() {
    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)
}

FontFamilySansSerifSample

@Composable
fun FontFamilySansSerifSample() {
    Text(text = "Demo Text sans-serif", fontFamily = FontFamily.SansSerif)
}