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

Gradient.draw and currentcolor #2320

Closed
l-vincent-l opened this issue Dec 4, 2024 · 6 comments
Closed

Gradient.draw and currentcolor #2320

l-vincent-l opened this issue Dec 4, 2024 · 6 comments
Labels
crash Problems preventing documents from being rendered

Comments

@l-vincent-l
Copy link

I'm building pages with weazyprint, and I have a problem with one page.

I can't figure out how to build a minimal case, but during the build I have this error message

Traceback (most recent call last):
  File "/home/…/bin/weasyprint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/…/lib/python3.12/site-packages/weasyprint/__main__.py", line 194, in main
    html.write_pdf(output, **options)
  File "/home/…/lib/python3.12/site-packages/weasyprint/__init__.py", line 265, in write_pdf
    self.render(font_config, counter_style, **options)
  File "/home/…/lib/python3.12/site-packages/weasyprint/document.py", line 404, in write_pdf
    pdf = generate_pdf(self, target, zoom, **options)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/…/lib/python3.12/site-packages/weasyprint/pdf/__init__.py", line 203, in generate_pdf
    page.paint(stream, scale)
  File "/home/…/lib/python3.12/site-packages/weasyprint/document.py", line 101, in paint
    draw_page(self._page_box, stream)
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 29, in draw_page
    draw_stacking_context(stream, stacking_context)
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 135, in draw_stacking_context
    draw_stacking_context(stream, child_context)
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 129, in draw_stacking_context
    draw_inline_level(stream, stacking_context.page, child)
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 536, in draw_inline_level
    draw_inline_level(
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 513, in draw_inline_level
    draw_background(stream, box.background)
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 250, in draw_background
    draw_background_image(stream, layer, bg.image_rendering)
  File "/home/…/lib/python3.12/site-packages/weasyprint/draw/__init__.py", line 278, in draw_background_image
    layer.image.draw(group, image_width, image_height, image_rendering)
  File "/home/…/lib/python3.12/site-packages/weasyprint/images.py", line 516, in draw
    color_couples[i][2] = a0 / a1

The Gradient is a LinearGradient with ('currentcolor', 'currentcolor') in colors.

Here's a complete failing example.
fail.zip

@liZe liZe added the crash Problems preventing documents from being rendered label Dec 4, 2024
@liZe
Copy link
Member

liZe commented Dec 4, 2024

Thanks for the report and the example, there’s obviously a problem with currentcolor used in gradients.

@l-vincent-l
Copy link
Author

Note that it works with version 62.0

@liZe
Copy link
Member

liZe commented Dec 4, 2024

Simple sample to reproduce: <div style="height: 10px; background: linear-gradient(currentcolor)"></div>.

@liZe liZe closed this as completed in db288a4 Dec 4, 2024
@liZe
Copy link
Member

liZe commented Dec 4, 2024

The crash should now be fixed, feedback is welcome.

Note that we still don’t draw the actual current color in this case (according to the TODO above the fixed line) but black. At least it doesn’t crash anymore.

@l-vincent-l
Copy link
Author

It works with the current version.

Thank you very much for the quick fix !

Will the fix be in the next release?

@liZe
Copy link
Member

liZe commented Dec 4, 2024

Will the fix be in the next release?

Yes, it will be in 63.1, when other bugs introduced by 63.0 are fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

2 participants