0

I wish to convert some text to Postscript. Using the method below from here and here works for some fonts, but not all. I am puzzled as to why this is.

It works for Times, using the Postscript name, TimesNewRomanPSMT. It does not work for Snell Roundhand, Postscript name, SnellRoundhand.

Both are .ttf fonts. Both reside in /Library/Fonts on my iMac.

Are there Postscript error messages being created somewhere when it does not find the font and defaults to Helvetica? If so, where?

Is there a better way in R to create Postscript files from text?

library(grImport)

# Must use Postscript name of file. See Font Body app in MacOS
cat("%!PS 
     /SnellRoundhand findfont 
     100 scalefont 
     setfont 
     newpath 
     0 0 moveto 
     (yfde) show", file = "data/y.ps")

PostScriptTrace("data/y.ps", "data/y.xml")
letters <- readPicture("data/y.xml")
grid.picture(letters)
KenS
  • 30,202
  • 3
  • 34
  • 51
ixodid
  • 2,180
  • 1
  • 19
  • 46

1 Answers1

0

Unix_SO suggested enscript which works for me.

# Write text file
letter <- "a"
letter_txt <- paste0("q", ".txt")
write_file(letter, path = letter_txt, append = FALSE )

# Convert text to Postscript with enscript
font_size <- "SnellRoundhand10"
unix_cmd <- paste0("enscript -B -o ", letter, ".ps -f ", font_size, " ", letter_txt)
system(unix_cmd)
ixodid
  • 2,180
  • 1
  • 19
  • 46