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

gradientTransform on linearGradient is not supported #112

Closed
thomasheinen opened this issue Aug 23, 2019 · 8 comments
Closed

gradientTransform on linearGradient is not supported #112

thomasheinen opened this issue Aug 23, 2019 · 8 comments

Comments

@thomasheinen
Copy link

Hi,

I have encountered an SVG which is not correctly rendered. Only the outer black ring is shown. The inner blue flames are not rendered at all. Batik and other programs render it correctly.

I have two versions of the same SVG (converted with inkscape from EPS using different converters). Both are not working.

I don't think this issue is related to #85 or #87 but I might be mistaken.
Could you please look into it? Thanks in advance.

Thomas.

broken-svgs.zip

@mogest
Copy link
Owner

mogest commented Aug 23, 2019

Hi @thomasheinen, thanks for posting.

That's an absolutely enormous SVG file you've supplied—could you please narrow the scope for me by paring it down to a minimal file that still reproduces the error? Happy to dig into it at that point.

@thomasheinen
Copy link
Author

Hi @mogest

Thanks for your fast reply. You are right, sorry. It was not very thoughtful of me to whip such a big file into your face. 😄

Please find attached a minimal example. The black circle is rendered correctly. The blue "egg" vanishes in the PDF, but is rendered in external programs and the HTML version correctly.

broken-svg-minimal.zip

@mogest
Copy link
Owner

mogest commented Aug 23, 2019

Ah, OK the first clue is that it does spit out a warning:

prawn-svg does not yet support gradients with a non-identity gradientTransform attribute

I don't actually know what that even means (yes I wrote that error message!) so I'll go looking.

@mogest
Copy link
Owner

mogest commented Aug 23, 2019

Ah, OK. Because the <linearGradient> elements in your document have gradientTransform attributes, it's skipping the gradient altogether which makes it not render.

I took those attributes out and it doesn't render correctly (it looks like it's missing the fade-out altogether.)

I tried a bit of hackery, the gradients are handled by Prawn but I managed to monkey patch the method that applies the transformation matrix to the gradient and multiply the supplied gradient on the attribute. Unfortunately I must be misunderstanding something, because it's all one colour after I do that.

This is probably not a super easy fix I'm sorry to say. I'll keep it open in case I want to beat my head against a wall sometime :)

@mogest mogest changed the title SVGs are not correctly rendered gradientTransform on linearGradient is not supported Aug 23, 2019
@thomasheinen
Copy link
Author

Hm okay. Maybe we'll have a look at it ourselves, but we are no Ruby programmers here. 😅 We are just using ASCII Doc for some fancy reporting in our framework and stumbled upon the problem with that SVG.

Thanks for looking into it anyway, and some hard head-banging on your side would be much appreciated. 😉 🤘

@mogest
Copy link
Owner

mogest commented Aug 23, 2019

Would you believe... I actually managed to get it going. Still needs a lot of tidying up since I have to monkey patch Prawn (their release cycle is slow) but if you want to try it out on the issue-112 branch please do!

logo-gas.svg.pdf

mogest pushed a commit that referenced this issue Aug 24, 2019
Also implements the missing skewX and skewY transforms to normal
transforms.

Requested on #112
@mogest
Copy link
Owner

mogest commented Aug 24, 2019

All done, it'll go out with the next release.

@mogest mogest closed this as completed Aug 24, 2019
@thomasheinen
Copy link
Author

I can confirm that the patch is working. Thanks very much for your effort. 👍

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