managed-commons / SvgNet

Fork of the SVG library for .NET that makes a GdiGraphics that "draws" on a SVG model
BSD 3-Clause "New" or "Revised" License
84 stars 37 forks source link

Implicit lineto commands are not parsed correctly #16

Closed glopesdev closed 6 years ago

glopesdev commented 6 years ago

I was trying to validate some SVG documents, and suddenly noticed that the parser does not correctly handle implicit lineto commands. For example, the following path definition should draw two disconnected lines as part of the same path:

<path d="m 2.5260284,293.65894 0.8048868,-1.79707 m 1.6705196,-0.15693 0.784638,1.84769"/>

According to the SVG specification: "If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands. Hence, implicit lineto commands will be relative if the moveto is relative, and absolute if the moveto is absolute."

However, the SvgPath class parser appears to treat this as a single line. Because of this, it is impossible to parse many of the more complex paths generated by software such as inkscape. I understand SvgNet had a bigger focus in writing SVG, but reading SVG is useful as well, to allow serialization of GDI+ commands, for example in copy/paste functions or storing/retrieving line drawings.

monoman commented 6 years ago

Thanks, I'll take a look

Rafael Teixeira O..:.)oooo

On Wed, May 2, 2018 at 6:30 AM glopesdev notifications@github.com wrote:

I was trying to validate some SVG documents, and suddenly noticed that the parser does not correctly handle implicit lineto commands. For example, the following path definition should draw two disconnected lines as part of the same path:

According to the SVG specification https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands: "If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands. Hence, implicit lineto commands will be relative if the moveto is relative, and absolute if the moveto is absolute."

However, the SvgPath class parser appears to treat this as a single line. Because of this, it is impossible to parse many of the more complex paths generated by software such as inkscape. I understand SvgNet had a bigger focus in writing SVG, but reading SVG is useful as well, to allow serialization of GDI+ commands, for example in copy/paste functions or storing/retrieving line drawings.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/managed-commons/SvgNet/issues/16, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOfNEheSQ5Cr6_GQjt2yI0hMStRnq8Eks5tuXzOgaJpZM4TvIzY .