Two problems with the recent use of R drawing
1. Use a different font
2. Save plot to PDF when font is embedded in PDF (embed the font)
These two problems can be solved by using Extrafont and Ghostscript.
1. Ghostscript
Installation: http://www.ghostscript.com/download/gsdnld.html
2. Extrafont (R package)
The following commands are executed in R
-Installation
> install.packages ("Extrafont") > Library (extrafont) > #这一步定位系统字体. C:\windows\fonts\*.ttf, for example, takes a few minutes > Font_import () > Loadfonts ()
-Using
> #查看可用的font family> fonts ()
> Library (GGPLOT2) > #使用字体Times New Roman drawing > P <-ggplot (Mtcars, AES (X=WT, Y=mpg)) + geom_point () + Xlab ("W Eight ") + Ylab (" Miles per gallon ") + Theme (Text=element_text (family=" Times New Roman ") > #保存pdf > Ggsave (" Font _ggplot.pdf ", plot=p)
-Embed fonts into PDF
> #指定ghostscript的路径 > sys.setenv (r_gscmd = "C:/Program Files/gs/gs9.05/bin/gswin32c.exe") > #嵌入字体 > Embed_ Fonts ("Font_ggplot.pdf", outfile= "Font_ggplot_embed.pdf")
The font_ggplot_embed.pdf you get is the PDF you need!
Ability to see if a font is embedded by using Fonts, Properties, Adobe Reader, File-
(The above content is from http://cran.r-project.org/web/packages/extrafont/README.html)
Bonus: Embed fonts directly into PDF using Ghostscript command line
(Execute in cmd, don't forget to add ghostscript environment variable)
Gswin32c-sfontpath=c:\windows\fonts-sdevice=pdfwrite-dembedallfonts=true-o output.pdf Input.pdf
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
R-Change plot glyphs, embed fonts in PDF