There are many tutorials on how to download and install fonts and use them in R (e.g. here, here, here)
There seems to be a high degree of variety in the patterns used in these tutorials and others. Some use external packages, many require the user to open the browser, navigate to a font website, download a font file manually, and figure out where it needs to be placed in order for R to access it.
Question
Is there a single R function that allows you to run code that uses a font you do not yet have installed seamlessly without having to leave R?
Example
A real use case could look like this:
obscure_font <- "Manthul" # From: https://www.download-free-fonts.com/list/m/page-5
download_install_import_font(obscure_font)
qplot(1:10)+theme(text=element_text(family=obscure_font))
# Works immediately
What I know so far
I do not know of any such function, but my guess is that one could exist that
- accepts a font name as an argument
download.file()
for that font from an external website- finds the appropriate location for it based on
Sys.info()$sysname
- does anything else necessary so that the user can immediately use the font (e.g. unzips)
- imports the font into R
The acid test would be that someone could copy your RMarkdown/ggplot code containing an obscure font, and run it on their computer and it would 'just work'.