Stay organized with collections Save and categorize content based on your preferences.

FontLoadingStrategy.Companion

object FontLoadingStrategy.Companion


Summary

Public properties

FontLoadingStrategy

Loading this font will never block, and will load on a background thread.

FontLoadingStrategy

Resolving this font will always block until the font loads.

FontLoadingStrategy

Resolving this font is best-effort and will attempt to load from a local resource that MAY be available.

Public properties

Async

val AsyncFontLoadingStrategy

Loading this font will never block, and will load on a background thread.

During loading, the app will not block but instead will find the next available font that is immediately available (Blocking or OptionalLocal). When the font finishes loading, text will reflow with the resolved typeface.

If no fallback fonts are available immediately, the platform default typeface will be used to draw text during loading.

If loading fails, the failure is stored permanently, and future uses of the font will always use the fallback.

This should typically not be used for fonts that are stored on-device and needed for the first frame. Instead use Blocking or OptionalLocal.

This should always be used for fonts that are fetched from a remote source such as over http.

Blocking

val BlockingFontLoadingStrategy

Resolving this font will always block until the font loads.

This means that the first frame that uses this font will always display using the desired font, and text will never reflow.

This should typically be used for fonts that stored on-device. It is acceptable to block the first frame of an application to read a font from disk.

This should typically not be used for fonts that are fetched from a remote source such as over http, as it will block all rendering until the font loads. Instead use Async.

OptionalLocal

val OptionalLocalFontLoadingStrategy

Resolving this font is best-effort and will attempt to load from a local resource that MAY be available.

Resolving this font will always block until the font resolves, and text will never reflow.

An OptionalLocal font describes a font that is installed locally, such as an optional system installed font. Resolution of an OptionalLocal font is expected to fail whenever the resource is not available, which will fallback to the next font in the FontFamily.

Typical usages involve following the OptionalLocal font with the same font loaded from a remote Async source. It may also be followed by other OptionalLocal fonts or Blocking fonts that have less specific styling to avoid async delay.

Apps should expect that OptionalLocal fonts will fail to load on devices where the font is not available.

This should typically not be used for fonts that are fetched from a remote source such as over http, as it will block all rendering until the font loads. Instead use Async.