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

Fix that affects MANY inkscape files: implicit "absolute" line segments were being converted to "relative" #2

Merged
merged 2 commits into from
Nov 23, 2011

Conversation

adamgit
Copy link

@adamgit adamgit commented Nov 23, 2011

I may have mis-read the spec, but my understanding is that in e.g.:

M 1,1 2,2, 3,3 z

...you should end up at (3,3)

Your code ends up at (6,6), because it assumes that the implicit "M"s were all relative.

This commit adds an extra BOOL to keep track of whethter the "initiating" command was relative or absolute.

There's also a very simple SVG file that demonstrates the bug clearly, and shows the fix working.

adam added 2 commits November 23, 2011 16:44
…gments whenever the letter was not repeated in the command. You have to keep track of whether the initial command was relative or absolute - previous code was just "assuming" relative for all cases.
…Open in Inkscape - you should see a square rotated 45 degrees (ie a diamond shape) with the bottom-left segment a concave curve instead of a straigtht line. Before the fix, you just got an ugly mess.
@adamgit
Copy link
Author

adamgit commented Nov 23, 2011

...but: if I've got the spec wrong, then Inkscape and OS X Preview have it wrong too :). Both of them render as per the fixed code, not the pre-fixed code

@reklis
Copy link
Owner

reklis commented Nov 23, 2011

Good catch, thanks :)

SLF

On Nov 23, 2011, at 11:50 AM, [email protected] wrote:

I may have mis-read the spec, but my understanding is that in e.g.:

M 1,1 2,2, 3,3 z

...you should end up at (3,3)

Your code ends up at (6,6), because it assumes that the implicit "M"s were all relative.

This commit adds an extra BOOL to keep track of whethter the "initiating" command was relative or absolute.

There's also a very simple SVG file that demonstrates the bug clearly, and shows the fix working.

You can merge this Pull Request by running:

git pull https://github.com/adamgit/SVGKit master

Or you can view, comment on it, or merge it online at:

#2

-- Commit Summary --

  • Fixed bug: relative line segments were being converted to absolute segments whenever the letter was not repeated in the command. You have to keep track of whether the initial command was relative or absolute - previous code was just "assuming" relative for all cases.
  • Test-case that shows the previous fix working, as opposed to broken. Open in Inkscape - you should see a square rotated 45 degrees (ie a diamond shape) with the bottom-left segment a concave curve instead of a straigtht line. Before the fix, you just got an ugly mess.

-- File Changes --

M Core/SVGPathElement.m (58)
A Samples/test-diamond-with-one-curve.svg (62)

-- Patch Links --

https://github.com/reklis/SVGKit/pull/2.patch
https://github.com/reklis/SVGKit/pull/2.diff


Reply to this email directly or view it on GitHub:
#2

reklis pushed a commit that referenced this pull request Nov 23, 2011
Fix that affects MANY inkscape files: implicit "absolute" line segments were being converted to "relative" (thanks adamgit)
@reklis reklis merged commit 77b7f38 into reklis:master Nov 23, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants