Hi, stumbled upon a weird bug it seems. Inside `Te...
# compose
d
Hi, stumbled upon a weird bug it seems. Inside
TextAutoSizeLayoutScope
the function
performLayout
will ignore the string specified to it to lay out and will always use the one of the
TextField
to which this
TextAutoSize
was added.
Copy code
val text1 = AnnotatedString("labas")
val layoutResult = performLayout(constraints, text1, currentPx.toSp())
println(layoutResult) // TextLayoutResult(layoutInput=TextLayoutInput(text=Timetable...
z
This API seems surprising: It makes sense that it might want to constraint the autosize logic to only operate on the passed string, but then
performLayout
shouldn't have that parameter at all.
d
Exactly, should I file a bug report?
z
yea
h
Cc @jossiwolf
That
text
parameter surprised me as well
d
For my use case I actually want it to perform layout on the text specified in the parameter
Looked into it more, the
constraints
passed to the
performLayout
function are also completely ignored. So this function only looks at parameters from the main
getFontSize
function:
Copy code
override fun TextAutoSizeLayoutScope.getFontSize(
        constraints: Constraints,
        text: AnnotatedString
    ): TextUnit
getFontSize
will also always return whatever fontsize was last used in the
performLayout
function:
Copy code
performLayout(constraints, text, 45.sp)
return 0.sp // In the end, getFontSize will still return 45.sp