neerav
03/22/2024, 5:13 AM@Composable invocations can only happen from the context of a @Composable functionBen Abramovitch
03/22/2024, 5:30 AMval LocalFont = compositionLocalOf<FontFamily?> {null}@Composable
fun MainView() {
    val fontFamily = FontFamily(Font(Res.font.yourfont, weight = FontWeight.Bold))
    CompositionLocalProvider(
        LocalFont provides fontFamily
    ) {
        Text("hello", fontFamily = LocalFont.currentOrThrow)
    }@Composable
fun someFont(): FontFamily { 
    return FontFamily(Font(Res.font.yourfont, weight = FontWeight.Bold))
}Text(text = "hello", fontFamily = someFont())Ben Abramovitch
03/22/2024, 5:39 AMBen Abramovitch
03/22/2024, 5:57 AMMaterialTheme(
     typography = Typography(defaultFontFamily = FontFamily(Font(Res.font.yourfont)))
 ) {
     Text(text = "hello", style = MaterialTheme.typography.body1, fontWeight = FontWeight.Bold)
 }