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

Markers with viewBox attribute have a border applied around the viewBox automatically #1982

Closed
michaellisitsa opened this issue Oct 11, 2023 · 2 comments
Milestone

Comments

@michaellisitsa
Copy link

michaellisitsa commented Oct 11, 2023

There is an issue where markers with a viewBox attribute are showing with a rectangular border in >v55
image
Browsers do not have this behaviour see https://codepen.io/michaellisitsa/pen/xxmBbye and couldn't find anything in the https://www.w3.org/TR/SVG/painting.html#RenderingMarkers

Investigation of bug
The bug only surfaced at v55.0 where a fix was made to the viewBox for markers 607f26f

A check occurs in svg/__init__.py file for the viewBox attribute on the marker node, and as a results a clip box is created on

Further down, a check is done for the clip_box and a rectangle is drawn. I believe this shouldn't be the case.

self.stream.rectangle(*clip_box)

Reproducable example

<svg
          width="600"
          height="217"
          role="img"
          viewBox="0 0 600 217"
          style="pointer-events: all; width: 100%; height: 100%"
        >
          <defs>
            <marker
            id="circle"
              viewBox="0 0 10 10"
              refX="10"
              refY="5"
              markerWidth="15"
              markerHeight="15"
              orient="auto"
              stroke="none"
            >
              <circle cx="2.5" cy="7.5" r="2.0" stroke="red" fill="transparent" stroke-width="1"/>
            </marker>
          </defs>
            <path
              d="M102.86664121071314,106.99999999999997L102.86664121071314,59"
              style="
                fill: none;
                stroke: black;
                pointer-events: stroke;
                marker-end: url(#circle);
                stroke-width: 2;
              "
              role="presentation"
              shape-rendering="auto"
            ></path>
        </svg>
@liZe
Copy link
Member

liZe commented Oct 11, 2023

Hi!

Thanks for the report.

We should add self.stream.end() after clipping, otherwise the rectangle will be used during the drawing. The push/pop state is probably also useless. I’ll push the fix as soon as I find the time to add some related tests!

@liZe liZe added this to the 61.0 milestone Oct 11, 2023
@liZe liZe closed this as completed in ff3b417 Oct 11, 2023
@liZe
Copy link
Member

liZe commented Oct 11, 2023

This problem is fixed and some tests have been added, but there are probably many problems left with markers and their wonderful list of available attributes. Don’t hesitate to report more issues if needed!

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