Join Slack
hi guys i am using fonts with experimental resource api in my KMP project and i am getting and error...
# multiplatform
b
Bharat Kumar
01/12/2024, 7:28 AM
hi guys i am using fonts with experimental resource api in my KMP project and i am getting and error for Unresolved Te Reference :Font while i already imported
import
androidx.compose.ui.text.platform.Font and using it correctly
Bharat Kumar
01/12/2024, 7:29 AM
]
Bharat Kumar
01/12/2024, 7:29 AM
package
theme
import
androidx.compose.material.Typography
import
androidx.compose.ui.text.TextStyle
import
androidx.compose.ui.text.font.FontFamily
import
androidx.compose.ui.text.font.FontWeight
import
androidx.compose.ui.text.platform.Font
import
androidx.compose.ui.unit.sp
import
kotlinx.coroutines.runBlocking
import
org.jetbrains.compose.resources.ExperimentalResourceApi
import
org.jetbrains.compose.resources.resource @OptIn(ExperimentalResourceApi::_class_)
val Montserrat
= _FontFamily_( _Font_( identity = "font/mons_black.ttf", weight = FontWeight.Black, data =
runBlocking
{
_resource_("font/mons_black.ttf").readBytes()
}
), _Font_( identity = "font/mons_bold.ttf", weight = FontWeight.Bold, data =
runBlocking
{
_resource_("font/mons_bold.ttf").readBytes()
}
), _Font_( identity = "font/mins_semibold.ttf", weight = FontWeight.SemiBold, data =
runBlocking
{
_resource_("font/mins_semibold.ttf").readBytes()
}
), _Font_( identity = "font/mins_regular.ttf", weight = FontWeight.Normal, data =
runBlocking
{
_resource_("font/mins_regular.ttf").readBytes()
}
), _Font_( identity = "font/mons_medium.ttf", weight = FontWeight.Medium, data =
runBlocking
{
_resource_("font/mons_medium.ttf").readBytes()
}
) )
Bharat Kumar
01/12/2024, 7:38 AM
If i use expect actual method for fonts its working but this is goven by compose right shouldnt it also work ?
r
rudolf.hladik
01/31/2024, 12:32 PM
imho you have to convert .ttf. to .otf as .ttf format is not yet supported. I've read that somewhere but dunno where
b
Bharat Kumar
02/01/2024, 4:52 AM
okkk
@rudolf.hladik
thanks for the update let me try and check
33
Views
Open in Slack
Previous
Next
kotlinlang
A modern programming language that makes developers happier.
Powered by