There is an issue with the default svg device on a centos workstation that I am using. It does not result in an error, but it produces malformed svg images. Exactly the same script works just fine on an ubuntu box. On Ubuntu I am using R binary that comes with maverick, on centos I am using the latest R binary from EPEL. Other than that both boxes are pretty clean, with only the dependencies installed that are automatically installed when installing R. For example a testscript like this svg("plot.svg"); plot(cars); dev.off(); should produce this: http://www.stat.ucla.edu/~jeroen/files/plot_good.svg (ubuntu), but on centos it produces this: http://www.stat.ucla.edu/~jeroen/files/plot_bad.svg. It looks very much as if there is something wrong with the fronts; maybe I am missing some library. However, as this is a production server, I don't want to go install random packages to see if this fixes the problem. Some questions: - How could I fix it? - Why is R not throwing an error instead of producing a malformed plot? - Maybe we could notify the R binary maintainers from fedora to add a formal dependency so that it works 'out of the box'? Jeroen -- View this message in context: http://r.789695.n4.nabble.com/svg-malformed-on-CentOS-epel-R-tp3352949p3352949.html Sent from the R help mailing list archive at Nabble.com.
Hi On 14/03/2011 2:30 p.m., Jeroen Ooms wrote:> There is an issue with the default svg device on a centos workstation that I > am using. It does not result in an error, but it produces malformed svg > images. Exactly the same script works just fine on an ubuntu box. On Ubuntu > I am using R binary that comes with maverick, on centos I am using the > latest R binary from EPEL. Other than that both boxes are pretty clean, with > only the dependencies installed that are automatically installed when > installing R. > > For example a testscript like this > svg("plot.svg"); > plot(cars); > dev.off(); > > should produce this: http://www.stat.ucla.edu/~jeroen/files/plot_good.svg > (ubuntu), but on centos it produces this: > http://www.stat.ucla.edu/~jeroen/files/plot_bad.svg. > > It looks very much as if there is something wrong with the fronts; maybe I > am missing some library. However, as this is a production server, I don't > want to go install random packages to see if this fixes the problem. > > Some questions: > > - How could I fix it? > - Why is R not throwing an error instead of producing a malformed plot? > - Maybe we could notify the R binary maintainers from fedora to add a formal > dependency so that it works 'out of the box'?Looking at the raw SVG, the letter glyphs are all defined at the top and one difference between the files is the presence of the 'overflow' attribute in plot_good.svg. You can manually edit the file to add this attribute to plot_bad.svg and the text becomes visible. So this is a clipping problem within the SVG that is being generated. My guess is that this is due to a difference in version of the Cairo library, but that's without looking very deeply into the probem. However, this does suggest that there is a simple text-processing, search-and-replace workaround if you are able/prepared to post-process the SVG (or you could post-process it "properly" with the 'XML' package). Paul> Jeroen > > -- > View this message in context: http://r.789695.n4.nabble.com/svg-malformed-on-CentOS-epel-R-tp3352949p3352949.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
The problem has been resolved thanks to Tom Callaway from Redhat: Tom Callaway wrote:> > Looking at the R source code, it uses Cairo to do the SVG creation, and > the Cairo in RHEL-5 is very (very) old (1.2.4). > > Digging through Cairo's changelogs post 1.2.4, I came across this: > > "SVG: Fix bug preventing text from appearing in many viewers" > > http://cairographics.org/news/cairo-1.4.0/ > > Sure enough, I dug out an old cairo 1.4 series package from Fedora 7 > (1.4.4, to be specific), rebuilt it on RHEL-5 and it generates a "good" > svg that views properly in Firefox. > > Looking at the code to see how they fixed that bug, it is pretty much > what I suspected, they add the overflow="visible" field when outputting > the glyphs. This was trivial to backport and the patch is attached. > > In addition, since I had to make the packages to test, I have uploaded > them here: > > http://spot.fedorapeople.org/cairo-invisible-text-fix-el5/ > > Last but not least, I have opened a bug against RHEL 5 on this issue. I > do not know if they will push a cairo update for this, but at least, it > is now on their radar: > > https://bugzilla.redhat.com/show_bug.cgi?id=691844 >So to fix the problem, grab the updated Cairo binary from the link he gives and do a: rpm -Uvh cairo-1.2.4-5.spot.i386.rpm -- View this message in context: http://r.789695.n4.nabble.com/svg-malformed-on-CentOS-epel-R-tp3352949p3420081.html Sent from the R help mailing list archive at Nabble.com.