[Rd] cairo is not the default when available

Michael Bell michael.bell at acm.org
Thu May 9 16:12:57 CEST 2013


This question was asked previously here, but not resolved:
http://tolstoy.newcastle.edu.au/R/e15/devel/11/08/0307.html

The upshot is that cairo is not being used as the default when it is
available, even though the documentation says:
Default "cairo" where available and reliable, otherwise "Xlib".

Here is my system information:
% uname -a
Linux anvil 2.6.18-194.11.4.el5 #1 SMP Fri Sep 17 04:57:05 EDT 2010
x86_64 x86_64 x86_64 GNU/Linux

> R.version
               _
platform       x86_64-unknown-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          0.0
year           2013
month          04
day            03
svn rev        62481
language       R
version.string R version 3.0.0 (2013-04-03)
nickname       Masked Marvel

> capabilities("X11");capabilities("cairo");options("bitmapType")
 X11
TRUE
cairo
 TRUE
$bitmapType
[1] "Xlib"

It is clear whether cairo or X11 is being used because cairo does
antialiasing, and X11 does not:
plot(read.table("in.txt"));

Whether cairo is the default is decided in
src/library/grDevices/R/zzz.R in the onLoad function:
 list(bitmapType = if(capabilities("aqua")) "quartz"
 else if(.Call(C_cairoProps, 2L)) "cairo" else "Xlib")
and
if (.Platform$OS.type != "windows" && !.Call(C_cairoProps, 2L))
        X11.options(type = "Xlib")


cairoProps is in src/library/grDevices/src/init.c:
static SEXP cairoProps(SEXP in)
{
    int which = asInteger(in);
    if(which == 1)
    return ScalarLogical(
#ifdef HAVE_WORKING_CAIRO
        1
#else
        0
#endif
        );
    else if(which == 2)
    return ScalarLogical(
#ifdef HAVE_PANGOCAIRO
        1
#else
        0
#endif
        );
    return R_NilValue;
}

I believe this is where the problem comes in. I don't have pangocairo
and cairoProps is being called with 2L instead of 1L. Indeed, if I
change it to 1L and recompile, cairo becomes the default, and
everything runs as expected.

I would like cairo to be checked for rather than pangocairo, but
perhaps there is a good reason how it is being done now. Can this be
changed?

thanks,
michael


--
michael.bell at acm.org



More information about the R-devel mailing list