pdf - 在 Ubuntu 中为 Ghostscript 添加 Times New Roman

标签 pdf fonts ghostscript truetype

在 Ubuntu 中使用 Ghostscript 8.71,但无法阅读所有页面上都有新罗马字体的 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 文件夹中的所有字体?

最佳答案

这是什么pdffonts关于 bad.pdf 的公用事业报告:

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

这意味着:

  • 未嵌入的字体名称是 Times-Roman ,不是 TimesNewRomanPSMT如你想象的。 (我猜你使用了 Adob​​e Acrobat/Reader 的“文件属性”对话框来查看字体属性?在那里你看到这个字体名称被标记为“实际字体”或类似的?这意味着 Acrobat 正在使用这个名为 TimesNewRomanPSMT 的字体)作为 替代 ,因为它本身没有名为 Times-Roman 的字体!)
  • DejaVu有3种字体家庭嵌入。这些不是子集,而是作为完整字体嵌入。

  • 到现在为止还挺好...

    或者?

    现在看看如果我尝试让从当前 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。保留所有权利。
    该软件不附带任何保证:有关详细信息,请参阅文件 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 似乎比你想象的要错误得多。

    关于pdf - 在 Ubuntu 中为 Ghostscript 添加 Times New Roman,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15072166/

    相关文章:

    html - @font-face 强标签和仿粗体渲染之间的问题

    linux - GhostScript:Windows 7 转换成功,而 Linux 失败

    pdf-generation - ghostscript pdfwrite 指定 jpeg 质量

    javascript - 将 HTML 文件转换为 PDF

    java - 使用 Apache PDFBox 在 PDF 中查找 javascript 代码

    php - 如何使用 PHPWord 将 Word 文档转换为 PDF

    c# - 在服务器端 c# 打印 html 或 pdf

    CSS 边框 mpdf 输出

    css - 带有 "Comfortaa"Google 字体的占位符文本被截断

    winforms - 将控件定位在 CheckBox 的中间