Ghostscript-无法找到(或无法打开)字体文件

时间:2019-05-21 10:19:25

标签: ghostscript

我尝试从php(imagemagic)中的pdf创建图像。在图像上缺少文本。

要调试此问题,我转到CLI并使用以下命令:

  

gs -sDevice=png16m -sOutputFile="test.png" test.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 1.
Page 1
Can't find (or can't open) font file /usr/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/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Querying operating system for font files...
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Loading ArialMT font from /usr/share/fonts/truetype/msttcorefonts/Arial.ttf... 4395876 2792289 6087360 4693359 4 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/Arial-BoldMT.
Can't find (or can't open) font file Arial-BoldMT.
Loading Arial-BoldMT font from /usr/share/fonts/truetype/msttcorefonts/arialbd.ttf... 4395876 2792684 6897144 5444610 4 done.
Can't find CID font "Arial".
Attempting to substitute CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Identity ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource. 
Warning: falling back to Identity ordering
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font CIDFallBack ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource. 
   **** Error: can't process embedded font stream,
        attempting to load the font using its name.
               Output may be incorrect.
Can't find CID font "Arial".
Attempting to substitute CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Identity ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource. 
Warning: falling back to Identity ordering
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font CIDFallBack ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource. 
   **** Error reading a content stream. The page may be incomplete.
               Output may be incorrect.
   **** Error: File did not complete the page properly and may be damaged.
               Output may be incorrect.
%%BoundingBox: 85 470 562 757
%%HiResBoundingBox: 85.491068 470.681986 561.761983 756.827977

我找到了很多话题,尝试了很多,但是我无法解决问题。我认为问题是CID字体,但是我不确定。

有人可以给我一些技巧来解决这个问题吗?

服务器:Debian GNU / Linux 9(拉伸) Ghostscript:GPL Ghostscript 9.26(2018-11-20)

1 个答案:

答案 0 :(得分:0)

您似乎有几个问题。很难确定,因为您没有提供要检查的PDF文件。

首先,您的PDF文件似乎正在尝试使用名为'Arial'的CIDFont,该文件未嵌入PDF文件中。它还不包含调整字体ArialMT和Arial-BoldMT,但是您似乎可以从fontmap.GS或通过fontconfig(如果您的构建包括该字体)中找到可疑字体。

无法嵌入字体是一种不习惯的做法,在PDF规范中专门针对未能嵌入CIDFonts。

Ghostscript尝试使用其后备方法为丢失的Arial CIDFont定义替代CIDFont。首先,它尝试使用备用字体Adobe-Identity(名称从CIDSystemInfo派生),但是CIDFont也不可用。因此,它又回到了下一个尝试,即使用DroidSansFallback。

但是失败了,因为为了产生令人满意的替代品,Ghostscript需要一个CMap来构建CIDDecoding资源。看来您的安装缺少相关的CMap。

您的发行版似乎打包了Ghostscript,因此它不使用ROM文件系统。而是“看起来”所有文件都安装在磁盘上的/usr/share/ghostscript/9.26

下。

您应该查找目录/usr/share/ghostscript/9.26/Resource/CMap,并查看是否存在一个名为Identity-UTF16-H的文件。

我猜可能没有,这是由于您的软件包维护者做出的决定。我不知道为什么他们会选择不包括该文件,但是如果没有该文件(以及该文件夹中的其他文件),CIDFont支持将受到阻碍。

如果它不存在,建议您与Debian软件包维护者联系。由于Ghostscript是根据AGPL许可的,因此当然可以从Ghostscript Git存储库和Ghostscript网站获得源代码(包括所有支持文件)。您可以从那里获取丢失的文件。

请注意,当前版本为9.27,我建议升级。