diff --git a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParser.kt b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParser.kt index ff17801580..ed4631ef18 100644 --- a/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParser.kt +++ b/components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParser.kt @@ -75,7 +75,8 @@ internal fun Element.toImageVector(density: Density): ImageVector { defaultWidth = attributeOrNull(ANDROID_NS, "width").parseDp(density), defaultHeight = attributeOrNull(ANDROID_NS, "height").parseDp(density), viewportWidth = attributeOrNull(ANDROID_NS, "viewportWidth")?.toFloat() ?: 0f, - viewportHeight = attributeOrNull(ANDROID_NS, "viewportHeight")?.toFloat() ?: 0f + viewportHeight = attributeOrNull(ANDROID_NS, "viewportHeight")?.toFloat() ?: 0f, + autoMirror = attributeOrNull(ANDROID_NS, "autoMirrored") == "true" ) parseVectorNodes(builder, context) return builder.build() diff --git a/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParserTest.kt b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParserTest.kt new file mode 100644 index 0000000000..78ca14db22 --- /dev/null +++ b/components/resources/library/src/commonTest/kotlin/org/jetbrains/compose/resources/vector/XmlVectorParserTest.kt @@ -0,0 +1,55 @@ +package org.jetbrains.compose.resources.vector + +import androidx.compose.ui.unit.Density +import androidx.compose.ui.unit.dp +import org.jetbrains.compose.resources.decodeToImageVector +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class XmlVectorParserTest { + + + private val arrowVector1 = """ + + + + """.trimIndent().encodeToByteArray() + + private val arrowVector2 = """ + + + + """.trimIndent().encodeToByteArray() + + @Test + fun canDecodeToImageVector() { + val iv = arrowVector1.decodeToImageVector(Density(1f)) + assertEquals(iv.viewportWidth, 32f) + assertEquals(iv.viewportHeight, 32f) + assertEquals(iv.defaultWidth, 32.dp) + assertEquals(iv.defaultHeight, 32.dp) + assertTrue(iv.autoMirror) + + val iv2 = arrowVector2.decodeToImageVector(Density(1f)) + assertEquals(iv2.viewportWidth, 36f) + assertEquals(iv2.viewportHeight, 24f) + assertEquals(iv2.defaultWidth, 40.dp) + assertEquals(iv2.defaultHeight, 30.dp) + assertFalse(iv2.autoMirror) + } +} \ No newline at end of file