Search code examples
rpdfplotggplot2adobe-indesign

Embedded pdf-font in R-plot is not recognized by InDesign although available


Using ggplot2, extrafont and R's pdf device I have built plots in the cmyk colormodel that incorporate certain non-Windows fonts. The pdf-output looks fine and shows that the font has been embedded correctly, for instance "Arial-BoldMT".

Unfortunately, when trying to import the pdf into Adobe InDesign, I get the error message that the font "Arial-BoldMT" is not currently available, which also happens to the non-Windows fonts I mentioned above.

I suppose there might be a problem with the name of the embedded font that cannot be recognized by InDesign, since the font is very well available as "Arial" including all the variations such as "bold".

Any suggestions how to get those fonts working in InDesign by either adjusting the R script or using InDesign?

Thank you!

Here is a sample plot, similar to the plots I need to produce, just leaving out the unnecessary code lines:

library(ggplot2)
library(extrafont)

# define font
font <- "Arial"

# sample data
x <- data.frame(c("Personnel Costs", "Non-Personnel Costs", "Investments"),
                c(33, 22, 45))
colnames(x) <- c("costs", "percent")

# plot
plot <- ggplot(x, aes("", y = percent, fill = factor(costs), width = 1.2))+
  geom_bar(width = 4, stat="identity")+
  # add the text (no font specification here)
  geom_text(aes(label=costs),fontface = "bold")+
  # no legend
  theme(legend.position = "none") +
  # pie-chart
  coord_polar("y", start = 0.42, direction = 1)

# save plot
pdf("plot.pdf", family=font, colormodel="cmyk")
plot
dev.off()

PS: Using ggsave and embedFonts() with Ghostscript produced the same results.

Note: Using "Calibri" with the pdf device or ggsave and embed_fonts() does not work at all.


Solution

  • It seems if the font was not properly embedded into the pdf. By running embed_fonts() after saving the plot, the according font got embedded and now works in InDesign.

    I just needed:

    library(extrafont)
    embed_fonts(file="plot.pdf", outfile="plot.pdf")