Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewBox is not handled correctly #287

Open
widi8835 opened this issue Jun 4, 2024 · 3 comments
Open

ViewBox is not handled correctly #287

widi8835 opened this issue Jun 4, 2024 · 3 comments
Assignees

Comments

@widi8835
Copy link

widi8835 commented Jun 4, 2024

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!

@paulushub
Copy link
Contributor

I thought we have resolved this in #278

@widi8835
Copy link
Author

widi8835 commented Jun 4, 2024

Unfortunately not. I tested it with 1.8.4 too.

@paulushub
Copy link
Contributor

Unfortunately not. I tested it with 1.8.4 too.

Maybe we just have to drop the WPF specific options, getting difficult finding a solution that will satisfy all cases.

@paulushub paulushub self-assigned this Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants