-
-
Notifications
You must be signed in to change notification settings - Fork 706
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
SVG with linearGradient using matrix gradientTransform is not rendered correctly #1601
Comments
Hello! There’s a problem about translations in <svg viewBox="0 0 800 800" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="gradient" gradientTransform="translate(1, 0)">
<stop offset="0" stop-color="blue" />
<stop offset="1" stop-color="yellow"/>
</linearGradient>
</defs>
<rect width="800" height="800" fill="url(#gradient)"/>
</svg>
That’s a good question. The current code drawing gradients is broken in many ways, because testing gradients is hard and there are so many different features. I tried to find a quick fix but the problem seems to be deep in the way we handle If someone is interested in SVG gradients and in the PDF specification (does someone like this even exist?), we’d be happy to get some help about this. |
Maybe off-topic, but why did you (had to) decide to stop using CairoSVG? I think it is very unfortunate, as I had no issues at all in the past few years when WeasyPrint still used CairoSVG. Maybe it is possible to use the implementation of CairoSVG regarding gradients as a reference to implement something new? |
Everything is explained in this article.
We’re really sorry for you. We tried hard to keep the same features and renderings, but it was obvious that we were about to face bugs like this one.
We actually reused CairoSVG’s code to handle SVGs in the new version of WeasyPrint. But of course, we had to change many things as pydyf is a low-level library while Cairo is more high-level. Handling gradients is one of the areas where we had to rewrite almost everything because of very different APIs, fixing some bugs like #790, but creating new ones like this one. |
Thank you for your quick reply and clear explanation. Cairo wasn't an optimal solution for the long term, as I understand it. Well, let's hope one day all SVG features are back again :). Besides this I use WeasyPrint a lot and it works very well! |
Using the new way of SVG rendering (v53+), a matrix gradientTransform gradient is no longer working. Is this something WeasyPrint could support again in the near future?
![test_gradient](https://user-images.githubusercontent.com/5802207/158984788-f5753910-8d5f-4404-8b6c-f62db68cc1f6.svg)
The text was updated successfully, but these errors were encountered: