[R] Symbol Font Baseline, Cairo, Card Symbols

ivo welch ivo.welch at gmail.com
Wed Aug 17 02:46:17 CEST 2011


I think I found a bug in the Cairo library, plus weird behavior in
both the Cairo and the normal pdf device.  The baseline of the spades
symbol seems to be off.  This is easier to show than it is to explain.
 The problem does not appear in the normal pdf device, which is why I
am guessing this is a Cairo bug.  moreover, I cannot figure out why
three of the card symbols seem to be transparent, but the fourth is
not.  this is the case for both the Cairo and the ordinary pdf
devices.

I thought I would report it to the R wizards on this group...

library(Cairo)

clubs <- expression(symbol('\247'))
hearts <- expression(symbol('\250'))
diamonds <- expression(symbol('\251'))
spades <- expression(symbol('\252'))
csymbols <- c(clubs, diamonds, hearts, spades)

CairoPDF(file = "cardsymbols.pdf")

plot( 0, xlim=c(0,5), ylim=c(0,2), type="n" )
clr <- c("black", "red", "red", "black")
for (i in 1:4) {
  hline <- function( yloc, ... ) for (i in 1:length(yloc)) lines(
c(-1,6), c(yloc[i],yloc[i]), col="gray")
  hline(0.9);  hline(1.0);   hline(1.1);   hline(1.2)
  text( i, 1, csymbols[i], col=clr[i], cex=5 )
  text( i, 0.5, csymbols[i], col=clr[i] )
}

dev.off()



----
Ivo Welch (ivo.welch at gmail.com)



More information about the R-help mailing list