I'm developing android with compose now. The Text widget is set by FontFamily.Default. My Galaxy 20 has several font families(Default, SamsungOne, Thick Gothic), and when I change them, the compose text FontFamily is also changed. I want to prevent this from changing. Is there any way about this?
Asked
Active
Viewed 257 times
1 Answers
0
It's easy. Set a font family using the fontFamily
parameter.
Text(
text = "I'm Roboto Font",
fontSize = 22.sp,
fontFamily = FontFamily(Font(R.font.roboto_medium, weight = FontWeight.Medium)),
color = Color.DarkGray
)
You can downlod the fonts from the Google Fonts site. Put them in the res
> font
folder. Follow this guide.

SemicolonSpace
- 1,007
- 11
- 20
-
If I set the FontFamily in each Text, they are not effected by system font? As watching your answer, it looks like an answer for setting custom fonts. But what I want to is setting absolute font family – jakchang Aug 08 '22 at 06:39
-
I tested the code in my samsung mobile. Even if I change the font in the system settings, it is not affecting the app. What do you mean by absolute font family? – SemicolonSpace Aug 08 '22 at 06:41
-
Ok I will try it. What I mean for absolute font family is font family that is not affected by system font setting. And Is there any way to not using FontFamily(Font())? – jakchang Aug 08 '22 at 06:52