public interface Font
The interface of the font resource.
Properties
weight
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
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
public val loadingStrategy: FontLoadingStrategy
Loading strategy for this font.
variationSettings
public val variationSettings: FontVariation.Settings
Variation settings to apply to this font.
Members
ResourceLoader
@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
@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
public companion object
Properties
MaximumAsyncTimeoutMillis
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)
- In the initial state, a fallback typeface is used to display text, which will reflow if
- In the loading state, the font continues to use the fallback typeface and may cause one
- If the font fails to load by the timeout, the failure is permanent, and the font will
the font successfully loads.
text reflow by finishing load. After a successful load it is considered resolved and will not cause another text reflow.
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.