AnimatedTextFontRegistry

Class

Android
@RequiresApi(31)
public class AnimatedTextFontRegistry(
    private val textStyle: TextStyle,
    private val startFontVariationSettings: FontVariation.Settings,
    private val endFontVariationSettings: FontVariation.Settings,
    private val startFontSize: TextUnit,
    private val endFontSize: TextUnit,
    private val density: Density,
    fontFamilyResolver: FontFamily.Resolver,
    private val contentColor: Color = textStyle.color,
    cacheSize: Int = AnimatedTextDefaults.CacheSize,
)

Generates fonts to be used by AnimatedText throughout the animation.

Start and end of the animation is when the animatable is at 0f and 1f, respectively. This API supports overshooting, so a generated font can be extrapolated outside startFontVariationSettings and endFontVariationSettings range, developers need to make sure the given font supports possible font variation settings throughout the animation.

AnimatedTextFontRegistry can be re-used between multiple AnimatedText composables to save memory and improve performance where needed and feasible.

Parameters

startFontVariationSettingsFont variation settings at the start of the animation
endFontVariationSettingsFont variation settings at the end of the animation
textStyleText style to be used for the animation
startFontSizeFont size at the start of the animation
endFontSizeFont size at the end of the animation
densityCurrent density, used to to convert font sizes
contentColorContent color of the animated text
fontFamilyResolverCurrent Resolver to use to resolve font families
cacheSizeSize of the cache used to store animated variable fonts, this can be increased to improve animation performance if needed, but it also increases the memory usage.