For saving ggplots with font name Calibri to pdf files, I tried to use the extrafont
package in order to be able to use this font type within ggplot2.
These were the steps I took:
font_import()
After getting all the fonts (during that proces nothing seems wrong), I get this error:
Scanning afm files in <<library path>>/extrafontdb/metrics
Error in if (grepl("Bold", weight)) { : argument is of length zero
together with errors like these:
Warning messages:
1: In readLines(srcfile) :
invalid input found on input connection 'C:<<path>>\AppData\Local\Temp\26\RtmpANG4o2/fonts/ahronbd.afm'
2: In readLines(srcfile) :
incomplete final line found on 'C:<<path>>\AppData\Local\Temp\26\RtmpANG4o2/fonts/ahronbd.afm'
etc.
When I run this code:
loadfonts()
fonts()
the output is NULL
and when I try to save a ggplot as a pdf using ggsave()
, the error says:
Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
I guess that last error is not that surprising as the font table seems empty.
What's going wrong here and how can this problem be solved?
EDIT I thought I found the solution. When I use loadfonts(device="win")
instead of loadfonts()
all seemed to go well at first, but I was wrong. fonts()
is still empty.