[R] font (charter)

ivo welch ivo.welch at gmail.com
Thu Aug 11 05:52:26 CEST 2011


this may help others.  among the set of font resources are the following:

http://yihui.name/en/2010/03/font-families-for-the-r-pdf-device/
http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/postscriptFonts.html
http://stat.ethz.ch/R-manual/R-patched/library/grDevices/html/embedFonts.html
http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html
http://r.789695.n4.nabble.com/Truetype-and-Opentype-font-in-pdf-device-td3218964.html

I don't think there is a complete font installation guide for R
anywhere yet.  (I may be wrong.)


now, for me, the following worked on OSX, thanks to a website I found
and thanks to Simon U's Cairo library:

[a] use http://www.freefontconverter.com/ to create an opentype font.
(this website is amazing.  I tore my hair out before I discovered it.)

[b] double click on each of the OTF files to install the fonts in OSX.

[c] install from cran Simon Urbanek's Cairo package

   > install.packages("Cairo")

[d] load Cairo

   > library(Cairo)

[e] make sure it can find my new font

    > CairoFontMatch(fontpattern="Bitstream Charter",sort=FALSE,verbose=FALSE)
1. family: "Bitstream Charter", style: "Roman", file:
"/Users/iaw4/Library/Fonts/bchr8a.otf"

[f] set it to be the default font

    > CairoFonts( regular="Bitstream Charter:style=Regular" )
you may also want to set the other four R fonts, as described in the docs.

[g] create a sample file,

> CairoPDF(file="testcharter.pdf")
> plot( c(0,1), c(0,1) )
> text( 0.5, 0.5, "This is Bitstream Charter")
> dev.off

[h] use Adobe Acrobat -> File -> Properties to confirm that your new
font is really Bitstream Charter.

/iaw

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



More information about the R-help mailing list