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

stop-opacity on linearGradient stops are not rendered #37

Open
iocoker opened this issue May 1, 2022 · 3 comments
Open

stop-opacity on linearGradient stops are not rendered #37

iocoker opened this issue May 1, 2022 · 3 comments

Comments

@iocoker
Copy link

iocoker commented May 1, 2022

SVG files with stop-opacity inside a stop are not rendering correctly. EG:

<linearGradient> <stop stop-color="#3f2600" stop-opacity="0.6" offset="0" /> <stop stop-color="#3f2600" stop-opacity="0" offset="1" /> </linearGradient>

Will render a uniform opacity of 0.6

tux

So, something like the Tux SVG above renders like this:
Screenshot 2022-05-01 134104

@rototor
Copy link
Owner

rototor commented May 1, 2022

@iocoker Thats a difficult issue. PDF does not support opacity gradients. At least not in PDF 1.7 (no idea about PDF 2.0; Did not yet pay for the spec... but likely not).

So this can only be faked somehow. Some common way to fake it, is to just rasterize the gradient as image. But this increases the file size a lot and also looks bad depending on the resolution used to rasterize the gradient...

Maybe it is possible to somehow implement that using soft masks. I'll have to investigate that.

rototor added a commit that referenced this issue May 1, 2022
@iocoker
Copy link
Author

iocoker commented May 1, 2022

@rototor , thanks for the reply.

The SVG is actually drawn into this sample and Acrobat reports its version as 1.7.
Sorry I'm not an expert on PDF, it could well be a 2.0 feature, as most PDF viewers are forgiving

example_058.pdf

@rototor
Copy link
Owner

rototor commented May 1, 2022

@iocoker I see, yes that is possible with PDF 1.7. In this example it uses a SMASK for the gradient masking.

I "just" need to replicate that.

rototor added a commit that referenced this issue May 1, 2022
And refactored the appling of the first color a bit.
rototor added a commit that referenced this issue May 1, 2022
as mask for the GradientPaint. This seems to work and look
fine.
rototor added a commit that referenced this issue May 1, 2022
But this is currently way of. There has to be put some
transform on it - or the "pattern" trick must be used
as seen in the tfpdf example.
rototor added a commit that referenced this issue May 1, 2022
Our small testcase works find, tux misses still
some gradients and some other svg causes crashes.

Also the code still needs to be cleaned up...
rototor added a commit that referenced this issue May 1, 2022
rototor added a commit that referenced this issue May 1, 2022
of the gradient is not going to cause any issues...

Added a colored version of tux to better see which
gradient is not working.
rototor added a commit that referenced this issue May 1, 2022
rototor added a commit that referenced this issue May 1, 2022
not working gradient.

Some stuff with the matrix seens to be wrong.
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