FlowFan
03/16/2025, 9:37 AMval XXXFontFamily: FontFamily
@Composable
get() {
val context = LocalContext.current
return remember(context) { FontFamily(Font(path = "font/xxx.ttf", assetManager = context.assets)) }
}
@Composable
fun Component() {
Column {
Text(text = "Hello")
Text(text = "World", fontFamily = XXXFontFamily)
}
}
Mark
03/16/2025, 10:41 AM@Composable
fun rememberXXXFontFamily(): FontFamily {
val context = LocalContext.current
return remember(context) {
FontFamily(Font(path = "font/xxx.ttf", assetManager = context.assets))
}
}
Mark
03/17/2025, 12:43 PMcontext
in the remember
because context.assets
never changes.FlowFan
03/18/2025, 2:02 AMremember
. It would be great if it could be like a resource, but there seems to be no way to do it.
@Stable
val XXXFontFamily: FontFamily = FontFamily(Font(<http://R.font.xxx|R.font.xxx>))
Mark
03/18/2025, 2:08 AMFontFamily
to the UI