I am currently trying to use Arial.ttf in all of my stories. I found several font manuals on the Internet, but I ran into problems when trying to save the bank through ggsave and the default device.
Minimal working example
I use the following minimal working example to reproduce this error:
Sys.setenv(R_GSCMD="D:/gs/bin/gswin64c.exe") library(ggplot2) require(extrafont) font_import(prompt = F, pattern = "arial.ttf") font_import(prompt = F, pattern = "JOKERMAN.TTF") loadfonts(device="win", quiet = T) loadfonts(device="pdf", quiet = T) plot <- ggplot(mtcars, aes(wt, mpg, colour = hp)) + geom_point() jokerman_plot <- plot + theme_bw(base_family = "Jokerman") arial_plot <- plot + theme_bw(base_family = "Arial") ggsave("arial_plot.png", arial_plot) ggsave("arial_plot.pdf", arial_plot) embed_fonts("arial_plot.pdf") ggsave("jokerman_plot.png", jokerman_plot) ggsave("jokerman_plot.pdf", jokerman_plot) embed_fonts("jokerman_plot.pdf")
This results in the following (correct) PNG images:

In Arial PDF, however, all characters are stacked on top of each other (Jokerman PDF does it right):

Warning output
These script generated the following warning messages.
Warning messages: 1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x68 2: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x70 3: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font metrics unknown for character 0x4d 4: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x68 5: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x70 6: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x4e 7: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x41 8: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font metrics unknown for character 0x4d 9: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x31 10: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 11: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 12: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x31 13: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x35 14: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 15: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x32 16: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 17: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 18: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x32 19: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x35 20: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 21: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x33 22: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 23: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 24: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x4e 25: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x41 26: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x4e 27: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x41 28: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x31 29: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 30: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 31: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x31 32: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x35 33: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 34: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x32 35: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 36: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 37: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x32 38: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x35 39: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 40: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x33 41: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 42: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x30 43: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x4e 44: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x41 45: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x6d 46: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x70 47: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x67 48: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font metrics unknown for character 0x4d 49: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x6d 50: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), ... : font width unknown for character 0x70
Session Information
My current sessionInfo()
R version 3.3.0 (2016-05-03) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] extrafont_0.17 ggplot2_2.1.0 RevoUtilsMath_3.2.5 loaded via a namespace (and not attached): [1] labeling_0.3 colorspace_1.2-6 scales_0.4.0 assertthat_0.1 plyr_1.8.3 tools_3.3.0 [7] gtable_0.2.0 ggthemes_3.0.3 Rcpp_0.12.5 extrafontdb_1.0 grid_3.3.0 digest_0.6.9 [13] Rttf2pt1_1.3.4 munsell_0.4.3
Attempts to solve
- I tried several ways to rename the generated AMF files to no avail.
- I thought that maybe the encoding of the source file might matter, so I changed it to UTF-8 (no change)
- Reset extrafontdb several times
- Reinstall ghostscript multiple times
Bypass
I currently have two workarounds, however I would prefer to use a βnativeβ PDF device configured in R or ggplot for easy portability
- Specify cairo_pdf as the device (this may lead to secondary output problems or some graphs being displayed a little differently). The pdf is ok, so can this mean a default error in the pdf device?
- Using PNG / bitmap output (I want to use graphics in print, so vector output is preferred)
- Rely on R using ArialMT by default. I'm not sure that ArialMT is exactly the same font as in my (latex) document, so I would like to explicitly specify the font.