Is it possible to draw a curved piece of text? The...
# compose
d
Is it possible to draw a curved piece of text? The answer on a stackoverflow topic I found from 3 years ago is using old methods that seem to not exist anymore.
y
In canvas on android
canvas.nativeCanvas.drawTextOnPath(actualText, textPath, 0f, 0f, paint)
d
Is this only available on android? I'm using compose multiplatform and with this code:
Copy code
Canvas(modifier = Modifier.fillMaxHeight()) {
    drawIntoCanvas {             
        it.nativeCanvas.drawTextOnPath(
            
        )
    }
}
I get:
Unresolved reference: drawTextOnPath
r
nativeCanvas
is a platform-specific type so you'll only be able to access that function on Android. For other platforms, it's doable but much more involved. See https://www.pushing-pixels.org/2022/02/10/drawing-text-on-a-path-in-compose-desktop-with-skia.html
d
I see, thanks. Looks like there's an implementation from the article here.
Just as a follow up question, I copied over the implementation from above but asSkiaPath is an uresovled reference. Does anyone have any idea why? Skia works with ios and android, and that function is from here, which is also multiplatform.
r
Android doesn't expose the same skia bindings that the other platforms use. Notice that the function you linked is in the
skikoMain
source set. That's common to non-Android platforms.
Use the original function you were looking at for Android, and the other implementation elsewhere.
d
That seems to be the case, thank you :)