在 Ubuntu 中将 Times New Roman 添加到 Ghostscript

seb*_*835 5 pdf fonts truetype ghostscript

在 Ubuntu 中使用 Ghostscript 8.71,但无法读取所有页面上都有 times new roman 字体的 PDF 文件。

我下载了 msttcorefonts 包并为 Ghostscript 创建了一个 Fontmap 文件,但这似乎不起作用。

我的 Fontmap 文件如下所示:

/Times (/usr/share/fonts/truetype/msttcorefonts/times.ttf);
/Times-Roman (/usr/share/fonts/truetype/msttcorefonts/times.ttf);
/Times-Bold (/usr/share/fonts/truetype/msttcorefonts/timesbd.ttf);
/Times-BoldItalic (/usr/share/fonts/truetype/msttcorefonts/timesbi.ttf);
/Times-Italic (/usr/share/fonts/truetype/msttcorefonts/timesi.ttf);
Run Code Online (Sandbox Code Playgroud)

我使用的 Ghostscript 命令:

gs -sFONTMAP=/usr/share/ghostscript/8.71/Fontmap bad.pdf -o good.pdf
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 3.
Page 1
Error: /undefined in --run--
Operand stack:
   --dict:5/14(L)--   F2   11.0   FontObject   --dict:8/8(L)--   --dict:8/8(L)--   397   --dict:8/8(L)--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   3   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1151/1684(ro)(G)--   --dict:1/20(G)--   --dict:75/200(L)--   --dict:75/200(L)--   --dict:108/127(ro)(G)--   --dict:288/300(ro)(G)--   --dict:22/25(L)--   --dict:6/8(L)--   --dict:25/40(L)--   --dict:1151/1684(ro)(G)--   --dict:10/10(L)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.71: Unrecoverable error, exit code 1
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?我觉得我已经用尽了所有我能想到的可能性。

这是我尝试通过 Ghostscript 运行的 PDF 文件:bad.pdf

如果我像这样加载所有字体:

gs -c 'loadallfonts quit'
Run Code Online (Sandbox Code Playgroud)

那么对 Times New Roman 字体的唯一引用是:

Loading TimesNewRomanPS-BoldItalicMT font from /usr/share/fonts/truetype/msttcorefonts/timesbi.ttf... 4310316 2923512 4001304 2206507 1 done.
Run Code Online (Sandbox Code Playgroud)

阅读所附 PDF 的属性,我可以看到它实际想要的字体是TimesNewRomainPSMT。为什么 gs 没有加载 msttcorefonts 文件夹中的所有字体?

Kur*_*fle 3

这是该pdffonts实用程序的报告内容bad.pdf

pdffonts bad.pdf
名称 类型 编码 emb sub uni 对象 ID
--------------------------- ----------------- ------ ---------- --- --- --- ---------
Times-Roman 类型 1 WinAnsi 否 否 12 0
DejaVuSerifCondensed 类型 1 WinAnsi 是 否 13 0
DejaVuSansCondensed 类型 1 WinAnsi 是 否 16 0
DejaVuSansCondensed-Bold 类型 1 WinAnsi 是 否 19 0

这意味着以下内容:

  1. 未嵌入的字体名称是Times-Roman,并不TimesNewRomanPSMT像您想象的那样。(我猜您使用了 Adob​​e Acrobat/Reader 的“文件属性”对话框来查看字体属性?您在其中看到了标记为“实际字体”或类似名称的字体名称?这意味着 Acrobat 正在使用该字体TimesNewRomanPSMT作为替代字体,因为它没有Times-Roman自己命名的字体!)

  2. 嵌入了该系列的 3 种字体DejaVu。这些不是子集,而是作为完整字体嵌入。

到目前为止,一切都很好...

或者?

现在看看如果我尝试让从当前 Git 源编译的最新 Ghostscript 版本处理此问题会发生什么bad.pdf

    gs -o new.pdf -sDEVICE=pdfwrite bad.pdf

 GPL Ghostscript GIT 预发布 9.16 (2014-09-22)
 版权所有 (C) 2014 Artifex Software, Inc. 保留所有权利。
 该软件不附带任何保证:有关详细信息,请参阅公共文件。
 处理第 1 至第 3 页。
 第1页
   **** 警告:无法处理字体流,按名称加载字体。
 用 Helvetica-Narrow 字体替换 DejaVuSerifCondensed。
 正在从 %rom%Resource/Font/NimbusSanL-ReguCond 加载 NimbusSanL-ReguCond 字体... 4671296 3041958 2433440 1055875 3 已完成。
 正在从 %rom%Resource/Font/NimbusRomNo9L-Regu 加载 NimbusRomNo9L-Regu 字体... 4688240 3115971 2494016 1110728 3 已完成。
 第2页
   **** 警告:无法处理字体流,按名称加载字体。
 用 Helvetica-Narrow 字体替换 DejaVuSerifCondensed。
 第3页
   **** 警告:无法处理字体流,按名称加载字体。
 用 Helvetica-Narrow 字体替换 DejaVuSerifCondensed。

   **** 此文件有错误,已修复或忽略。
   **** 该文件由以下人员生成:
   **** ====== mPDF 4.6 ======
   **** 请通知生成此内容的软件的作者
   **** 文件不符合 Adob​​e 发布的 PDF
   **** 规格。

Ghostscript 无法处理您的嵌入字体。

这个特定的 PDF 似乎存在比您想象的更多的错误。