Title: | Tools for Using Fonts |
---|---|
Description: | Tools to using fonts other than the standard PostScript fonts. This package makes it easy to use system TrueType fonts and with PDF or PostScript output files, and with bitmap output files in Windows. extrafont can also be used with fonts packaged specifically to be used with, such as the fontcm package, which has Computer Modern PostScript fonts with math symbols. |
Authors: | Winston Chang <[email protected]> |
Maintainer: | Winston Chang <[email protected]> |
License: | GPL-2 |
Version: | 0.19 |
Built: | 2024-12-08 02:59:24 UTC |
Source: | https://github.com/wch/extrafont |
For a sequence of font family names, return the first one installed on the system. This makes it easy for code to specify a preferred font-family, but fall back to other font families if that is not installed on the system. This function acts much like the CSS font-family property.
choose_font(fonts, quiet = TRUE)
choose_font(fonts, quiet = TRUE)
fonts |
|
quiet |
|
character
. First font in fonts
that is installed
on the system or ""
if none of those are installed.
choose_font(c("GillSans", "Verdana", "sans"), quiet = TRUE) choose_font(c("BemeboStd", "Garamond", "serif"), quiet = TRUE)
choose_font(c("GillSans", "Verdana", "sans"), quiet = TRUE) choose_font(c("BemeboStd", "Garamond", "serif"), quiet = TRUE)
Embeds fonts that are listed in the local Fontmap
embed_fonts(file, format, outfile = file, options = "")
embed_fonts(file, format, outfile = file, options = "")
file |
Name of input file. |
format |
File format. (see |
outfile |
Name of the output file (with fonts embedded). (Default is same as input file) |
options |
Other arguments passed to |
## Not run: loadfonts() pdf('fonttest.pdf') library(ggplot2) p <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() # Run only the code below that is appropriate for your system # On Mac and Windows, Impact should be available p + opts(axis.title.x=theme_text(size=16, family="Impact", colour="red")) # On Linux, Purisa may be available p + opts(axis.title.x=theme_text(size=16, family="Purisa", colour="red")) dev.off() embed_fonts('fonttest.pdf', outfile='fonttest-embed.pdf') ## End(Not run)
## Not run: loadfonts() pdf('fonttest.pdf') library(ggplot2) p <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point() # Run only the code below that is appropriate for your system # On Mac and Windows, Impact should be available p + opts(axis.title.x=theme_text(size=16, family="Impact", colour="red")) # On Linux, Purisa may be available p + opts(axis.title.x=theme_text(size=16, family="Purisa", colour="red")) dev.off() embed_fonts('fonttest.pdf', outfile='fonttest-embed.pdf') ## End(Not run)
This package is used for using and embedding fonts other than the basic Postscript fonts.
For use instructions, see https://github.com/wch/extrafont.
This is usually not called directly, but via font_install
.
font_addpackage(pkg = NULL)
font_addpackage(pkg = NULL)
pkg |
The name of the font package, e.g., |
Presently only supports TrueType fonts.
font_import(paths = NULL, recursive = TRUE, prompt = TRUE, pattern = NULL)
font_import(paths = NULL, recursive = TRUE, prompt = TRUE, pattern = NULL)
paths |
A vector of directories to search in. (Default is to auto-detect based on OS) |
recursive |
Search recursively in directories? (Default TRUE) |
prompt |
Show confirmation prompt? (Default TRUE) |
pattern |
A regular expression that the filenames must match. |
font_import()
font_import()
If the font package specified by fontpkg
is not already installed,
it will be downloaded from CRAN. The font package will then be registered
in the fonts database.
font_install(fontpkg = NULL, prompt = TRUE)
font_install(fontpkg = NULL, prompt = TRUE)
fontpkg |
The name of an R package containing a font, e.g., |
prompt |
Ask user to install font from CRAN if not already installed |
## Not run: font_install('fontcm') ## End(Not run)
## Not run: font_install('fontcm') ## End(Not run)
Show the fonts that are registered in the font table (and available for embedding)
fonts()
fonts()
This registers fonts so that they can be used with the pdf, postscript, or Windows bitmap output device. It must be run once in each R session.
loadfonts(device = c("all", "pdf", "postscript", "win"), quiet = FALSE)
loadfonts(device = c("all", "pdf", "postscript", "win"), quiet = FALSE)
device |
The output device. If |
quiet |
If |
A named list with up to three elements, one for each device for which
fonts were loaded. Each device element is a named list, with an element for
each family that was the function attempted to register with that device.
The value is NULL
if the function did not register the font family
due to problems or because the font family was already registered. If value
is the return value of windowsFonts
for "win"
,
postscriptFonts
for "postscript"
, and
pdfFonts
for "pdf"
.
embed_fonts
, #ifdef windows
windowsFont
, windowsFonts
,
#endif postscriptFonts
, pdfFonts
,
Type1Font
.
Imports all TrueType fonts in a directory and all subdirectories
ttf_import(paths = NULL, recursive = TRUE, pattern = NULL)
ttf_import(paths = NULL, recursive = TRUE, pattern = NULL)
paths |
A vector of directories to search in. (Default is to auto-detect based on OS) |
recursive |
Search recursively in directories? (Default TRUE) |
pattern |
A regular expression that the filenames must match. |