Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

match_font

Find a system font by name and style


Description

This function locates the font file (and index) best matching a name and optional style (italic/bold). A font file will be returned even if a match isn't found, but it is not necessarily similar to the requested family and it should not be relied on for font substitution. The aliases "sans", "serif", and "mono" match to the system default sans-serif, serif, and mono fonts respectively ("" is equivalent to "sans").

Usage

match_font(family, italic = FALSE, bold = FALSE)

Arguments

family

The name of the font family

italic, bold

logicals indicating the font style

Value

A list containing the path locating the font file and the 0-based index of the font in the file.

Examples

# Get the system default sans-serif font in italic
match_font('sans', italic = TRUE)

systemfonts

System Native Font Finding

v1.0.2
MIT + file LICENSE
Authors
Thomas Lin Pedersen [aut, cre] (<https://orcid.org/0000-0002-5147-4711>), Jeroen Ooms [aut] (<https://orcid.org/0000-0002-4035-0289>), Devon Govett [aut] (Author of font-manager), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.