Is there a way to compute `TextLayoutResult` befor...
# compose
v
Is there a way to compute
TextLayoutResult
before the text is actually drawn? I reduce my text size until the text fits the width of the screen using
onTextLayout
(never thought it'd be that easy on Android) and it works fine but I'd like to do it in background without the user seeing the text get smaller.
j
I know I advocated pretty hard for this to be true in the early days of the design, although things have changed substantially since then, so I can't be sure what ended up happening here. Have you tried just instantiating one? The class I would look at is the implementation of https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:co[…]rc/commonMain/kotlin/androidx/compose/ui/text/TextDelegate.kt which also has some logic for validating old (cached) results - you can probably just copy-paste some pieces of that into your code. cc @Siyamed
👀 1
s
What Jim said. We made TextDelegate internal since we weremt sure of that is an api we want, but anything it uses should be public.
v
Will check out and update. Thanks.
Thanks for exposing
TextDelegate
in alpha11. I used it to resize text and it works pretty well.
👍 1