Skip to content

Commit 70e94fc

Browse files
tests/test_drawings.py: New tests for #4954: test_4954_1() test_4954_2().
1 parent 0c0b44c commit 70e94fc

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/test_drawings.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,39 @@ def test_3591():
228228
paths = page.get_drawings()
229229
for p in paths:
230230
assert p["width"] == 15
231+
232+
233+
def test_4954_1():
234+
path_out = os.path.normpath(f'{__file__}/../../tests/test_4954_1.pdf')
235+
with pymupdf.open() as document:
236+
page = document.new_page(width=200, height=200)
237+
shape = page.new_shape()
238+
shape.draw_line((0, 0), (1, 1))
239+
shape.finish(color=(0, 0, 0), width=0.1)
240+
shape.commit()
241+
content = b'q\n0.12 0 0 0.12 0 0 cm\n2 j\n6 w\n100 100 m\n800 100 l\nS\nQ\n'
242+
document.update_stream(page.get_contents()[0], content, compress=0)
243+
document.save(path_out)
244+
245+
with pymupdf.open(path_out) as document:
246+
d = document[0].get_drawings()[-1]
247+
print(f'{d["lineJoin"]=}') # Expected: 2, Actual: 0.24
248+
assert d['lineJoin'] == 2
249+
250+
251+
def test_4954_2():
252+
path_out = os.path.normpath(f'{__file__}/../../tests/test_4954_2.pdf')
253+
with pymupdf.open() as document:
254+
page = document.new_page(width=200, height=200)
255+
shape = page.new_shape()
256+
shape.draw_line((0, 0), (1, 1))
257+
shape.finish(color=(1, 0, 0), width=0.1)
258+
shape.commit()
259+
content = b'q\n2 0 0 3 0 0 cm\n1 w\n10 10 m\n90 10 l\nS\nQ\n'
260+
document.update_stream(page.get_contents()[0], content, compress=0)
261+
document.save(path_out)
262+
263+
with pymupdf.open(path_out) as document:
264+
d = document[0].get_drawings()[-1]
265+
print(f'{d["width"]=}') # Expected: 2.0, Actual: 1.0
266+
assert abs(d['width'] - 2.449) < 0.01

0 commit comments

Comments
 (0)