From 8bc6161f0b6d7a3043671051a361bcb022c67271 Mon Sep 17 00:00:00 2001 From: "Jorj X. McKie" Date: Sun, 27 Sep 2026 11:25:48 -0400 Subject: [PATCH] Fix 5122 We must ensure that rectangle path items return the top-left corner as the starting point of the drawing operation. --- src/__init__.py | 7 +++++-- src/extra.i | 4 +++- tests/resources/test_5122.pdf | Bin 0 -> 465 bytes tests/test_5122.py | 12 ++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/resources/test_5122.pdf create mode 100644 tests/test_5122.py diff --git a/src/__init__.py b/src/__init__.py index 86317017f..c2588e120 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -11912,7 +11912,7 @@ def get_cdrawings(self, extended=None, callback=None, method=None): assert isinstance(page, mupdf.FzPage), f'{self.this=}' clips = True if extended else False prect = mupdf.fz_bound_page(page) - if 1 or g_use_extra: + if g_use_extra: rc = extra.get_cdrawings(page, extended, callback, method) else: rc = list() @@ -23514,7 +23514,10 @@ def jm_checkrect(dev): ): return 0 # not a rectangle - # we have a rect, replace last 3 "l" items by one "re" item. + # we have a rect + dev.lastpoint = ll # last point is the start of the first line + + # replace last 3 "l" items by one "re" item. if ul.y < lr.y: r = mupdf.fz_make_rect(ul.x, ul.y, lr.x, lr.y) orientation = 1 diff --git a/src/extra.i b/src/extra.i index f7da7bf19..7af38ee1f 100644 --- a/src/extra.i +++ b/src/extra.i @@ -2467,8 +2467,10 @@ jm_checkrect(jm_lineart_device* dev) ur.x != lr.x) { goto drop_out; // not a rectangle } + // we have a rect + dev->lastpoint = fz_make_point(ll.x, ll.y); // set last point to start of first line - // we have a rect, replace last 3 "l" items by one "re" item. + // replace last 3 "l" items by one "re" item. if (ul.y < lr.y) { r = fz_make_rect(ul.x, ul.y, lr.x, lr.y); orientation = 1; diff --git a/tests/resources/test_5122.pdf b/tests/resources/test_5122.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ccfe445d223c933cb02acdca91b701a6373ba753 GIT binary patch literal 465 zcmZXR!A`?442JJ{3SW90N!n%%Y3hN&E`XReZWD(9M=QiW(`3^82%Y zJ4seI%Za|og$4!g>kUB4l zfe!<}KKIyGaSvI}@en=QcbfQ9XsUaea($T4;ZbCyOldb_!;|)GKl9P!PAD)!{VkXp zlNs2-S-XNR3hh}lvyrB?8EL5=