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

Opacity does not support percentage #1986

Closed
michaellisitsa opened this issue Oct 12, 2023 · 1 comment
Closed

Opacity does not support percentage #1986

michaellisitsa opened this issue Oct 12, 2023 · 1 comment
Labels
feature New feature that should be supported
Milestone

Comments

@michaellisitsa
Copy link

Failure occurs in v59 of weasyprint. There is no support for percentage values, instead the print fails. I believe we should support it per https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-opacity or if that's too hard at least have a fallback incase its not a float.

Source code

It appears like the problem might be with trying to coerce the value to a float

stroke_opacity = float(node.get('stroke-opacity', 1))

Failure log

File \"/usr/local/lib/weasyprint/.venv/lib/python3.8/site-packages/weasyprint/svg/__init__.py\", line 633, in fill_stroke\n    stroke_opacity = float(node.get('stroke-opacity', 1))\nValueError: could not convert string to float: '40%'\n",
@liZe liZe changed the title Stroke-opacity does not support percentage Opacity does not support percentage Oct 13, 2023
@liZe liZe added the feature New feature that should be supported label Oct 13, 2023
@liZe
Copy link
Member

liZe commented Oct 13, 2023

Hi!

Thanks for the bug report.

All opacity and *-opacity properties should allow percentages, in SVG and CSS, as defined in CSS Color Level 4.

Correctly handling errors in SVG is not done yet, so I’m not sure that we’ll implement a nice fallback just here. But handling percentages will definitely fix your problem.

@liZe liZe closed this as completed in cf9e7cd Feb 3, 2024
@liZe liZe added this to the 61.0 milestone Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

No branches or pull requests

2 participants