Is there any way for converting Jetpack Compose Typeface to native Typeface?

493 views Asked by At

I'm trying to draw text using NativeCanvas and NativePaint. I want to use Jetpack compose FontFamily and Typeface but I have to use native Typeface.

I couldn't get font path from compose FontFamily to create a native Typeface.

Is there any way for converting Compose Typeface to native Typeface?

Thanks

1

There are 1 answers

1
Nestor Perez On

I dont think there is a way to covert compose typeface to native. Currently the only workaround that i found is to provide with resources:

val textTypeface: android.graphics.Typeface? =
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) LocalContext.current.resources.getFont(R.font.quicksand_light) else null

However if android version < android oreo, idk how to provide the font, so i fallback to default fount.