Skip to contents

Registers a font family for use in ggplot2 plots and updates the default font for text and label geoms. Three font families are bundled with the package for offline use: "Open Sans", "Lato", and "Source Sans 3". Any Google Font can be loaded when an internet connection is available.

Usage

set_fonts(base_family = "Open Sans", font_method = c("showtext", "extrafont"))

Arguments

base_family

Character. Font family name. Default is "Open Sans". Bundled options: "Open Sans", "Lato", "Source Sans 3".

font_method

Character. Rendering backend: "showtext" (default, recommended) or "extrafont" (legacy).

Value

Invisible NULL. Called for its side effects of registering fonts and enabling automatic rendering.

Details

Two rendering backends are supported:

"showtext"

(Default, recommended.) Uses sysfonts and showtext. Bundled fonts are loaded from TTF files in inst/fonts/; other fonts are fetched via font_add_google.

"extrafont"

(Legacy.) Uses the extrafont package. May require font_import on first use.

See also

Examples

if (FALSE) { # \dontrun{
# Use bundled Open Sans (no internet needed)
set_fonts(base_family = "Open Sans")

# Use bundled Lato
set_fonts(base_family = "Lato")

# Use a Google Font (requires internet)
set_fonts(base_family = "Roboto")
} # }