【问题标题】:Adding Times New Roman to Ghostscript in Ubuntu在 Ubuntu 中将 Times New Roman 添加到 Ghostscript
【发布时间】:2013-02-10 21:40:54
【问题描述】:

在 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);

我使用的 Ghostscript 命令:

gs -sFONTMAP=/usr/share/ghostscript/8.71/Fontmap bad.pdf -o good.pdf

这是我得到的错误:

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

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

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

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

gs -c 'loadallfonts quit'

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

Loading TimesNewRomanPS-BoldItalicMT font from /usr/share/fonts/truetype/msttcorefonts/timesbi.ttf... 4310316 2923512 4001304 2206507 1 done.

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

【问题讨论】:

  • 您在第一行末尾缺少一个分号。
  • 您说文件包含字体 Times New Roman,但您似乎没有定义替代品,只是 Times 系列。鉴于您在“运行”时遇到错误,我确信 Fred F 是正确的。
  • 我已经确保没有丢失分号,但我仍然得到同样的错误。我还添加了一个指向我试图通过 Ghostscript 运行的 PDF 的链接。请问有人可以提供进一步的帮助吗?万分感谢。 bad.pdf
  • *PSMT 只是 Adob​​e Acrobat 使用的字体,它不是 PDF 中的字体名称。

标签: pdf fonts ghostscript truetype


【解决方案1】:

这是pdffonts 实用程序报告的关于bad.pdf 的内容:

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

这意味着:

  1. 没有嵌入的字体名称是Times-Roman,而不是你想象的TimesNewRomanPSMT。 (我猜您使用 Adob​​e Acrobat/Reader "file properties" 对话框查看字体属性?在那里您看到此字体名称标记为 "Actual Font" 或类似?这意味着 Acrobat 正在使用名为 TimesNewRomanPSMT 的字体作为替代,因为它本身没有名为 Times-Roman 的字体!)

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

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

还是?

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

gs -o new.pdf -sDEVICE=pdfwrite bad.pdf GPL Ghostscript GIT PRERELEASE 9.16 (2014-09-22) 版权所有 (C) 2014 Artifex Software, Inc. 保留所有权利。 此软件不提供任何担保:有关详细信息,请参阅文件 PUBLIC。 处理第 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 似乎比您想象的要多得多。

【讨论】:

  • 感谢 Kurt 的全面回复 - 非常感谢。我将根据您的发现调查其他途径。谢谢。
  • 是的!在流程中被叫走......你知道成为一名开发人员是怎样的;-)
猜你喜欢
  • 2018-10-24
  • 1970-01-01
  • 2016-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多