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

SVG-Fix clipping path being painted - issue #1147 #1150

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
### Fixed
* ordering RTL fragments on bidirectional texts
* fixed type hint of member `level` in class [`OutlineSection`](https://py-pdf.github.io/fpdf2/fpdf/outline.html#fpdf.outline.OutlineSection) from `str` to `int`.
* SVG clipping paths being incorrectly painted - _cf._ [issue #1147](https://github.com/py-pdf/fpdf2/issues/1147)]
### Changed
* improved the performance of `FPDF.start_section()` - _cf._ [issue #1092](https://github.com/py-pdf/fpdf2/issues/1092)
### Deprecated
Expand Down
3 changes: 3 additions & 0 deletions fpdf/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from fontTools.svgLib.path import parse_path
from fontTools.pens.basePen import BasePen

from .enums import PathPaintRule

try:
from defusedxml.ElementTree import fromstring as parse_xml_str
except ImportError:
Expand Down Expand Up @@ -963,6 +965,7 @@ def build_clipping_path(self, shape, clip_id):
elif shape.tag in xmlns_lookup("svg", "path"):
clipping_path_shape = PaintedPath()
apply_styles(clipping_path_shape, shape)
clipping_path_shape.paint_rule = PathPaintRule.DONT_PAINT
svg_path = shape.attrib.get("d")
if svg_path is not None:
svg_path_converter(clipping_path_shape, svg_path)
Expand Down
Binary file added test/svg/generated_pdf/path_clippingpath.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions test/svg/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,10 @@ def Gs(**kwargs):
svgfile("issue-1076.svg"),
id="<clipPath> containing a <path>",
),
pytest.param(
svgfile("path_clippingpath.svg"),
id="<clipPath> containing a <path> used in a group with color - issue #1147",
),
)

svg_path_edge_cases = (
Expand Down
Loading
Loading