Support context paint in SVG markers#2744
Open
moreaki wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2667.
Context
SVG 2 adds
context-fillandcontext-strokepaint values so marker contents can use the fill or stroke paint of the element referencing the marker. The motivating issue uses a marker circle withstroke="context-stroke"andfill="context-fill"on a dashed red path. In browsers such as Firefox, the marker takes the path paint values, but WeasyPrint did not recognize these keywords.While investigating this, there was also an older rendering problem exposed by the same example: the dashed PDF graphics state from the referencing path could leak into marker contents. That meant a marker stroke could become dashed even if the marker child itself had no
stroke-dasharray. This was not specific to the new SVG 2 keywords; it could happen with a plainstroke="red"marker too.Changes
context-fillandcontext-strokepaint values from that context node.stroke-dasharray, preventing marker strokes from inheriting a dashed graphics state from the referencing path.Scope and follow-up
This is intentionally a first, narrow slice of SVG 2 context paint support. It does not try to implement every context-paint case from the spec. In particular,
use-element context paint and paint-server coordinate-space continuity for contextual paint values remain follow-up work.Tests
venv/bin/python -m pytest tests/draw/svg/test_markers.pyvenv/bin/python -m pytest tests/draw/svgvenv/bin/python -m ruff check weasyprint/svg/__init__.py tests/draw/svg/test_markers.py