fun AutoSizeText(text: String, modifier: Modifier = Modifier, suggestedFontSizes: ImmutableWrapper<List<TextUnit>> = emptyList<TextUnit>().toImmutableWrapper(), minTextSize: TextUnit = TextUnit.Unspecified, maxTextSize: TextUnit = TextUnit.Unspecified, stepGranularityTextSize: TextUnit = TextUnit.Unspecified, textAlignment: Alignment = Alignment.Center, color: Color = Color.Unspecified, fontStyle: FontStyle? = null, fontWeight: FontWeight? = null, fontFamily: FontFamily? = null, letterSpacing: TextUnit = TextUnit.Unspecified, textDecoration: TextDecoration? = null, textAlign: TextAlign? = null, lineHeight: TextUnit = TextUnit.Unspecified, softWrap: Boolean = true, maxLines: Int = 1, minLines: Int = 1, onTextLayout: (TextLayoutResult) -> Unit = {}, style: TextStyle = LocalTextStyle.current) Composable function that automatically adjusts the size of text to fit within the given constraints.
Features:
Best performance: Utilizes a dichotomous binary search algorithm to quickly find the optimal text size without unnecessary iterations.
Text alignment support: Supports 6 possible alignment values through the Alignment interface.
Material Design 3 support.
Font scaling support: Changing the font scale by the user does not affect the visual rendering result.
Limitation:
Does not work well when maxLine is greater than 1.
Does not work well when changing lineHeight
Author
Reda El Madini - For support, contact gladiatorkilo@gmail.com
Parameters
The text to be displayed.
The modifier for the text composable.
The suggested font sizes to choose from.
The minimum text size allowed.
The maximum text size allowed.
The step size for adjusting the text size.
The alignment of the text within its container.
The font style of the text.
The font weight of the text.
The font family of the text.
The letter spacing of the text.
The text decoration style.
The alignment of the text within the lines of the paragraph.
The line height of the text.
Whether the text should break at soft line breaks.
The maximum number of lines for the text.
The minimum number of lines for the text.
Callback invoked when the text layout is available.
The base style to apply to the text.
fun AutoSizeText(text: AnnotatedString, modifier: Modifier = Modifier, suggestedFontSizes: ImmutableWrapper<List<TextUnit>> = emptyList<TextUnit>().toImmutableWrapper(), minTextSize: TextUnit = TextUnit.Unspecified, maxTextSize: TextUnit = TextUnit.Unspecified, stepGranularityTextSize: TextUnit = TextUnit.Unspecified, textAlignment: Alignment = Alignment.Center, color: Color = Color.Unspecified, fontStyle: FontStyle? = null, fontWeight: FontWeight? = null, fontFamily: FontFamily? = null, letterSpacing: TextUnit = TextUnit.Unspecified, textDecoration: TextDecoration? = null, textAlign: TextAlign? = null, lineHeight: TextUnit = TextUnit.Unspecified, softWrap: Boolean = true, maxLines: Int = 1, minLines: Int = 1, inlineContent: ImmutableWrapper<Map<String, InlineTextContent>> = mapOf<String, InlineTextContent>().toImmutableWrapper(), onTextLayout: (TextLayoutResult) -> Unit = {}, style: TextStyle = LocalTextStyle.current)