Skip to content

Instantly share code, notes, and snippets.

@delacrixmorgan
Created August 24, 2024 14:17
Show Gist options
  • Save delacrixmorgan/39c2d8a140233da9b87a5b8158aeb03c to your computer and use it in GitHub Desktop.
Save delacrixmorgan/39c2d8a140233da9b87a5b8158aeb03c to your computer and use it in GitHub Desktop.
KMP Typography Style
val displayFontFamily: FontFamily
    @Composable
    get() = FontFamily(
        Font(Res.font.league_spartan, weight = FontWeight.Normal)
    )

val bodyFontFamily: FontFamily
    @Composable get() = FontFamily(
        Font(Res.font.lato_black, weight = FontWeight.Black),
        Font(Res.font.lato_bold, weight = FontWeight.Bold),
        Font(Res.font.lato_light, weight = FontWeight.Light),
        Font(Res.font.lato_regular, weight = FontWeight.Normal),
        Font(Res.font.lato_thin, weight = FontWeight.Thin),
    )

val AppTypography: Typography
    @Composable get() {
        val baseline = Typography()
        val displayFontFamily = displayFontFamily
        val bodyFontFamily = bodyFontFamily

        return Typography(
            displayLarge = baseline.displayLarge.copy(fontFamily = displayFontFamily),
            displayMedium = baseline.displayMedium.copy(fontFamily = displayFontFamily),
            displaySmall = baseline.displaySmall.copy(fontFamily = displayFontFamily),
            headlineLarge = baseline.headlineLarge.copy(fontFamily = displayFontFamily),
            headlineMedium = baseline.headlineMedium.copy(fontFamily = displayFontFamily),
            headlineSmall = baseline.headlineSmall.copy(fontFamily = displayFontFamily),
            titleLarge = baseline.titleLarge.copy(fontFamily = displayFontFamily),
            titleMedium = baseline.titleMedium.copy(fontFamily = displayFontFamily),
            titleSmall = baseline.titleSmall.copy(fontFamily = displayFontFamily),
            bodyLarge = baseline.bodyLarge.copy(fontFamily = bodyFontFamily),
            bodyMedium = baseline.bodyMedium.copy(fontFamily = bodyFontFamily),
            bodySmall = baseline.bodySmall.copy(fontFamily = bodyFontFamily),
            labelLarge = baseline.labelLarge.copy(fontFamily = bodyFontFamily),
            labelMedium = baseline.labelMedium.copy(fontFamily = bodyFontFamily),
            labelSmall = baseline.labelSmall.copy(fontFamily = bodyFontFamily),
        )
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment