Skip to contents

grDevices::pdf() draws the glyphs of geom_point_glyph() by referring to the shapes font without embedding it, so the file shows the shapes only on a system where the font is installed. embed_shapes_font() embeds the shapes it uses, with Ghostscript through grDevices::embedGlyphs().

Usage

embed_shapes_font(file, outfile = file)

Arguments

file

Path to a PDF file written by grDevices::pdf().

outfile

Path to write the PDF with the font embedded. The default overwrites file.

Value

outfile, invisibly. It is file unless outfile is given, so the result is always the path of the PDF with the font embedded.

Details

Requires R 4.3 or later and Ghostscript (see tools::find_gs_cmd()). Only files written by pdf() need it: ragg and the other raster devices draw the glyphs into the image.

Examples

library("ggplot2")
p <- ggplot(mtcars, aes(wt, mpg, shape = factor(gear))) +
  geom_point_glyph(size = 3) +
  scale_shape_cleveland(unicode = TRUE)
path <- tempfile(fileext = ".pdf")
ggsave(path, p, device = pdf, width = 5, height = 4)
embed_shapes_font(path)