【问题标题】:How to convert text within EPS figures to vector outlines in R?如何将 EPS 图形中的文本转换为 R 中的矢量轮廓?
【发布时间】:2016-06-05 08:06:18
【问题描述】:

我正在准备一篇论文以提交给期刊,该期刊要求以 EPS 格式提交矢量图形,图形中的所有文本都转换为轮廓。将文本转换为矢量轮廓有助于避免最终布局中出现字体问题。期刊要求可here

可以使用ggplot2 在 R 中轻松创建 EPS 图形:

library(ggplot2)
ggsave(filename = "file.eps")

或使用setEPS()postscript 设备,如前所述here

setEPS()
postscript("filename.eps")
plot(1:10)
dev.off()

我的问题是:如何将图中的文本转换为矢量轮廓?我在其他软件(例如 Illustrator 或 InDesign)中找到了有关如何执行此操作的信息,但我想知道是否有办法直接在 R 中执行此操作。

【问题讨论】:

    标签: r


    【解决方案1】:

    如果您在 linux 下使用发行版的包管理器安装 ghostscriptdownload it for windows(还有一个 portable version),对于 mac,您可能可以使用 use brew。然后在 R like in this SO question 中调用 gsgs.exe

    library(ggplot2)
    data(diamonds)
    
    gs.cmd <- "gs"  # ghostscript executable
    # gs.cmd <- "C:/path/to/gs.exe" # Windows
    
    p <- qplot(x=carat, y=price, color=clarity, data=diamonds)
    
    ggsave(p, filename="test.eps")
    
    system(paste(gs.cmd,"-o test_outline.eps -dNoOutputFonts -sDEVICE=eps2write test.eps"))
    

    【讨论】:

    • 谢谢,这些命令有效。但是我认为你有一个错字:选项应该是-sDEVICE=epswrite 而不是-sDEVICE=eps2write。我还添加了-dEPSCrop 以避免裁剪图像。为了检查它是否有效,我安装了pdffonts(Xpdf 的一部分),使用epstopdf 将两个EPS 文件转换为PDF,然后在PDF 上运行pdffonts 以检查嵌入的字体。这实际上表明两个 EPS 文件都没有任何嵌入字体,因此ggsave 可能已经将字体转换为原始 EPS 中的轮廓。任何人都可以确认吗?我搜索了ggplot2 文档,但找不到任何信息。
    • 您可以使用gs -h 列出ghostscript 中可用的驱动程序。在我的电脑上,eps2write 存在,epswrite 不存在,但这可能与其他 Ghostscript 版本不同
    猜你喜欢
    • 2011-12-14
    • 1970-01-01
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多