forked from icerockdev/moko-resources
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFontResource.kt
More file actions
27 lines (24 loc) · 780 Bytes
/
Copy pathFontResource.kt
File metadata and controls
27 lines (24 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
package dev.icerock.moko.resources.compose
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.platform.Font
import dev.icerock.moko.resources.FontResource
import dev.icerock.moko.resources.compose.internal.toByteArray
@Composable
actual fun FontResource.asFont(
weight: FontWeight,
style: FontStyle,
): Font? = remember(filePath) {
Font(
identity = fontName,
data = data.toByteArray(),
weight = weight,
style = style,
)
}