wch / extrafont

Tools for using fonts in R graphics
315 stars 48 forks source link

"GhostScript was not found" on M1 Big Sur Mac #86

Closed wrmadsen closed 3 years ago

wrmadsen commented 3 years ago

I just switched to an M1, Big Sur Macbook. I need to embed the fonts of a number of pdfs that include plots from ggplot2.

However, when I run the embed_fonts() function, it returns the following error message: GhostScript was not found

With Homebrew, I've installed Ghostscript. I have also reinstalled extrafont and extrafontdb, restarted RStudio, and then run font_import() and loadfonts() again. None of this solves the error message.

Have you experienced this problem? I wonder if it's because of the change to the M1's Apple Silicon?

I have also switched from using bash to zsh in my terminal. Could that have affected this?

A reprex:

> library(ggplot2)
> library(extrafont)
> (plot <- ggplot(cars, aes(x = speed, y = dist)) +
+     geom_point()
+ )
> ggsave("test_plot.pdf", plot)
Saving 5.19 x 6.87 in image
> embed_fonts(file = "test_plot.pdf", outfile = "test_plot_embedded.pdf")
Error in embedFonts(file = file, format = format, outfile = outfile, options = paste(paste("-I",  : 
  GhostScript was not found
wrmadsen commented 3 years ago

Problem arose from installing with homebrew install ghostscript. Though everything seemed fine, that did not work.

It was fixed by installing directly from: https://pages.uoregon.edu/koch/

stephenpg commented 3 years ago

This also worked for me (the direct download) - and embedFonts didn't need telling where to find the GhostScript afterwards. thanks for highlighting the solution. And thanks William for a v cool package.