skikoMain.io.github.alexzhirkevich.compottie.ResourcesFontManager.skiko.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compottie-resources Show documentation
Show all versions of compottie-resources Show documentation
Compose Multiplatform lottie animation
The newest version!
package io.github.alexzhirkevich.compottie
import androidx.compose.ui.text.font.Font
import io.github.alexzhirkevich.compottie.assets.LottieFontSpec
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.FontResource
import org.jetbrains.compose.resources.ResourceEnvironment
import org.jetbrains.compose.resources.getFontResourceBytes
@OptIn(ExperimentalResourceApi::class)
internal actual suspend fun loadFont(
context : LottieContext?,
environment: ResourceEnvironment,
font: LottieFontSpec,
resource: FontResource
) : Font {
return androidx.compose.ui.text.platform.Font(
identity = "${font.family}_${font.weight.weight}_${font.style}",
data = getFontResourceBytes(environment, resource),
weight = font.weight,
style = font.style
)
}