I think I've found the appropriate function to alter the theme in the
"Polishing" chapter, ie theme_text
p + opts(axis.text.y = theme_text(family="ComputerModern"))
but there are three questions (that doesn't work):
Firstly, what does the "family" parameter want? I've looked at how it
works in Grid but I'm a bit confused about that. I tried use the
Type1Font command, pointing to the relevant files, but AFAIK
ComputerModern should already be defined. But ggplot2 definitely
doesn't like that. Can one only use the Adobe files?
Secondly, is there a way to change the font family for the whole theme
(akin to base_size?) or does one have to change all the textual
elements separately? That would be pretty awesome.
Finally, is there a way to get ggplot2 to embed the relevant fonts (if
not I think I'll just use a raster format, like PNG)
FWIW, I've had good success at getting the font size right by using
base_size and specifying the actual width and height that I want the
final graphic.
I know that fonts are a pain in the arse, so hope I haven't opened a
can of worms here.
Thanks,
James
Family wants what grid wants (for the font family parameter), and
that's described in:
Paul Murrell and Brian Ripley. Non-standard fonts in PostScript and
PDF graphics. R News, 6(2):41-47, May 2006.
http://CRAN.R-project.org/doc/Rnews/Rnews_2006-2.pdf
The article includes an example of computer modern, and embedding the
fonts in the output pdf.
> Secondly, is there a way to change the font family for the whole theme
> (akin to base_size?) or does one have to change all the textual
> elements separately? That would be pretty awesome.
Unfortunately, you have to change them all separately. I'd suggest
you take a look at the code in theme_grey and modify it yourself -
I'll do the same for a future version of ggplot2.
Regards,
Hadley
Great! And thanks for writing your process up - I'm sure it will be
helpful for others in the future.
>
> Error in grid.Call("L_textBounds", as.graphicsAnnot(x$label), x$x, x
> $y, :
> Polygon edge not found
> In addition: Warning messages:
I think you're correct in your diagnosis of this problem - the quartz
fonts and pdf fonts are quite independent.