2

I have the same question as Error using Arial in .eps figure with extrafont package but the answers did not help me: I'm using ggplot2 and cowplot for creating figures. The journal, I want to publish in, wants an eps-file with arial as font. I used library(extrafont) for changing the font and loadfonts(device='postscript'). To save the figure I used ggsave(filename='Fig2DFH.eps') but I get an error:

Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : family 'Arial' not included in postscript() device

According to the link above I tried to solve it with

library(showtext)
font.add('Arial', regular='arial.ttf', bold='arialbd.ttf', italic='ariali.ttf', bolditalic='arialbi.ttf')

Here I get the following error:

Error in .check.font.path(regular, "regular") : 
  font file not found for 'regular' type

I was wondering if I did something wrong or if I have to change something in the names as I'm working with a German PC. The font.path is correct but filenames in C:Windows/Fonts/Arial are in German. I tried to change filenames in the R-command, but it did not work.

Community
  • 1
  • 1
Z.Kipp
  • 63
  • 2
  • 9
  • Do you find the path where the font files are installed in `font.paths()`? –  Jan 29 '16 at 09:36
  • Yes, I checked this:font.paths() [1] "C:\\Windows\\Fonts" – Z.Kipp Jan 29 '16 at 09:50
  • Is the name `arial.ttf` correct? –  Jan 29 '16 at 09:51
  • How can I check this? Do you mean the file names under "C:\\Windows\\Fonts\\Arial? These are for example: "Arial Standard" for regular, "Arial Fett" for bold, "Arial kursiv" for italic... – Z.Kipp Jan 29 '16 at 12:06
  • Windows usually hides the real file names of fonts. To see the file name of Arial, copy the font in `C:\Windows\Fonts` and paste it to a different location, and then in the destination folder it will be an ordinary file. – yixuan Feb 24 '16 at 21:30
  • Thank you, yixuan. I already solved my problem by exporting the figure as svg-file and a colleague converted it to eps with another program. But hopefully your answer will help someone with the same problem. – Z.Kipp Feb 26 '16 at 08:32

1 Answers1

0

I faced similar problems and found this tutorial very helpful. For me it worked for using Arial in an EPS device.

install.packages("extrafont")
library(extrafont)
font_import() # takes a few minutes
loadfonts(device="postscript")
postscript("test_fonts.eps", width=2000, height=2000, family="Arial")
plot(x=rnorm(10), y=rnorm(10), xlab="x in Arial", ylab="y in Arial", main="a title")
dev.off()

This is using base plotting functionalities, you can try whether it also works for ggplot.

Vera
  • 29
  • 4