4.5.0-patch2

Lazy loading of system fonts so startup is fast
This commit is contained in:
Yair Morgenstern
2023-02-26 09:32:51 +02:00
parent fd9fc914bc
commit 8e17c9ed98
3 changed files with 8 additions and 8 deletions

View File

@ -20,13 +20,14 @@ import kotlin.math.abs
class FontAndroid : FontImplementation {
private val fontList: HashSet<Font> = hashSetOf()
private val fontList by lazy {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) emptySet()
else SystemFonts.getAvailableFonts()
}
private val paint: Paint = Paint()
private var currentFontFamily: String? = null
init {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
fontList.addAll(SystemFonts.getAvailableFonts())
paint.isAntiAlias = true
paint.strokeWidth = 0f
paint.setARGB(255, 255, 255, 255)
@ -49,7 +50,6 @@ class FontAndroid : FontImplementation {
else
{
paint.typeface = createTypefaceSystem(fontFamilyData.invariantName)
}
}