0

我已经阅读了大量关于从 PDF 转换(使用 ghostscript)到图像时字体问题的 stackoverflow 问题。

因为您没有嵌入字体,ghostscript 试图在您的系统中找到替代品并呈现更好的可能。

但我不明白为什么我的 MacOSX Preview 可以完美地呈现 PDF 而 ghostscript 不能。

gs -sFONTPATH=/Library/Fonts -sDEVICE=pngalpha -o file-%03d.png -r144 my.pdf 

我什至告诉 gs 字体在哪里。

这是输出。

$ pdffonts cv18.pdf 

Fontconfig warning: "/usr/local/etc/fonts/fonts.conf", line 86: unknown element "blank"
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
CenturyGothic,Bold                   TrueType          WinAnsi          no  no  no      13  0
CenturyGothic                        TrueType          WinAnsi          no  no  no      14  0
CourierNew                           TrueType          WinAnsi          no  no  no      15  0
Arial                                TrueType          WinAnsi          no  no  no      16  0
AYTOPC+Wingdings                     TrueType          WinAnsi          yes yes no      17  0
TimesNewRoman                        TrueType          WinAnsi          no  no  no      18  0
CenturyGothic,Italic                 TrueType          WinAnsi          no  no  no      24  0


$ gs -sDEVICE=pngalpha -o file-%03d.png -r300 cv18.pdf 

GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Querying operating system for font files...
Substituting font NewCenturySchlbk-Bold for CenturyGothic,Bold.
Loading C059-Bold font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/C059-Bold... 4357236 2918185 2219472 869812 4 done.
Substituting font NewCenturySchlbk-Roman for CenturyGothic.
Loading C059-Roman font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/C059-Roman... 4504148 3145674 2313416 951449 4 done.
Substituting font Courier for CourierNew.
Loading NimbusMonoPS-Regular font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/NimbusMonoPS-Regular... 4731860 3382093 2548760 1140366 4 done.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Didn't find this font on the system!
Substituting font Helvetica for ArialMT.
Loading NimbusSans-Regular font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/NimbusSans-Regular... 4939372 3576328 2589160 1183936 4 done.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/TimesNewRomanPSMT.
Can't find (or can't open) font file TimesNewRomanPSMT.
Can't find (or can't open) font file /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/TimesNewRomanPSMT.
Can't find (or can't open) font file TimesNewRomanPSMT.
Didn't find this font on the system!
Substituting font Times-Roman for TimesNewRomanPSMT.
Loading NimbusRoman-Regular font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/NimbusRoman-Regular... 5196116 3849418 3003064 1540393 4 done.
Page 2
Substituting font NewCenturySchlbk-Roman for CenturyGothic.
Substituting font NewCenturySchlbk-Bold for CenturyGothic,Bold.
Substituting font NewCenturySchlbk-Italic for CenturyGothic,Italic.
Loading C059-Italic font from /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/C059-Italic... 5504628 4138508 2467960 1088660 4 done.

问题是:为什么 MacOSX Preview 没有这个问题?它从哪里获取字体,以完美呈现?

4

1 回答 1

0

我需要查看您的 PDF 文件才能发表评论,但是如果您说“我什至告诉 gs 字体在哪里”,恐怕这似乎不正确。

Ghostscript 后台频道说:

找不到(或无法打开)字体文件 /usr/local/Cellar/ghostscript/9.26/share/ghostscript/9.26/Resource/Font/ArialMT.

所以要么文件不存在,要么 Ghostscript 无法打开它,或者它可能以某种方式损坏。

fontconfig 是您用来“告诉 gs 字体在哪里”的唯一东西吗?因为如果是这样,你并没有真正告诉 Ghostscript 任何东西。另请注意 fontconfig 警告,我不是字体配置专家,但我怀疑您可能也想解决这个问题。

Ghostscript 可能会或可能不会使用 fontconfig,这取决于它是如何构建的,这显然我不知道。如果您实际上要告诉Ghostscript字体(而不是 fontconfig),那么它可能会更好。您需要编辑/创建一个 fontmap.GS 文件并告诉 Ghostscript 在哪里可以找到它,使用 -I(包含)开关。

您可以在 /ghostscript/Resource/Init 中找到示例 fontmap.GS

为了提供更多帮助,我需要知道字体文件所在的确切路径,您用来告诉 Ghostscript 字体文件所在位置的方法,以及 fontmap.GS 的确切配置(或任何意味着您正在使用)。PDF 文件和字体文件也会很有帮助,以防字体文件以某种方式损坏。我也会对 ArialMT 和 C059-Roman 字体的格式感到好奇。PostScript 或 TrueType 字体?

于 2019-02-25T08:14:33.960 回答