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

font_fallback

Get the fallback font for a given string


Description

A fallback font is a font to use as a substitute if the chosen font does not contain the requested characters. Using font fallbacks means that the user doesn't have to worry about mixing characters from different scripts or mixing text and emojies. Fallback is calculated for the full string and the result is platform specific. If no font covers all the characters in the string an undefined "best match" is returned. The best approach is to figure out which characters are not covered by your chosen font and figure out fallbacks for these, rather than just request a fallback for the full string.

Usage

font_fallback(
  string,
  family = "",
  italic = FALSE,
  bold = FALSE,
  path = NULL,
  index = 0
)

Arguments

string

The strings to find fallbacks for

family

The name of the font family

italic

logicals indicating the font style

bold

logicals indicating the font style

path

path an index of a font file to circumvent lookup based on family and style

index

path an index of a font file to circumvent lookup based on family and style

Value

A data frame with a path and index column giving fallback for the specified string and font combinations

Examples

font_fallback("\U0001f604") # Smile emoji

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.