i use non-standard fonts in ggplot2 chart embed in rmarkdown document, knitted pdf. current workflow specify font in chart, knit, run extrafonts::embed_fonts on created pdf. question is: can specify directly in rmarkdown document fonts should embedded in outputted pdf?
minimal example:
--- title: "untitled" output: beamer_presentation --- ```{r} library(extrafont) library(ggplot2) loadfonts() qplot(iris$sepal.length) + theme_light(base_family = "cm roman") ``` knitr::knit2pdf("test.rmd") embed_fonts("test.pdf")
if set graphics device "cairo_pdf" fonts embedded. can individual chunks or whole document using knitr::opts_chunk$set
i used different font below clear fonts being set.
the package called "extrafont" not "extrafonts"
--- title: "untitled" output: beamer_presentation --- ```{r, echo=false, message = false} knitr::opts_chunk$set(warning=false, message=false, echo = false, dev = "cairo_pdf") ``` ```{r} library(extrafont) library(ggplot2) loadfonts() ``` ## ```{r, fig.width = 5} qplot(iris$sepal.length) + theme_light(base_family = "vladimir script") ```
Comments
Post a Comment