what is the compose equivalent of StaticLayout? it'd like to draw mutiline text bounded by a certain...
z
what is the compose equivalent of StaticLayout? it'd like to draw mutiline text bounded by a certain width
I've used drawIntoCanvas to try and create StaticLayout, but NativePaint doesn't seem to be compatible with TextPaint
s
Copy code
DrawScope.drawIntoCanvas {
                it.nativeCanvas.drawText(
                    text,
                    width,
                    height,
                    textPaint
                )
            }
z
that does not help me with StaticLayout
I was going to do something like:
Copy code
drawIntoCanvas { canvas ->
            val layout = StaticLayout.Builder.obtain(text, 0, text.length, strokePaint, viewSize.width)
                .build()

            layout.draw(canvas.nativeCanvas)
}
but, strokePaint is not of instance TextPaint
I've created it via Paint().asFrameworkPaint()
but I assume compose requires something else to get the textpaint
p
@Zan Skamljic I have created the feature request for adding drawText function to @composable Canvas. Feel free to add your comments there: https://issuetracker.google.com/issues/190787898
z
Thanks, I'll add a few lines