[cairo] Fwd: cairo path rendering bug with inkscape

Carl Worth cworth at cworth.org
Sat Apr 5 06:26:30 PDT 2008


On Fri, 04 Apr 2008 22:39:20 -0700, Carl Worth wrote:
> On Fri, 4 Apr 2008 18:38:09 -0400, "bulia byak" wrote:
> >  I installed 1.5.12 today and the zooming bug with outline mode is gone
> >  - thanks!

So I think that improvement is due to the 16.16->24.8 changes. Thanks
again, Vladimir and others!

> >            However, rendering is still not entirely clear. I noticed
> >  these artifacts before but thought they were caused by the same 16.16
> >  issue, but now it's obvious that this is a different problem. Load the
> >  attached file[1] into Inkscape (with cairo 1.5.12) and switch to outline
> >  mode: you'll see a diagonal straight line across the mountain. It only
> >  appears at some zoom levels and in some positions of the path on
> >  screen.

[1] I've posted Bulia's SVG file here:

	http://cairographics.org/~cworth/images/cairobug.svg

It's a nice, small file with inkscape's logo in it.

> Very, very interesting.
...
> Anyway, I can definitely see the bug here, and I'm definitely
> intrigued.
>
> I'll work to extract a minimal test case and then work to fix this as
> quick as I can.

I ran inkscape along with "LD_PRELOAD=/path/to/libcairowrap.so". You
might google for libcairowrap---it's a handy tool, (and something I'd
like to get packaged up at some point[2]).

It was quite easy to see the bug in its output and to trim it down to
a minimal test case. So below[3] is a subset of the cairo calls
exactly as they came out of inkscape, just packaged up into a C
function.

Or, restated in a language you might be more familiar with[4].

I tried to correlate that sequence of drawing commands back to the
original file you sent, and the only thing that looks close is as
follows:

Original svg file:	MLCCCCCCCCCCLCz
What cairo got:		MLCCCMMMMCCCLCz

So Bulia, I'm throwing the ball back into your court. It appears
there's a bug in inkscape that is converting some C path elements into
cairo_move_to instead of cairo_curve_to.

I haven't tried chasing this down into inkscape yet.

-Carl

[2] What I'd really like is a packaged version that just let me do:

	cairo-trace inkscape cairobug.svg

Even better, I'd like to get rid of the noise generated by GTK+ using
cairo, (when I care only about inkscape's use of cairo), so I'd really
want:

	cairo-trace -gtk inkscape cairobug.svg

That should be really trivial to get going I think. Anyone want to
take that up? I suppose I maybe could have pitched "enhance and
package libcairowrap" as a Summer of Code idea.

[3] The buggy results expressed in C:

static void
draw (cairo_t *cr, int width, int height)
{
    cairo_set_source_rgba (cr, 0, 0, 0, 1);
    cairo_set_line_width (cr, 0.5);
    cairo_set_tolerance (cr, 1.25);
    cairo_move_to (cr, 258.278, 72.4098);
    cairo_line_to (cr, 68.3159, 266.798);
    cairo_curve_to (cr, 4.13266, 346.281, 111.996, 337.033, 158.235, 359.927);
    cairo_curve_to (cr, 174.821, 376.881, 94.6595, 389.395, 111.246, 406.364);
    cairo_curve_to (cr, 127.833, 423.318, 211.544, 439.028, 228.159, 455.982);
    cairo_move_to (cr, 210.795, 507.878);
    cairo_move_to (cr, 272.928, 547.909);
    cairo_move_to (cr, 373.367, 537.021);
    cairo_move_to (cr, 358.222, 504.696);
    cairo_curve_to (cr, 399.47, 462.515, 437.875, 489.368, 451.987, 447.102);
    cairo_curve_to (cr, 458.959, 426.217, 391.269, 414.904, 407.883, 397.95);
    cairo_curve_to (cr, 455.607, 370.079, 620.555, 351.937, 542.288, 273.67);
    cairo_line_to (cr, 345.383, 72.4098);
    cairo_curve_to (cr, 321.302, 49.2902, 281.115, 49.0357, 258.278, 72.4098);
    cairo_close_path (cr);
    cairo_stroke (cr);
}

[4] The buggy results expressed in SVG:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Created by hand (cworth at cworth.org) -->
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="512">
  <path d="M 258.278, 72.4098
           L 68.3159, 266.798
           C 4.13266, 346.281, 111.996, 337.033, 158.235, 359.927
           C 174.821, 376.881, 94.6595, 389.395, 111.246, 406.364
           C 127.833, 423.318, 211.544, 439.028, 228.159, 455.982
           M 210.795, 507.878
           M 272.928, 547.909
           M 373.367, 537.021
           M 358.222, 504.696
           C 399.47, 462.515, 437.875, 489.368, 451.987, 447.102
           C 458.959, 426.217, 391.269, 414.904, 407.883, 397.95
           C 455.607, 370.079, 620.555, 351.937, 542.288, 273.67
           L 345.383, 72.4098
           C 321.302, 49.2902, 281.115, 49.0357, 258.278, 72.4098
           z" stroke="black" stroke-width="0.5" fill="none" />
</svg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080405/926026d5/attachment.pgp 


More information about the cairo mailing list