R package extrafont::font_import() not finishing

500 views Asked by At

As I was writing up this question, I tricked myself into finding the (now fairly obvious) solution. However, since it caused me a lot of confusion, I figured I would leave this up to save other people time. I can't write my own answer, so if someone else wants to answer it I will mark it. And no hard feelings if someone wants to mark this as obvious/duplicate/not a question. Basically, I "couldn't" see the y/n prompt because I wasn't looking at the console (I was doing this in R Notebook for no particular reason), and the function was endlessly waiting for me to respond. After I figured this out, font_import() finished after 5 minutes. Hope this is helpful to someone.

Here is my question:

I'm trying to set up the extrafont package in R so I can use Times New Roman in ggplot. I am using this as a reference: How to change font of ggplot into Times New Roman (on OS X)? Here is what I have tried:

library()
#font_import()
#font_import(pattern = "TIMES")
font_import(paths="C:\\Windows\\Fonts")

I let the first one run for 5 hours last night, and I tried the other ones this morning to maybe keep it from doing unnecessary work. None of them finished. However, I think something is going wrong for two reasons: 1) I don't get the prompt shown here: https://rdrr.io/cran/extrafont/man/font_import.html, and 2) my CPU and RAM utilization don't indicate that my computer is actually working on anything that should take some time.

2

There are 2 answers

0
slamballais On BEST ANSWER

The font_import function gives a prompt on the console that needs to be answered with y or n. Hence, it was waiting for a response, and nothing happened.

(Posting answer since OP cannot post themselves.)

0
Ioana Preoteasa On

FYI, I had a similar issue (newbie to R), until I figured out that there was a prompt in the console.

If you wanna avoid having to wait to answer in the console every time, set

prompt=FALSE

https://www.rdocumentation.org/packages/extrafont/versions/0.18/topics/font_import