Missing "lineto" in line-draw -- is this an Inkscape bug?

Discuss SVG code, accessible via the XML Editor.
Farry
Posts: 6
Joined: Sun Nov 29, 2009 11:18 pm

Missing "lineto" in line-draw -- is this an Inkscape bug?

Postby Farry » Mon Nov 30, 2009 12:41 am

Apologies for raising the possible issue of a bug here, but I've not looked at SVG before, and I'd like know what you think of this.

I've been puzzling over why the Konqueror web-browser doesn't display any lines drawn by Inkscape, and yet other browsers and image viewers do, so after a bit of hacking of the generated SVG down to the bare minimum to show the issue, I think I might have found out why.

When Inkscape generates the SVG code for a line, it creates a path element with an "m" (moveto) command, followed by the x and y coordinates, followed by the relative x and y coordinates of the drawn line. However, the SVG spec http://www.w3.org/TR/SVG/paths.html says that relative line-draw coordinates should be preceded by an "l" (lower-case L lineto) command, and that pairs of numbers on their own are treated as a repetition of the previous command. Thus it seems to me that the Konqueror web-browser is correctly treating the second xy pair as another moveto command and so no line is drawn. (And yet Firefox and various image viewers that I've tried do show the line despite this.)

Here's my example code. Note that the code for the red line does not include that lower-case L, but the blue line does:

Code: Select all

<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60">
  <g>
    <rect width="60" height="60" x="20" y="0" fill="yellowgreen" />
    <path d="m 0 40 100 0" stroke="red" stroke-width="10" />
    <path d="m 0 20 l 100 0" stroke="blue" stroke-width="10" />
  </g>
</svg>

This is the embedded SVG image itself: SVG Image
This is a PNG image of what Firefox sees: Image
This is a PNG image of what Konqueror sees: Image
Last edited by Farry on Mon Nov 30, 2009 3:15 am, edited 1 time in total.

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Missing "lineto" in line-draw -- is this an Inkscape bug?

Postby sas » Mon Nov 30, 2009 1:31 am

This is a Konqueror bug. See the last sentence of the description column in section 8.3.2 of the SVG spec.

Farry
Posts: 6
Joined: Sun Nov 29, 2009 11:18 pm

Re: Missing "lineto" in line-draw -- is this an Inkscape bug?

Postby Farry » Mon Nov 30, 2009 1:47 am

Ah, thanks, I see. It says "If a moveto is followed by multiple pairs of coordinates, the subsequent pairs are treated as implicit lineto commands."

Whoever wrote Konqueror's SVG subsystem must've missed that as I did, and took note instead of the sentence in 8.3.1 that says: "The command letter can be eliminated on subsequent commands if the same command is used multiple times in a row".

Ho hum. I'll look at the KDE bugzilla, and raise a bug if it's not already there.

Edit: Done. https://bugs.kde.org/show_bug.cgi?id=216686

User avatar
sas
Posts: 404
Joined: Sat Oct 06, 2007 5:42 am

Re: Missing "lineto" in line-draw -- is this an Inkscape bug?

Postby sas » Mon Nov 30, 2009 11:30 pm

By the way, there's an option in Inkscape Preferences (in the "SVG output" section) called "Force repeat commands". If you tick this option, then Inkscape should write all the path commands explicitly, which would avoid this problem. (But this only applies to new paths. Getting it to rewrite the path data for paths that already exist is another matter.)

Farry
Posts: 6
Joined: Sun Nov 29, 2009 11:18 pm

Re: Missing "lineto" in line-draw -- is this an Inkscape bug?

Postby Farry » Tue Dec 01, 2009 4:06 am

Thanks. Seems that making a minor change, like ungrouping then re-grouping objects will re-write existing paths and avoid the problem.


Return to “SVG / XML Code”