运维开发网

pdf – 在Ubuntu中将Times New Roman添加到Ghostscript

运维开发网 https://www.qedev.com 2020-05-17 16:38 出处:网络 作者:运维开发网整理
在Ubuntu中使用Ghostscript 8.71,但无法读取在其所有页面上都有新罗马字体时间的PDF文件.
在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:bad.pdf运行的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 
name                        type              encoding         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. (我猜你用Adobe Acrobat / Reader“文件属性”对话框查看字体属性?你看到这个字体名称标记为“Actual Font”或类似?这意味着Acrobat使用这个名为TimesNewRomanPSMT的字体作为替换,因为它没有名为Times-Roman本身的字体!)

>嵌入了DejaVu系列的3种字体.这些不是子集,但是作为完整字体嵌入.

到现在为止还挺好…

要么?

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

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

 GPL Ghostscript GIT PRERELEASE 9.16 (2014-09-22)
 Copyright (C) 2014 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
   **** Warning: can't process font stream, loading font by the name.
 Substituting font Helvetica-Narrow for DejaVuSerifCondensed.
 Loading NimbusSanL-ReguCond font from %rom%Resource/Font/NimbusSanL-ReguCond... 4671296 3041958 2433440 1055875 3 done.
 Loading NimbusRomNo9L-Regu font from %rom%Resource/Font/NimbusRomNo9L-Regu... 4688240 3115971 2494016 1110728 3 done.
 Page 2
   **** Warning: can't process font stream, loading font by the name.
 Substituting font Helvetica-Narrow for DejaVuSerifCondensed.
 Page 3
   **** Warning: can't process font stream, loading font by the name.
 Substituting font Helvetica-Narrow for DejaVuSerifCondensed.

   **** This file had errors that were repaired or ignored.
   **** The file was produced by: 
   **** ====== mPDF 4.6 ======
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.

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

这个特定的PDF似乎比你想象的要错得多.

0

精彩评论

暂无评论...
验证码 换一张
取 消