orangy
07/19/2021, 5:23 PMSVGPainter
seems to ignore Density
for stroke width, and uses it for intrinsicSize
only. It makes rendering inconsistent – graphics appear too thin. Is it a known issue?Igor Demin
07/19/2021, 8:43 PMorangy
07/19/2021, 9:10 PM<svg width="18" height="14" viewBox="0 0 18 14" fill="none" xmlns="<http://www.w3.org/2000/svg>">
<path d="M1 6.46197L6.29819 12L17 1" stroke="white" stroke-width="4"/>
</svg>
Igor Demin
07/19/2021, 10:12 PMimport androidx.compose.desktop.Window
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Row
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.loadSvgResource
import androidx.compose.ui.unit.Density
fun main() = Window {
Row {
CompositionLocalProvider(LocalDensity provides Density(1f)) {
Test()
}
CompositionLocalProvider(LocalDensity provides Density(2f)) {
Test()
}
CompositionLocalProvider(LocalDensity provides Density(4f)) {
Test()
}
}
}
@Composable
private fun Test() {
val density = LocalDensity.current
val svg = remember(density) {
loadSvgResource(
"""
<svg width="18" height="14" viewBox="0 0 18 14" fill="none" xmlns="<http://www.w3.org/2000/svg>">
<path d="M1 6.46197L6.29819 12L17 1" stroke="black" stroke-width="4"/>
</svg>
""".trimIndent().byteInputStream(),
density
)
}
Image(
svg,
contentDescription = null
)
}
Compose 0.5.0-build226
orangy
07/20/2021, 10:01 AM