I am working on a ggplot2 extension package for my organization to use, to apply our design guidelines to all of our R charts. Part of this requires the use of specific fonts. We use the Whitney typeface on our published visualizations, but not all users have the required fonts installed on their computers. I would like the package to check whether Whitney is installed and, if not, specify an alternate, widely-available font (e.g. Calibri) to use as a backup.
The following code will run successfully, without warnings, regardless of whether "Whitney Medium" is actual installed on the PC. If it is not installed, the plotted text will display in Arial.
grDevices::windowsFonts(font_reg = "Whitney Medium")
graphics::plot(c(0,2), c(0,2), type="n", xlab="", ylab="")
graphics::par(family="font_reg")
graphics::text(1, 1, "font_reg", cex=4)
How can I verify that "Whitney Medium" is a valid font on a given PC, and specify a backup if it's not?
Note: Our Whitney font files are OTF, not TTF, so I can't use the extrafont package. I also would like to avoid using showtext because I really want to find a solution that works in the RStudio plotting window.