From 6f3eb0848824a19e92c6f302459a1b56f2724737 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Tue, 19 Mar 2024 16:27:12 +0100 Subject: [PATCH] [resources] Fix readResourceBytes function on Android if font is located under qualified directory (#4512) Fix the problem when users try to read a font bytes under a qualified directory. --- .../org/jetbrains/compose/resources/ResourceReader.android.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt b/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt index b04857b424..b742de7b9f 100644 --- a/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt +++ b/components/resources/library/src/androidMain/kotlin/org/jetbrains/compose/resources/ResourceReader.android.kt @@ -10,7 +10,7 @@ actual suspend fun readResourceBytes(path: String): ByteArray { val classLoader = Thread.currentThread().contextClassLoader ?: AndroidResourceReader.javaClass.classLoader val resource = classLoader.getResourceAsStream(path) ?: run { //try to find a font in the android assets - if (File(path).parentFile?.name.orEmpty() == "font") { + if (File(path).parentFile?.name.orEmpty().startsWith("font")) { classLoader.getResourceAsStream("assets/$path") } else null } ?: throw MissingResourceException(path)