skip icon indicating copy to clipboard operation
skip copied to clipboard

docs: Document how to manage Material3 typography

Open dfabulich opened this issue 10 months ago • 0 comments

To edit Android fonts, especially navigation titles and tab bar titles, you have to edit your Main.kt and edit typography settings there. This should be in the docs somewhere.

@Composable
internal fun PresentationRootView(context: ComposeContext) {
    val colorScheme = if (isSystemInDarkTheme()) ColorScheme.dark else ColorScheme.light

    val typography = androidx.compose.material3.Typography(
        // nav title (large)
        headlineLarge = androidx.compose.ui.text.TextStyle(
            fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
            fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
        ),
        // nav title (smaller)
        headlineMedium = androidx.compose.ui.text.TextStyle(
            fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
            fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
        ),
        // tab title
        labelMedium = androidx.compose.ui.text.TextStyle(
            fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
            fontWeight = androidx.compose.ui.text.font.FontWeight.Bold
        )
    )

    androidx.compose.material3.MaterialTheme(typography = typography) {
        PresentationRoot(defaultColorScheme = colorScheme, context = context) { ctx ->
            val contentContext = ctx.content()
            Box(modifier = ctx.modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
                RootView().Compose(context = contentContext)
            }
        }
    }
}

dfabulich avatar Feb 21 '25 20:02 dfabulich