Skip to content

ViewBox is not handled correctly #287

Description

@widi8835

I use FileSvgReader to read SVGs and use the resulting Drawing in my software. In WpfDrawingSettings EnsureViewboxPosition and EnsureViewboxSie are set to true.
In v1.8.1 it works like expected. Since at least v1.8.3 the ViewBox isn't correctly handled anymore.

Tested with WpfSvgTestBox (*_expected.png faked with option EnsureViewBox=false):

  1. ViewBox is not handled correctly
    ViewBox_Screenshot_EnsureViewBox ViewBox_Screenshot_expected
    ViewBox.svg:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- Created with Inkscape (http://www.inkscape.org/) -->
    
    <svg
       width="15.000001mm"
       height="15mm"
       version="1.1"
       id="svg3307"
       viewBox="7.5 7.5 41.500003 41.5"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:svg="http://www.w3.org/2000/svg">
      <defs
         id="defs3304" />
      <g
         id="g21921"
         transform="matrix(1.8876249,0,0,1.8876249,20.026725,-10.180173)">
        <rect
           style="fill:#ff0000;stroke:none;stroke-width:3.68483;stroke-opacity:1"
           id="rect23997"
           width="21.9853"
           height="21.9853"
           x="-6.6362362"
           y="9.3663597" />
        <ellipse
           style="fill:#000000;stroke:#000000;stroke-width:0.244809"
           id="path3845"
           cx="10.034876"
           cy="15.062319"
           rx="5.1643801"
           ry="5.5422616" />
      </g>
      <circle
         style="fill:#000000;stroke:#000000;stroke-width:0.462107"
         id="path3843"
         cx="18.013865"
         cy="38.604069"
         r="10.223943" />
    </svg>
  2. Translation is not handled correctly: it seems, that when WpfDrawingContext.UpdateBounds is call (with option 'EnsureViewboxSize=true'), translation is not considered
    Translation_Screenshot_EnsureViewBox Translation_Screenshot_expected
    Translation.svg:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- Created with Inkscape (http://www.inkscape.org/) -->
    
    <svg
       width="32mm"
       height="32mm"
       viewBox="0 0 32 31.999999"
       version="1.1"
       id="svg3307"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:svg="http://www.w3.org/2000/svg">
      <defs
         id="defs3304" />
      <rect
         style="fill:#ffff00;stroke-width:0.33445"
         id="rect24983"
         width="32"
         height="32"
         x="0"
         y="0" />
      <g
         id="g3848"
         transform="translate(-47.721429,-75.213883)">
        <circle
           style="fill:#000000;stroke:#000000;stroke-width:0.334433"
           id="path3843"
           cx="70.732185"
           cy="98.952362"
           r="7.399189" />
      </g>
      <ellipse
         style="fill:#000000;stroke:#000000;stroke-width:0.334433"
         id="path3845"
         cx="8.2220945"
         cy="8.4335947"
         rx="7.0550404"
         ry="7.5712628" />
    </svg>

SVGs are created with Inkscape 1.2.2 (732a01da63, 2022-12-09)

By the way: Thanks for you work!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions