androidandroid-jetpack-composegoogle-fontsandroid-jetpack-compose-material3

Google Font does not apply on android 8 in compose


I am developing an app using jetpack compose and material 3: v1.2.1, i need a specific text to have the stalemate font. so i downloaded the font and added it to font resources and added it as a FontFamily like this:

val staleMate = FontFamily(
    Font(R.font.stalemate)
)

and using the FontFamily like this:

Text(text = "The Light",
        style = TextStyle(
            brush = Brush.linearGradient(
                colors = listOf(MaterialTheme.colorScheme.primary, MaterialTheme.colorScheme.tertiary),
            ),
            fontSize = MaterialTheme.typography.displayMedium.fontSize,
            fontFamily = staleMate
        ),
        modifier = modifier
    )

now when i open the app in my samsung A24, the font shows up correctly and there is no problem at all (this phone has android 14). but when i open the app in my huawei psmart which has android 8, the font is not loaded and the app uses default font. so i tried the downloadable fonts, as the documentation suggests to use GoogleFonts downloadable fonts. but that did not work either. so now i dont know what to do. are there any reasons that the font is not working on my android 8 device and how can i fix this issue?

Edit i decided to test the font in two more devices with different os versions, one is an emulator with android 10 and the other one is galaxy tab 4 with android 5. both instances of the app works fine and the font is shown perfectly. so now the question is: why doesn't it work on my huawei phone?


Solution

  • The problem was in the font management system of my huawei itself. huawei phones have a themes app that you can set the font and text styles of the whole phone in it. when you change the text style and font in there it force changes all the fonts in all the apps no matter what. so when i put the font to default of the system, the app worked perfectly and the font loaded as well.