Skip to content

Commit

Permalink
refactor(legacy): not crash when fail to load fonts (#5692)
Browse files Browse the repository at this point in the history
  • Loading branch information
MukjepScarlet authored Feb 24, 2025
1 parent 063b79d commit b471610
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main/java/net/ccbluex/liquidbounce/ui/font/Fonts.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ object Fonts : MinecraftInstance {
private var customFontInfoList: List<CustomFontInfo>
get() = with(configFile) {
if (exists()) {
// readJson().decode<List<CustomFontInfo>>()
// For old versions
readJson().asJsonArray.map {
it as JsonObject
val fontFile = it["fontFile"].asString
val fontSize = it["fontSize"].asInt
val name = if (it.has("name")) it["name"].asString else fontFile
CustomFontInfo(name, fontFile, fontSize)
try {
// For old versions
readJson().asJsonArray.map {
it as JsonObject
val fontFile = it["fontFile"].asString
val fontSize = it["fontSize"].asInt
val name = if (it.has("name")) it["name"].asString else fontFile
CustomFontInfo(name, fontFile, fontSize)
}
} catch (e: Exception) {
LOGGER.error("Failed to load fonts", e)
emptyList()
}
} else {
createNewFile()
Expand Down

0 comments on commit b471610

Please sign in to comment.