font_install {showtextdb} | R Documentation |
font_install()
saves the specified font to the ‘fonts’ directory of
the showtextdb package, so that it can be used by the showtext
package. This function requires the curl package.
font_installed()
lists fonts that have been installed to
showtextdb.
NOTE: Since the fonts are installed locally to the package directory, they will be removed every time the showtextdb package is upgraded or re-installed.
font_install(font_desc, quiet = FALSE, ...) font_installed()
font_desc |
A list that provides necessary information of the font for installation. See the Details section. |
quiet |
Whether to show the progress of downloading and installation. |
... |
Other parameters passed to |
font_desc
is a list that should contain at least the following components:
showtext_name
The family name of the font that will be used in showtext.
font_ext
Extension name of the font files, e.g., ttf
for
TrueType, and otf
for OpenType.
regular_url
URL of the font file for "regular" font face.
Optionally, font_desc
can also contain bold_url
, italic_url
,
bolditalic_url
, and symbol_url
that provide the URLs of the other
font faces.
See source_han_sans()
and source_han_serif()
for an example of the font_desc
parameter.
Yixuan Qiu <https://statr.me/>
## Not run: ## Install Source Han Serif Simplified Chinese font_install(source_han_serif()) ## List available font families sysfonts::font_families() ## Use the font with the "showtext" package if(require(showtext)) { wd = setwd(tempdir()) showtext.auto() pdf("source-han-serif.pdf") par(family = "source-han-serif-cn") plot.new() box() text(0.5, 0.9, "\u601d\u6e90\u5b8b\u4f53", cex = 3, font = 2) text(0.5, 0.4, "\u843d\u5176\u5b9e\u8005\u601d\u5176\u6811", cex = 3) text(0.5, 0.2, "\u996e\u5176\u6d41\u8005\u6000\u5176\u6e90", cex = 3) dev.off() setwd(wd) } ## End(Not run)