GNOME Bugzilla – Bug 482648
Number parsing bug in CSS in SVG file, inline style is ok!
Last modified: 2007-11-19 17:57:44 UTC
Please describe the problem: Hi folks, I'm using the rsvg command line tool to convert an svg file to a png file. I'm using 2.16.1. I can't use 2.18 unfortunately. I looked through the bug reports but didn't see anything that matched. The problem was Firefox/Opera were rendering the file correctly, but the png file was blank. It took quite a while to isolate the bug... here it is: If a stroke-width is between 0.0 and 1.0, AND the number of digits is "a lot", ONLY the CSS parses it as 0, while an inline style this is ok. Steps to reproduce: Sample file: <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="600px" height="600px" version="1.1" xmlns="http://www.w3.org/2000/svg"> <desc>The 3rd square should be the same as the 4th</desc> <defs> <style type="text/css"><![CDATA[ .outline1 { fill: none; stroke: black; stroke-width: 1.0666666666666666666666; } .outline2 { fill: none; stroke: black; stroke-width: 0.0666666666666666666666; } .outline3 { fill: none; stroke: black; stroke-width: 0.06666667; } ]]></style> </defs> <g> <rect x="0" y="0" width="100" height="100" class="outline1" /> <rect x="105" y="0" width="100" height="100" style="fill:none; stroke:black; stroke-width:1.0666666666666666666666" /> <rect x="0" y="105" width="100" height="100" class="outline2" /> <rect x="105" y="105" width="100" height="100" style="fill:none; stroke:black; stroke-width:0.0666666666666666666666" /> <rect x="0" y="210" width="100" height="100" class="outline3" /> <rect x="105" y="210" width="100" height="100" style="fill:none; stroke:black; stroke-width:0.06666667" /> </g> </svg> save a junk.svg View in Firefox or Opera You should see 6 boxes 1 2 3 4 5 6 Notice that 1/2, 3/4, 5/6 are only different in that one uses CSS and one uses inline style, and that 1/2, 3/4 5/6 are the same Now do rsvg -f png junk.svg junk.png and view the junk.png image. Box 3 is different (missing). But the only difference between 3 and 5 is number of digits in the stroke-width! It appears to be parsing to 0. Nutty! Actual results: Expected results: Does this happen every time? yes Other information: Work around is pretty simple: limit floating point numbers to "less" significant digits. I discovered this by using python str(anumber) to generate a svg file. thanks!
(In reply to comment #0) > Please describe the problem: > Hi folks, I'm using the rsvg command line tool to convert an svg file to a png > file. I'm using 2.16.1. I can't use 2.18 unfortunately. I looked through the > bug reports but didn't see anything that matched. > > The problem was Firefox/Opera were rendering the file correctly, but the png > file was blank. It took quite a while to isolate the bug... here it is: > > If a stroke-width is between 0.0 and 1.0, AND the number of digits is "a lot", > ONLY the CSS parses it as 0, while an inline style this is ok. > > > > > Steps to reproduce: > Sample file: > > <?xml version="1.0" standalone="no"?> > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" > "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> > <svg width="600px" height="600px" version="1.1" > xmlns="http://www.w3.org/2000/svg"> > <desc>The 3rd square should be the same as the 4th</desc> > <defs> > <style type="text/css"><![CDATA[ > .outline1 { fill: none; stroke: black; stroke-width: 1.0666666666666666666666; > } > .outline2 { fill: none; stroke: black; stroke-width: 0.0666666666666666666666; > } > .outline3 { fill: none; stroke: black; stroke-width: 0.06666667; } > ]]></style> > </defs> > <g> > > <rect x="0" y="0" width="100" height="100" class="outline1" /> > <rect x="105" y="0" width="100" height="100" style="fill:none; > stroke:black; stroke-width:1.0666666666666666666666" /> > <rect x="0" y="105" width="100" height="100" class="outline2" /> > <rect x="105" y="105" width="100" height="100" style="fill:none; > stroke:black; stroke-width:0.0666666666666666666666" /> > <rect x="0" y="210" width="100" height="100" class="outline3" /> > <rect x="105" y="210" width="100" height="100" style="fill:none; > stroke:black; stroke-width:0.06666667" /> > </g> > </svg> > > save a junk.svg > View in Firefox or Opera > You should see 6 boxes > 1 2 > 3 4 > 5 6 > > Notice that 1/2, 3/4, 5/6 are only different in that one uses CSS and one uses > inline style, and that 1/2, 3/4 5/6 are the same > > Now do > > rsvg -f png junk.svg junk.png > > and view the junk.png image. > > Box 3 is different (missing). But the only difference between 3 and 5 is > number of digits in the stroke-width! It appears to be parsing to 0. > > Nutty! > > > > Actual results: > > > Expected results: > > > Does this happen every time? > yes > > Other information: > Work around is pretty simple: limit floating point numbers to "less" > significant digits. I discovered this by using python str(anumber) to generate > a svg file. > > > thanks! >
I finally got my system updated. Confirmed in 2.18. I just found out about libcroco, I'm using version 0.6.1. thanks
confirmed that the problem is libcroco see bug 498240
Marking as a duplicate of 498240 *** This bug has been marked as a duplicate of 498240 ***