Skip to content

Draw Svg in Svg with different ViewBox #1108

Open
@Appendme

Description

@Appendme

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions