From 78f4b1f2afe56a09a342c93aebb1544f1b951d76 Mon Sep 17 00:00:00 2001 From: AbdallahMehiz Date: Mon, 23 Sep 2024 13:25:25 +0100 Subject: [PATCH] fix: crash when opening subtitle settings with possibly corrupt font files closes #99 --- .../components/panels/SubtitleSettingsTypographyCard.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/panels/SubtitleSettingsTypographyCard.kt b/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/panels/SubtitleSettingsTypographyCard.kt index bc9e093..97be522 100644 --- a/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/panels/SubtitleSettingsTypographyCard.kt +++ b/app/src/main/java/live/mehiz/mpvkt/ui/player/controls/components/panels/SubtitleSettingsTypographyCard.kt @@ -87,7 +87,9 @@ fun SubtitleSettingsTypographyCard( fileManager.fromUri(Uri.parse(preferences.fontsFolder.get())) ?: return@withContext, ).filter { fileManager.isFile(it) && fileManager.getName(it).lowercase().matches(".*\\.[ot]tf$".toRegex()) - }.map { TTFFile.open(fileManager.getInputStream(it)!!).families.values.first() }, + }.mapNotNull { + runCatching { TTFFile.open(fileManager.getInputStream(it)!!).families.values.first() }.getOrNull() + }, ) fontsLoadingIndicator = null }