[R] simple pdf font embedding example for Bera

ivo welch ivo.welch at anderson.ucla.edu
Fri Feb 8 19:15:46 CET 2013


I wanted to put a short example into the r-help archives how to embed
the Bera (texlive) font.

options(texlive= "/usr/local/texlive/2012/")
options(texfonts= paste0(getOption("texlive"), "/texmf-dist/fonts/"))
library(grDevices)
pdfFonts(Bera = Type1Font("Bera", paste0(getOption("texfonts"),
"afm/public/bera/", c("fvsr8a","fvsb8a","fvsro8a","fvsbo8a"),
".afm")))
options(pfbdir = c(paste0(getOption("texfonts"), "type1/public/bera/")))

and now

pdf(file="test.pdf", family="Bera")
plot(1:10, 1:10)
dev.off()
embedFonts( file= "test.pdf", fontpaths = getOption("pfbdir") )

it would be more elegant if pdf() could take fontpaths that the
subsequent embedFonts needs and the dev.off would execute embedFonts
automatically on dev.off; and/or if pdfFonts could take an optional
.pfbdir that embedFonts would search.  but this is pretty painless
already as is, esp to how it was 5 years ago.  thanks to all the folks
that put in the hard work to make this possible.

[PS: The above may be incorrect in terms of encoding, dingbats
(symbols), or other issues.  I just checked that the basics worked.]

regards,

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



More information about the R-help mailing list