【问题标题】:Limiting problematic font mapping in Ghostscript在 Ghostscript 中限制有问题的字体映射
【发布时间】:2018-09-08 22:47:01
【问题描述】:

我正在使用 Ghostscript 处理一些 PDF 以减小大小。有时处理时嵌入的字体不如查看原件时使用的本地字体。

几个问题:

  1. 我想已经嵌入输入 PDF 中的字体会在输出 PDF 中重复使用,而不是从本地计算机获取。它是否正确?即使启用了子集设置也是如此吗?

  2. 是否有可能(并且合理地)让 Ghostscript 仅在严格匹配时嵌入缺失的字体?

  3. Ghostscript 是否可以保留已嵌入输入 PDF 中的字体,但不打扰嵌入源中缺少的字体?

背景

目前我在 Ghostscript 9.23 中使用以下命令:

gs -sDEVICE=pdfwrite \
   -dCompatibilityLevel=1.4 \
   -dDownsampleColorImages=true \
   -dDownsampleGrayImages=true \
   -dDownsampleMonoImages=true \
   -dColorImageResolution=72 \
   -dGrayImageResolution=72 \
   -dMonoImageResolution=72 \
   -dColorImageDownsampleThreshold=1.0 \
   -dGrayImageDownsampleThreshold=1.0 \
   -dMonoImageDownsampleThreshold=1.0 \
   -dNOPAUSE -dQUIET -dPARANOIDSAFER -dBATCH \
   -dDetectDuplicateImages=true \
   -sOutputFile=output.pdf input.pdf

但是,在某些情况下,字体重新映射似乎会损害渲染结果。这是一个没有任何嵌入字体的源 PDF 在字体替换和嵌入后对典型查看器的渲染性能下降的情况:

之前:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
FrizQuadrata-Bold                    Type 1            MacRoman         no  no  no       7  0
Helvetica-Black                      Type 1            MacRoman         no  no  no       9  0
Helvetica-Light                      Type 1            MacRoman         no  no  no      59  0
Helvetica-Bold                       TrueType          MacRoman         no  no  no      65  0
Helvetica-Bold                       Type 1            MacRoman         no  no  no      68  0
ZapfDingbats                         Type 1            Custom           no  no  no      70  0
Helvetica-Black                      Type 1            MacRoman         no  no  no     108  0
Helvetica-BlackOblique               Type 1            MacRoman         no  no  no     136  0
ZapfDingbats                         Type 1            Custom           no  no  no     137  0
Helvetica-Bold                       Type 1            MacRoman         no  no  no     780  0
Helvetica-LightOblique               Type 1            MacRoman         no  no  no     926  0

之后:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
VRGBBC+Times-Bold                    Type 1C           MacRoman         yes yes no       8  0
JTHLZY+Helvetica-Bold                Type 1C           MacRoman         yes yes no      10  0
ETQHWQ+Helvetica                     Type 1C           MacRoman         yes yes no      20  0
ZapfDingbats                         Type 1            ZapfDingbats     no  no  yes     29  0
LSUJJC+Helvetica-BoldOblique         Type 1C           MacRoman         yes yes no      46  0
RBDUAX+Helvetica-Oblique             Type 1C           MacRoman         yes yes no     202  0

【问题讨论】:

    标签: pdf ghostscript


    【解决方案1】:

    这里有很多要回答的......

    I imagine that fonts which are already embedded in an input PDF are reused in the output PDF rather than sourced from the local
    

    机器。它是否正确?即使在子集化时也是如此 启用了吗?

    当您创建一个新的 PDF 文件时,Ghostscript 的 pdfwrite 设备默认情况下会保留它可能从输入中获取的所有内容。这实际上对字体至关重要。

    Is it possible (and reasonably) to have Ghostscript only embed a missing font when it has a strict match?
    

    你如何定义“严格匹配”?

    Is it possible for Ghostscript to retain fonts already embedded in the input PDF but not bother embedding fonts that are missing in the
    

    来源?

    您当然可以调整 Ghostscript 的 pdfwrite 设备嵌入字体的方式,有几个控件,都记录在案。 AlwaysEmbed、NeverEmbed 数组允许您防止某些命名字体被嵌入,还有 EmbedAllFonts 和 SubsetFonts。

    尝试使用您的测试文档将 EmbedAllFonts 设置为 false(important 还将 SubsetFonts 设置为 false)。我还建议您共享一个显示问题的 PDF 文件,因为很难看出为什么会出现问题。 “一些退化”并不能真正告诉我很多。嵌入的字体(FrizQuadrata、Helvetica-Black、Helvetica-BlackOblique 和 Helvetica-LightOblique 除外)是 base 13 的一部分,因此应该没问题。

    在 PDF 文件中嵌入字体(除了 base 13 之外)是个坏主意,它应该是可移植的,如果你依赖字体替换,你总是冒着渲染结果不正确。

    假设您实际上在本地拥有这些字体,那么为什么不将它们提供给 Ghostscript 以便 pdfwrite 设备可以将字体的子集嵌入到新的 PDF 文件中呢?然后它将是便携式的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-09
      • 2020-02-20
      • 2011-06-16
      相关资源
      最近更新 更多