Typeface

Function

Android

Deprecated This API is deprecated with the introduction of async fonts which cannot resolve in this context. To preload fonts, use FontFamily.Resolver.

fun Typeface(
    context: Context,
    fontFamily: FontFamily,
    styles: List<Pair<FontWeight, FontStyle>>? = null,
): androidx.compose.ui.text.font.Typeface

Build an Android specific Typeface from FontFamily.

You can pass styles for loading only specific styles.

This function caches the internal native Typeface but always create the new Typeface object. Caller should cache if necessary.

Parameters

contextthe context to be used for loading Typeface.
fontFamilythe font family to be loaded
stylesoptional style filter for loading subset of fontFamily. null means load all fonts in fontFamily.

Returns

androidx.compose.ui.text.font.Typeface instance
Android
fun Typeface(typeface: Typeface): androidx.compose.ui.text.font.Typeface

Returns a Compose androidx.compose.ui.text.font.Typeface from Android Typeface.

Parameters

typefaceAndroid Typeface instance