Fix crash when device headline font family is blank
This commit is contained in:
parent
a6d13425fa
commit
c35387a9fb
@ -11,7 +11,11 @@ fun getDeviceHeadlineFontFamily(context: Context): FontFamily {
|
|||||||
|
|
||||||
if (configResId != 0) {
|
if (configResId != 0) {
|
||||||
val fontFamily = context.resources.getString(configResId)
|
val fontFamily = context.resources.getString(configResId)
|
||||||
return FontFamily(
|
|
||||||
|
if (fontFamily.isBlank()) return FontFamily.SansSerif
|
||||||
|
|
||||||
|
return try {
|
||||||
|
FontFamily(
|
||||||
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.Thin, style = FontStyle.Normal),
|
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.Thin, style = FontStyle.Normal),
|
||||||
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.ExtraLight, style = FontStyle.Normal),
|
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.ExtraLight, style = FontStyle.Normal),
|
||||||
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.Light, style = FontStyle.Normal),
|
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.Light, style = FontStyle.Normal),
|
||||||
@ -31,6 +35,9 @@ fun getDeviceHeadlineFontFamily(context: Context): FontFamily {
|
|||||||
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.ExtraBold, style = FontStyle.Italic),
|
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.ExtraBold, style = FontStyle.Italic),
|
||||||
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.Black, style = FontStyle.Italic),
|
Font(DeviceFontFamilyName(fontFamily), weight = FontWeight.Black, style = FontStyle.Italic),
|
||||||
)
|
)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
FontFamily.SansSerif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FontFamily.SansSerif
|
return FontFamily.SansSerif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user