0

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'.

stevec
  • 41,291
  • 27
  • 223
  • 311
  • 2
    I don't know of any other font importing package, but I think `extrafont` is already pretty good ... You could write your own function, wrapping all the extrafont steps together!! – tjebo Mar 29 '20 at 10:12
  • 2
    @stevec: check out [`showtext`](https://stackoverflow.com/a/51906008/786542). It might have the function you need – Tung Mar 29 '20 at 13:55

0 Answers0