{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

AndroidTypefaceKt

public final class AndroidTypefaceKt


Summary

Public methods

static final @NonNull FontFamily

Creates a FontFamily from Android Typeface.

static final @NonNull Typeface

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

static final @NonNull Typeface
Typeface(
    @NonNull Context context,
    @NonNull FontFamily fontFamily,
    List<@NonNull Pair<@NonNull FontWeight, @NonNull FontStyle>> styles
)

This method is deprecated. This API is deprecated with the introduction of async fonts which cannot resolve in this context.

Public methods

FontFamily

public static final @NonNull FontFamily FontFamily(@NonNull Typeface typeface)

Creates a FontFamily from Android Typeface.

Parameters
@NonNull Typeface typeface

Android Typeface instance

Typeface

public static final @NonNull Typeface Typeface(@NonNull Typeface typeface)

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

Parameters
@NonNull Typeface typeface

Android Typeface instance

Typeface

public static final @NonNull Typeface Typeface(
    @NonNull Context context,
    @NonNull FontFamily fontFamily,
    List<@NonNull Pair<@NonNull FontWeight, @NonNull FontStyle>> styles
)

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
@NonNull Context context

the context to be used for loading Typeface.

@NonNull FontFamily fontFamily

the font family to be loaded

List<@NonNull Pair<@NonNull FontWeight, @NonNull FontStyle>> styles

optional style filter for loading subset of fontFamily. null means load all fonts in fontFamily.