Is there anything like the iOS "shrink font size" ...
# compose
t
Is there anything like the iOS "shrink font size" for Texts? Basically, if it doesn't fit, you can specify a scalar or minimum font size and it will try to use smaller and smaller fonts until it reaches that limit, and then applies whatever visual overflow handling you want
r
We do not support this unfortunately, at least not yet. It’s a feature from the View system (https://developer.android.com/develop/ui/views/text-and-emoji/autosizing-textview) that has yet to make it into Compose.
t
thank you color I'll keep an eye out for when it makes it over.
Just out of design curiosity, would it be likely that TextOverflow picked up this additonal data so that all of that was in one place? Or is it more likely it would be added as another optional parameter to the Text() composable?
r
No idea. Prob a separate parameter since you’ll want to specify min/max font size
s
Adding to text overflow is interesting idea will keep that in mind, but possibly would require another config as Romain mentioned.
h
In the meantime, you can refer to this example for ideas on how to achieve that in Compose https://gist.github.com/halilozercan/d1468efa45c4e9a71907623e41c2ccb7
a
@Halil Ozercan Is the
flag
necessary to trigger redraw? I have a auto shrink text implementation here in which I'm also using
Ref<TextLayoutResult>
but I'm not manually triggering redraw, and it seems to work well. Correct me if I'm wrong but I think recomposition or relayout will always result in redraw so it doesn't seem needed to manually trigger redraw.
h
Yes in many cases a recomposition triggers relayout and redraw but that behavior is not guaranteed. https://developer.android.com/jetpack/compose/phases#:~:text=Depending%20on%20the%20result%20of,the%20layout%20won't%20change.