From fd035dfba5e8082e85893a5328b408cc8ecc5c5f Mon Sep 17 00:00:00 2001 From: Chuanxin Date: Wed, 30 Dec 2015 22:15:39 +1100 Subject: [PATCH] Update README.md using cairo_pdf() function to generate pdf files won't make any warnings compared to ggsave() function. --- README.md | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 0e21064..cb06b7a 100644 --- a/README.md +++ b/README.md @@ -111,16 +111,18 @@ dev.off() library(ggplot2) +library(Cairo) p <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() + ggtitle("Fuel Efficiency of 32 Cars") + xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") + theme(text=element_text(size=16, family="Impact")) -ggsave("font_ggplot.pdf", plot=p, width=4, height=4) +cairo_pdf("font_ggplot.pdf", width=4, height=4) +p +dev.off() ``` -The first time you use a font, it may throw some warnings about unknown characters. -This should be harmless, but if it causes any problems, please report them. +Just test it on windows. Using cairo_pdf won't incur any warnings and the pdf file could be created properly, therefore you don't need to take the following steps to emb the fonts. ## Embed the fonts @@ -132,13 +134,6 @@ All other fonts should be embedded into the PDF files. First, if you are running Windows, you may need to tell it where the Ghostscript program is, for embedding fonts. (See Windows installation notes below.) -```R -# Needed only on Windows - run once per R session -# Adjust the path to match your installation of Ghostscript -Sys.setenv(R_GSCMD = "C:/Program Files/gs/gs9.05/bin/gswin32c.exe") -``` - - As the name suggests, `embed_fonts()` will embed the fonts: ```R @@ -199,22 +194,10 @@ The source code for the utility program `ttf2pt1` is in the package Rttf2pt1. CRAN has pre-compiled Windows and Mac OS X binaries. For other platforms, and when installing from source, it will be compiled on installation, so you need a build environment on your system. - -## Windows installation notes - -In Windows, you need to make sure that Ghostscript is installed. - -In each R session where you embed fonts, you will need to tell R where Ghostscript is installed. -For example, when Ghostscript 9.05 is installed to the default location, running this command will do it (adjust the path for your installation): - -```R -Sys.setenv(R_GSCMD="C:/Program Files/gs/gs9.05/bin/gswin32c.exe") -``` - ## Resetting the font database To reset the extrafont database, reinstall the extrafontdb package: ```R install.packages("extrafontdb") -``` \ No newline at end of file +```