I am creating some fairly complex charts in R using the Cairo library for anti-aliased graphics under Windows 7. I am using R2.15.1 and cairoDevice version 2.19. I have a problem where font sizes are larger in the Cairo_png() than in simple screen-based Cairo() , and mtext placements are different. To give a simple example:
Code for screen version:
> Cairo(4, 4)
> par(bg = "blue")
> plot.new()
> for (x in 1:30) mtext(format(x), line = -x, outer = TRUE, adj = 0, col = "white")
Result:

Code for png version:
> Cairo_png("test.png", 4, 4)
> par(bg = "red")
> plot.new()
> for (x in 1:30) mtext(format(x), line = -x, outer = TRUE, adj = 0, col = "white")
> dev.off()
Result of png code:

As you can see the font is bigger in the png version, and the mtext placement is wider. Is this a bug or am I doing something wrong?
I should add that Cairo_svg() and Cairo_pdf() behave the same way as Cairo_png(). They all output the same, but inconsistently with the screen-based Cairo().
As we can see in the cairoDevice documentation, there are different default values for the parameter
pointsizein your mentioned functions:Taking the same
pointsizereturns this