Skip to content

SVG: accept transparent and case-insensitive color keywords in fill and stroke - #1997

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-transparent-and-keyword-case
Oct 11, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:svg-transparent-and-keyword-case

Conversation

@RavSinghChandan

Copy link
Copy Markdown

Importing an SVG with fill="transparent" or stroke="transparent", which design tools and browsers export often, raised ValueError: unsupported color specification transparent. A color keyword in another case, such as fill="RED", failed the same way, although SVG/CSS color keywords are ASCII case-insensitive.

svgcolor() now looks keywords up case-insensitively (and strips the value), and a small svg_paint() used by fill and stroke treats transparent like none, painting nothing. url(...), inherit and currentColor behave as before. Added cases to test_svg_attribute_conversion.

Checklist:

  • A unit test is covering the code added / modified by this PR
  • In case of a new feature, docstrings have been added, with also some documentation in the docs/ folder (N/A)
  • A mention of the change is present in CHANGELOG.md
  • This PR is ready to be merged

By submitting this pull request, I confirm that my contribution is made under the terms of the GNU LGPL 3.0 license.

@RavSinghChandan RavSinghChandan changed the title SVG: accept transparent and case-insensitive color keywords in fill a… SVG: accept transparent and case-insensitive color keywords in fill and stroke Oct 11, 2026

@andersonhc andersonhc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to merge. Thanks.

@andersonhc
andersonhc merged commit e4978e1 into py-pdf:master Oct 11, 2026
23 checks passed
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.

2 participants