cantoo-scribe / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
136 stars 27 forks source link

Fix duplicate adjustment in SVG path command T #30

Closed ralfstx closed 1 year ago

ralfstx commented 1 year ago

The control point (px, py) is already updated in the else branch above (L271). It is then updated once again which causes https://github.com/Hopding/pdf-lib/issues/1443

This commit removes these duplicated lines which fixes the bug.

What?

Fixes https://github.com/Hopding/pdf-lib/issues/1443

Why?

Because we're making the world a better place.

How?

See code. Removed two lines of code which were clearly wrong.

Testing?

I've come across this issue cheating when I implemented SVG path support in PDF Maker.

As explained in the bug mentioned above, with this path: M 10,25 Q 30,0 50,25 Q 70,50 90,25 T 130,25 T 170,25, the green line in the image below should be rendered, but the red line actually is.

To reprocude, try drawSvgPath('M 10,25 Q 30,0 50,25 Q 70,50 90,25 T 130,25 T 170,25')

New Dependencies?

No.

Screenshots

image

Suggested Reading?

Unrelated, but yes, I've read most of the PDF 1.7 spec :nerd_face:

Anything Else?

Thanks for keeping this project alive, guys! :heart:

Checklist