• Cmn
    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

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

Constants

const Long

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

Cmn

Public properties

open FontLoadingStrategy

Loading strategy for this font.

Cmn
FontStyle

The style of the font, normal or italic.

Cmn
FontWeight

The weight of the font.

Cmn

Extension functions

FontFamily

Create a FontFamily from this single Font.

Cmn

Constants

MaximumAsyncTimeoutMillis

const val MaximumAsyncTimeoutMillisLong

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)
  • In the initial state, a fallback typeface is used to display text, which will reflow if the font successfully loads.

  • In the loading state, the font continues to use the fallback typeface and may cause one text reflow by finishing load. After a successful load it is considered resolved and will not cause another text reflow.

  • If the font fails to load by the timeout, the failure is permanent, and the font will never attempt to load again. Failure never causes text reflow.

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 properties

loadingStrategy

open val loadingStrategyFontLoadingStrategy

Loading strategy for this font.

style

val styleFontStyle

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.

weight

val weightFontWeight

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

toFontFamily

fun Font.toFontFamily(): FontFamily

Create a FontFamily from this single Font.