```val textPaint = android.graphics.Paint().apply ...
# compose
p
Copy code
val textPaint = android.graphics.Paint().apply {
            color = md_theme_chip_text.toArgb()
            textSize = labelTextSize
        }

drawContext.canvas.nativeCanvas.drawText(
    "C3", 0f, y, textPaint
)
i am using this code to print some text inside the canvas but when same code i am using in common main it gives errors .drawText() is not available so how to migrate ?
r
nativeCanvas
is a platform-specific type. It's
android.graphics.Canvas
on Android and
org.jetbrains.skia.Canvas
on other platforms. You can only access the Android-specific stuff from Android, not from common. To migrate, you can try defining your own
expect fun
in common that delegates to the platform-specific text APIs.
p
i dont't want to go platform specific, how to use org.jetbrains.skia.Canvas to print Text on canvas ?
r
I don't think any shared canvas text APIs exist that work on both Android and Skia platforms. You're going to have to do something platform-specific, but you can probably get away with relatively simple expect/actual declaration and then use that from common for all your actual use-cases.