hi, i added a font `matesc_regular.ttf` to the `/c...
# compose
a
hi, i added a font
matesc_regular.ttf
to the
/composeApp/src/commonMain/composeResources/drawable/font
folder. how do i create import this font
Particulars.kt
to create a
fontFamily
instance?
b
Your folder location for storing fonts is not correct one. You should store it into
composeResources/font
directory. Then you can access it
Res.font.
but I think you need to build your project first to make them available to you.
a
this worked but i am getting this now
b
Did you used correct import for Font?
import org.jetbrains.compose.resources.Font
a
^^^ when i used this i was getting build error
@Composable invocations can only happen from the context of a @Composable function
b
You have 2 options now. Either you make a method instead of variable like this:
Copy code
@Composable
private fun interFamily() = FontFamily(
    Font(Res.font.matesc_regular, FontWeight.Normal)
)
Or you can also defined it in this way if you want to keep a variable:
Copy code
val interFamily: FontFamily
    @Composable get() = FontFamily(
        Font(Res.font.matesc_regular, FontWeight.Normal)
    )
a
thanks @Blaž Vantur this worked!!!
👍 1