[cairo] Fwd: cairo path rendering bug with inkscape
Hakki Dogusan
dogusanh at tr.net
Sat Apr 5 07:10:20 PDT 2008
Hi,
Carl Worth wrote:
> 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.
>
(I know, It is not exactly what you want, but..) I started to write a
SVG importer for CairoPad. It's not usable yet (and due to boring daily
work, I can't work on it now). I'm waiting Cairo's release to release it
-as it is-. It translates SVG to Lua code. Generator is not finished
yet; it'll translate path data to something readable. My aim is "import
svg file, modify/play on it with cairo code, then save as svg, png,
etc.". For now generated code for cairobug.svg is as follows:
<Lua code>
local cr,svg = ...; -- Paint context, svg exec
--[[----------------------------------------------------------------------]]--
--[[ Generated from /home/hd/Masaüstü/cairobug.svg ]]--
--[[----------------------------------------------------------------------]]--
local doc = {}
doc["svg_svg3754"] = function(args)
svg:svg_start(args)
doc["defs_defs3756"] = function(args)
svg:defs_start(args)
svg:defs_end(args)
end
doc["defs_defs3756"]({ stdAttrs={id=[[defs3756]]} })
svg:metadata{stdAttrs={id=[[metadata3759]]}}
svg:text{}
doc["g_layer1"] = function(args)
svg:g_start(args)
doc["g_inkscape_logo"] = function(args)
svg:g_start(args)
svg:path{stdAttrs={id=[[path39145]]}, d=[[M 163.15,27.83 L
28.81,165.3 C -16.58,221.51 59.7,214.97 92.4,231.16 C 104.13,243.15
47.44,252 59.17,264 C 70.9,275.99 130.1,287.1 141.85,299.09 C
153.58,311.08 117.84,323.8 129.57,335.79 C 141.3,347.78 168.43,336.42
173.51,364.1 C 177.13,383.88 222.4,372.6 244.54,356.4 C 256.27,344.4
222.1,345.53 233.83,333.54 C 263,303.71 290.16,322.7 300.14,292.81 C
305.07,278.04 257.2,270.04 268.95,258.05 C 302.7,238.34 419.35,225.51
364,170.16 L 224.75,27.83 C 207.72,11.48 179.3,11.3 163.15,27.83 z M
317.46,292.81 C 317.46,299.63 367.71,304.1 367.71,291.2 C 360.55,270.48
323.4,271.88 317.46,292.81 z M 91.1,329.05 C 103,339.34 121.38,326.49
126.89,312.13 C 115.36,296.81 72.2,312.68 91.1,329.05 z M 311.16,306.82
C 295.82,320.58 312.88,334.54 328,325.65 C 331.37,322.23 327.91,310.24
311.16,306.82 z]]}
svg:path{stdAttrs={id=[[path39147]]}, style=[[fill:#ffffff]], d=[[M
131,238.6 C 134.59,240.83 188.89,251.86 202.16,254.06 C 206.76,255.03
203.5,259.77 197.16,262.97 C 182.86,266.77 113.5,238.6 131,238.6 z]]}
svg:path{stdAttrs={id=[[path39149]]}, style=[[fill:#ffffff]], d=[[M
216.63,37.47 L 269.78,91.45 C 274.82,96.6 274.75,106.58 271.93,109.45 L
245.54,88.34 L 240.35,119.6 L 218.3,107.96 L 182.99,130.27 L 171.3,83.24
L 152.33,116.06 L 123.33,116.06 C 111.51,116.06 110.12,101.06
120.86,90.32 C 139.62,70.07 161.15,49.43 172.85,37.47 C 184.61,25.45
205.1,25.79 216.63,37.47 z]]}
svg:g_end(args)
end
doc["g_inkscape_logo"]({ stdAttrs={id=[[inkscape-logo]]},
style=[[display:inline]],
transform=[[matrix(0.38425,0,0,0.38425,272.983,354.5516)]] })
svg:g_end(args)
end
doc["g_layer1"]({ stdAttrs={id=[[layer1]]} })
svg:svg_end(args)
end
doc["svg_svg3754"]({ xmlns=[[http://www.w3.org/2000/svg]],
stdAttrs={id=[[svg3754]]}, width=[[744.09448819]],
height=[[1052.3622047]] })
</Lua code>
> [3] The buggy results expressed in C:
> [snipped]
>
> [4] The buggy results expressed in SVG:
> [snipped]
>
--
Regards,
Hakki Dogusan
More information about the cairo
mailing list