Skip to content

SVG: apply a gradient set on a <use> - #2220

Open
RavSinghChandan wants to merge 2 commits into
py-pdf:masterfrom
RavSinghChandan:svg-use-gradient-fill
Open

RavSinghChandan wants to merge 2 commits into
py-pdf:masterfrom
RavSinghChandan:svg-use-gradient-fill

Conversation

@RavSinghChandan

Copy link
Copy Markdown

A fill or stroke that is a gradient (url(#g)) on a <use> was dropped: the referenced shape was drawn without it, while a <g> with the same gradient worked. In SVG the paint set on the <use> is inherited by what it draws, as for a group, and browsers apply it.

build_xref() now applies the gradient paint of the <use> to its group, the way a <g> already does. If the referenced element sets its own fill (including fill="none"), that still wins, as in Chrome. I compared fill and stroke gradients on a <use>, a <use> of a <use>, and a <use> inside a transformed group with Chrome, and they match.

I added tests in test/svg/test_svg_gradients.py, and they fail without the change.

This branch has not been deployed

No deployments
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.

1 participant