Skip to content

Conversation

@johnkenny54
Copy link
Contributor

This PR fixes the problem raised in issue #1267. The general issue is that merging paths into a single element changes the bounding box, so any style that depends on the bounding box of the element may change behavior. This PR disables merging for any paths that have:

  • A fill, filter, or stroke that references a URL.
  • A clip-path or mask.

It's possible that there are other scenarios where merging should be disabled, but those above are the only ones that I was able to construct a test case for so far.

With the current regression settings, there is no change in pixel mismatches in the regressions. With the Oxygen files, only one file seems to be affected - scalable/status/weather-few-clouds-night.svg. The clouds were rendered incorrectly in the optimized version before the fix.

Closes #1267

@johnkenny54 johnkenny54 marked this pull request as ready for review February 15, 2024 16:16
Copy link
Member

@SethFalco SethFalco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left one minor comment, but overall this looks good. Thanks for spotting the issue and submitting a patch.

@SethFalco SethFalco merged commit a8d2df6 into svg:main Feb 25, 2024
@KTibow
Copy link
Contributor

KTibow commented Feb 25, 2024

I'm a bit late here but this "is the path bounding box sensitive?" logic would be useful for #1951, and I'm going to move it to a function to reduce duplication. Which file would that function best fit in?

@SethFalco
Copy link
Member

@KTibow Nothing shouts out to me, so I'd default to lib/svgo/tools.js.

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

Successfully merging this pull request may close these issues.

Combining multiple shapes into a <path> breaks <linearGradient>

3 participants