Bold text - Android
On Android, you can use the fontWeightAdjustment
property on Android 12 and higher. The property returns an integer between 1
and 1000
, which indicates the current user preference for increasing font weight. The constant FontStyle.FONT_WEIGHT_BOLD
has a value of 700
.
fun Context.prefersBoldFont(): Boolean {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
return false
}
return resources.configuration.fontWeightAdjustment >= FontStyle.FONT_WEIGHT_BOLD
}