Skip to content

SVG: read var() with the CSS custom properties or the fallback - #2200

Open
RavSinghChandan wants to merge 2 commits into
py-pdf:masterfrom
RavSinghChandan:svg-css-var
Open

RavSinghChandan wants to merge 2 commits into
py-pdf:masterfrom
RavSinghChandan:svg-css-var

Conversation

@RavSinghChandan

Copy link
Copy Markdown

Figma writes colors as fill="var(--fill-0, #171D25)" when they are variables, and VS Code extensions write fill="var(--vscode-foreground, #808080)" in their walkthrough images, as in the Python and Jupyter extensions. Both fail with ValueError: unsupported color specification var(...).

A var() in a style or a presentation attribute now takes the value of the custom property, declared in a <style> or a style attribute on the element or an ancestor, or else its fallback, as in browsers. Without either, or with custom properties that reference each other in a cycle, the property is inherited, as CSS makes it invalid at computed-value time. The substitution is bounded, so properties that double at each step stop being substituted.

test_svg_css_var, test_svg_css_var_opacity_and_transform and test_svg_css_var_substitutions_are_bounded cover these; 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