path segments are lost

Bug #395647 reported by Frederik Elwert
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Scour
Fix Released
Undecided
codedread

Bug Description

When cleaning up path data, the last segment is lost in special cases. This bug is introduced in scour 0.14, so I guess it’s related to the attempt to remove the last segment whith closed paths. But in some cases, the path isn’t closed after the cleanup.

I noticed this behaviour with a cairo generated file. Cairo creates a bit odd paths with a M command after the path is closed by Z. Maybe this causes the problem.

Original path:
M 601.441406 216 L 649.480469 216 L 649.480469 273.601562 L 601.441406 273.601562 Z M 601.441406 216

Cleaned path with lost segment:
M601.44,216h48.04v57.60h-48.04m0-57.60

Revision history for this message
codedread (codedread) wrote :

Hi Frederik,

I appreciate this bug - can you possibly send me a file where the path generated by scour actually causes a visual problem?

The example you have given shows the converted path as being identical except for missing the closepath ('Z') segment. Scour 0.14 was simply dropping the Z segment (closepath) and this didn't cause a problem in Firefox, Opera or Safari.

I have worked out a modified version of scour that no longer drops the closepath commands. I have checked this in as revision 105. Can you please test it?

Thanks,
Jeff

Revision history for this message
codedread (codedread) wrote :

Potential fix checked in as revision 105

Changed in scour:
assignee: nobody → codedread (codedread)
status: New → In Progress
Revision history for this message
Frederik Elwert (frederik-elwert) wrote :

> I appreciate this bug - can you possibly send me a file where the path generated by scour actually causes a visual problem?

I have attached an SVG file generated by R using cairo as its backend. When running scour 0.14 on it, rectangles (like the border around the legend) loose one edge.

> The example you have given shows the converted path as being identical except for missing the closepath ('Z') segment. Scour 0.14 was simply dropping the Z segment (closepath) and this didn't cause a problem in Firefox, Opera or Safari.

Ok, than I misunderstood what scour was trying to do. In many SVG files (e.g., generated by Inkscape) the Z segment can be omitted, since its redundant: The last segment of closed paths usually ends at the starting point. But in the example file, the Z segment is used in a propper and efficient way: Only three segments of a rectangle are drawn, and the Z segment closes the rectangle.

If one wanted to make use of the Z command in scour, one could rather drop the last segment if it ends where the first one starts, and keep the Z segment. But I don’t know how hard this would be to implement.

> I have worked out a modified version of scour that no longer drops the closepath commands. I have checked this in as revision 105. Can you please test it?

Yes, that revision fixes the problem for the attached file. Thanks a lot!

Cheers,
Frederik

Revision history for this message
codedread (codedread) wrote :

Fix checked in with revision 105

Changed in scour:
status: In Progress → Fix Committed
Revision history for this message
codedread (codedread) wrote :

Actually this was my fault. Removing Z segments have no effect on the fill but they DO have an effect on the stroke. I have added a unit test for this and release Scour 0.15 with this change.

Thanks a lot Frederick!

By the way, what is 'R' that you mention above?

Revision history for this message
codedread (codedread) wrote :

Ok, found it! http://www.r-project.org/

Talk about a hard thing to find using Google! :)

Changed in scour:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.