From 285c8ae87f660109afecbb9fe45cd1547da47ad4 Mon Sep 17 00:00:00 2001 From: David Huggins-Daines Date: Mon, 2 Dec 2024 08:06:04 -0500 Subject: [PATCH] fix: do not create empty PathObject --- playa/page.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/playa/page.py b/playa/page.py index 0a2007c..62f8a7c 100644 --- a/playa/page.py +++ b/playa/page.py @@ -2146,6 +2146,8 @@ def create(self, object_class, **kwargs) -> ContentObject: def do_S(self) -> Iterator[ContentObject]: """Stroke path""" + if not self.curpath: + return yield self.create( PathObject, stroke=True, @@ -2162,6 +2164,8 @@ def do_s(self) -> Iterator[ContentObject]: def do_f(self) -> Iterator[ContentObject]: """Fill path using nonzero winding number rule""" + if not self.curpath: + return yield self.create( PathObject, stroke=False, @@ -2177,6 +2181,8 @@ def do_F(self) -> Iterator[ContentObject]: def do_f_a(self) -> Iterator[ContentObject]: """Fill path using even-odd rule""" + if not self.curpath: + return yield self.create( PathObject, stroke=False, @@ -2188,6 +2194,8 @@ def do_f_a(self) -> Iterator[ContentObject]: def do_B(self) -> Iterator[ContentObject]: """Fill and stroke path using nonzero winding number rule""" + if not self.curpath: + return yield self.create( PathObject, stroke=True, @@ -2199,6 +2207,8 @@ def do_B(self) -> Iterator[ContentObject]: def do_B_a(self) -> Iterator[ContentObject]: """Fill and stroke path using even-odd rule""" + if not self.curpath: + return yield self.create( PathObject, stroke=True,