From 8e17c9ed987842f6bebe7ed64a1879f2a8f456b5 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 26 Feb 2023 09:32:51 +0200 Subject: [PATCH] 4.5.0-patch2 Lazy loading of system fonts so startup is fast --- android/src/com/unciv/app/FontAndroid.kt | 8 ++++---- buildSrc/src/main/kotlin/BuildConfig.kt | 4 ++-- core/src/com/unciv/models/ruleset/Building.kt | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/android/src/com/unciv/app/FontAndroid.kt b/android/src/com/unciv/app/FontAndroid.kt index cef1b01d85..7eeb47150e 100644 --- a/android/src/com/unciv/app/FontAndroid.kt +++ b/android/src/com/unciv/app/FontAndroid.kt @@ -20,13 +20,14 @@ import kotlin.math.abs class FontAndroid : FontImplementation { - private val fontList: HashSet = 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) - } } diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index e298fd3144..c0d56708e5 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -3,8 +3,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.8.0" const val appName = "Unciv" - const val appCodeNumber = 820 - const val appVersion = "4.5.0-patch1" + const val appCodeNumber = 821 + const val appVersion = "4.5.0-patch2" const val gdxVersion = "1.11.0" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 87228f0734..ad614272ba 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -21,11 +21,11 @@ import com.unciv.models.stats.Stat import com.unciv.models.stats.Stats import com.unciv.models.translations.fillPlaceholders import com.unciv.models.translations.tr -import com.unciv.ui.screens.civilopediascreen.FormattedLine import com.unciv.ui.components.Fonts import com.unciv.ui.components.extensions.getConsumesAmountString import com.unciv.ui.components.extensions.getNeedMoreAmountString import com.unciv.ui.components.extensions.toPercent +import com.unciv.ui.screens.civilopediascreen.FormattedLine import kotlin.math.pow @@ -382,7 +382,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { && matchesFilter(it.params[0]) && city.matchesFilter(it.params[3]) } - || return super.canBePurchasedWithStat(city, stat) + || super.canBePurchasedWithStat(city, stat) ) }