【问题标题】:embedFonts changes the paper size in my R plotembedFonts 更改我的 R 图中的纸张大小
【发布时间】:2021-12-12 05:42:34
【问题描述】:

当我使用 embedFonts 将字体嵌入 EPS 文件时,纸张大小会发生变化,并且我的 R 绘图图形位于左下角。这个问题已经在这里问过embed_fonts() changes paper size on encapsulated postscript (.eps, R),但没有解决。所以这是一个最小工作示例的问题。我在 macOS Big Sur 上使用 R 版本 4.1.1 和 Ghostscript 版本 9.50 或 9.54.0。

fileName = 'WithoutFonts.eps'
fileNameEmbed = 'WithEmbeddedFonts.eps'
setEPS()
postscript( file = fileName, height = 5, width = 4 )
plot( rnorm(100), rnorm(100), main = 'Random Values' )
dev.off()
embedFonts( file = fileName, format = 'eps2write', outfile = fileNameEmbed )

【问题讨论】:

    标签: r fonts embed eps


    【解决方案1】:

    我找到了解决问题的方法。最初我创建了一个 EPS 文件,然后使用 embedFonts() 嵌入字体。从而改变了纸张尺寸。现在我创建一个 PDF 文件,然后使用 embedFonts() 嵌入字体并同时将格式更改为 EPS。现在它将边界裁剪到可见区域。这会使纸张尺寸过小。但是,如果您在 PDF 文件中绘制一个白框(另请参阅embedFonts is changing the bounding box of my R plot),则带有嵌入字体的 EPS 文件与原始 PDF 文件的大小完全相同。我怀疑这与 EPS 没有纸张大小而是边界框有关。提示:这适用于 eps2write,但不适用于 epswrite。

    fileName = 'WithoutFonts.pdf'
    fileNameEmbed = 'WithEmbeddedFonts.eps'
    pdf( file = fileName, height = 5, width = 4 )
    plot( rnorm(100), rnorm(100), main = 'Random Values' )
    box( which = 'outer', col = 'white' )
    dev.off()
    embedFonts( file = fileName, format = 'eps2write', outfile = fileNameEmbed )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-03
      • 1970-01-01
      • 2017-08-28
      • 1970-01-01
      • 2014-03-16
      • 1970-01-01
      • 1970-01-01
      • 2020-07-06
      相关资源
      最近更新 更多