Class

FontListFontFamily

Defines a font family with list of Font.

FontFamilySansSerifSample

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

CustomFontFamilySample

@Sampled
@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)
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: