Interface

Font

The interface of the font resource.

Source set: Common
public interface Font

The interface of the font resource.

Properties

weight

Source set: Common
public val weight: FontWeight

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.

style

Source set: Common
public val style: FontStyle

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.

loadingStrategy

Source set: Common
public val loadingStrategy: FontLoadingStrategy

Loading strategy for this font.

variationSettings

Source set: Common
public val variationSettings: FontVariation.Settings

Variation settings to apply to this font.

Members

ResourceLoader

Source set: Common
@Deprecated(
        "Replaced with FontFamily.Resolver during the introduction of async fonts, " +
            "all usages should be replaced. Custom subclasses can be converted into a " +
            "FontFamily.Resolver by calling createFontFamilyResolver(myFontFamilyResolver, context)"
    )
    public interface ResourceLoader

Interface used to load a font resource.

Functions

load

Source set: Common
@Deprecated(
            "Replaced by FontFamily.Resolver, this method should not be called",
            ReplaceWith("FontFamily.Resolver.resolve(font, )"),
        )
        public fun load(font: Font): Any

Loads resource represented by the Font object.

Parameters

font Font to be loaded

Return

platform specific typeface

Throws: Exception

if font cannot be loaded

Throws: IllegalStateException

if font cannot be loaded

Companion

Source set: Common
public companion object

Properties

MaximumAsyncTimeoutMillis

Source set: Common
public const val MaximumAsyncTimeoutMillis: Long = 15_000L

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)

    the font successfully loads.

  • In the initial state, a fallback typeface is used to display text, which will reflow if
  • text reflow by finishing load. After a successful load it is considered resolved and will not cause another text reflow.

  • In the loading state, the font continues to use the fallback typeface and may cause one
  • never attempt to load again. Failure never causes text reflow.

  • If the font fails to load by the timeout, the failure is permanent, and the font will

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.

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: