SVG icon indicating copy to clipboard operation
SVG copied to clipboard

Draw Svg in Svg with different ViewBox

Open Appendme opened this issue 2 years ago • 0 comments

Description

There is a situation when you need to draw an SVG that contains an SVG inside, but with a larger ViewBox size. Resvg and Chrome draw the same, but Svg.Net does not. Is this some kind of error that these libraries can solve, but Svg.net can’t, or is this a bug in Svg.Net?

Example data

Original picture:

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 124 124">
  <rect width="124" height="124" rx="24" fill="#F97316"/>
  <svg x="62" y="62" width="800" viewBox="0 0 600 600" preserveAspectRatio="xMinYMin">
    <circle cx="63.2109" cy="37.5391" r="18.1641" fill="black"/>
  </svg>
</svg>

Approximately what Svg.Net produces:

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400" viewBox="0 0 124 124">
  <rect width="124" height="124" rx="24" fill="#F97316"/>
  <svg x="62" y="62" width="800" viewBox="0 0 124 124" preserveAspectRatio="xMinYMin">
    <circle cx="63.2109" cy="37.5391" r="18.1641" fill="black"/>
  </svg>
</svg>

Used Versions

OS: Windows 11 DotNet Core 8 Render: Svg.Skia

Appendme avatar Dec 14 '23 07:12 Appendme