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
startFontVariationSettings | Font variation settings at the start of the animation |
endFontVariationSettings | Font variation settings at the end of the animation |
textStyle | Text style to be used for the animation |
startFontSize | Font size at the start of the animation |
endFontSize | Font size at the end of the animation |
density | Current density, used to to convert font sizes |
contentColor | Content color of the animated text |
fontFamilyResolver | Current Resolver to use to resolve font families |
cacheSize | Size 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. |