Register a font from 'Google Fonts' so that it can be used with devices using the 'systemfonts' package, i.e. the 'flextable' package and graphic outputs generated with the 'ragg', 'svglite' and 'ggiraph' packages.
Usage
register_gfont(family = "Open Sans", subset = c("latin", "latin-ext"))
Arguments
- family
family name of a 'Google Fonts', for example, "Open Sans", "Roboto", "Fira Code" or "Fira Sans Condensed". Complete list is available with the following command:
- subset
font subset, a character vector, it defaults to only "latin" and "latin-ext" and can contains values such as "greek", "emoji", "chinese-traditional",
Run the following code to get a complete list:
Details
It allows users to use fonts from 'Google Fonts' in an HTML page generated by 'shiny' or 'R Markdown'.
At the first request, the font files will be downloaded and stored in a cache on the
user's machine, thus avoiding many useless downloads or allowing to work with
these fonts afterwards without an Internet connection, in a docker image for example.
See fonts_cache_dir()
.
The server delivering the font files should not be too busy. That's
why a one second pause is added after each download to respect the server's
limits. This time can be set with the option GFONTS_DOWNLOAD_SLEEPTIME
which
must be a number of seconds.
See also
Other functions for font management:
addGFontHtmlDependency()
,
fonts_cache_dir()
,
gfontHtmlDependency()
,
install_gfont_script()
,
installed_gfonts()
,
liberationsansHtmlDependency()
,
register_liberationsans()
Examples
if (FALSE) { # \dontrun{
if (check_gfonts()) {
dummy_setup()
register_gfont(family = "Roboto")
}
} # }