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

Font

public interface Font

Known direct subclasses
AndroidFont

Font for use on Android.

ResourceFont

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


The interface of the font resource.

See also
ResourceFont

Summary

Nested types

public interface Font.ResourceLoader

This interface is deprecated. Replaced with FontFamily.Resolver during the introduction of async fonts, all usages should be replaced.

Constants

default static final long

This is the global timeout for fetching an FontLoadingStrategy.Async font.

Public methods

default @NonNull FontLoadingStrategy

Loading strategy for this font.

abstract @NonNull FontStyle

The style of the font, normal or italic.

abstract @NonNull FontWeight

The weight of the font.

Extension functions

default final @NonNull FontFamily

Create a FontFamily from this single Font.

Constants

MaximumAsyncTimeoutMillis

default static final long MaximumAsyncTimeoutMillis

This is the global timeout for fetching an FontLoadingStrategy.Async font.

This defines the "loading" window for a font. After this timeout, a font load may no longer trigger text reflow and is considered "resolved."

Each async font is given separate loading window and goes through these states:

(initial) -> (loading with timeout) -> (resolved)

After a font is in resolved, it will never cause text reflow unless it is evicted from the font cache and re-enters initial.

This timeout is not configurable, and timers are maintained globally.

Public methods

getLoadingStrategy

default @NonNull FontLoadingStrategy getLoadingStrategy()

Loading strategy for this font.

getStyle

abstract @NonNull FontStyle getStyle()

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.SpanStyle.

getWeight

abstract @NonNull FontWeight getWeight()

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.SpanStyle.

Extension functions

FontKt.toFontFamily

default final @NonNull FontFamily FontKt.toFontFamily(@NonNull Font receiver)

Create a FontFamily from this single Font.