【问题标题】:Postscript can't find installed fonts on MacOS from R ScriptPostscript 无法从 R Script 找到 MacOS 上已安装的字体
【发布时间】:2019-07-13 16:15:33
【问题描述】:

我希望将一些文本转换为 Postscript。使用herehere 中的以下方法适用于某些字体,但不是全部。我很困惑为什么会这样。

它适用于 Times,使用 Postscript 名称 TimesNewRomanPSMT。 它不适用于 Snell Roundhand、Postscript 名称、SnellRoundhand。

两者都是 .ttf 字体。 两者都位于我 iMac 上的 /Library/Fonts 中。

当找不到字体并默认为 Helvetica 时,是否会在某处创建 Postscript 错误消息?如果有,在哪里?

在 R 中有没有更好的方法从文本创建 Postscript 文件?

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)

【问题讨论】:

    标签: r macos fonts


    【解决方案1】:

    Unix_SO 建议的脚本对我有用。

    # 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)
    

    【讨论】:

      猜你喜欢
      • 2017-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-28
      • 2020-02-26
      • 2021-02-08
      • 1970-01-01
      相关资源
      最近更新 更多