我正在尝试获取Ghostscript来从Windows框渲染PDF文件。 PDF文件使用Comicsansms字体。我已经从Windows7 box复制了Comic.ttf文件中的/usr/usr/share/ghostscript/fonts目录,并且我在包含此行的同一目录中创建了一个fontmap文件:

/ComicSansMS (comic.ttf) ;

如我所知,尽管如此,该字体并未被发现。文本的出现非常差,一些较小的字体尺寸的尺寸将其尺寸缩小一半。访问时间和Strace表明正在读取字体示例文件,但是根本无法访问字体文件(comic.ttf)。没有错误消息:

hope 78$ gs cards-01.pdf
GPL Ghostscript  9.00 (2010-09-14)
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 1.
Page 1
>>showpage, press <return> to continue<<

如果我在GS命令行上使用-dfapidebug,我会看到以下内容:

hope 74$ gs -dFAPIDEBUG -I/usr/share/ghostscript/fonts cards-01.pdf
GPL Ghostscript  9.00 (2010-09-14)
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 1.
Page 1
FAPIhook --nostringval--
Trying to render the font Font --nostringval-- ( aliased from ComicSansMS ) with FAPI...
Font --nostringval-- ( aliased from ComicSansMS ) is being rendered with FAPI=FreeType
FAPIhook --nostringval--
Font --nostringval-- ( aliased from ComicSansMS ) is mapped to FAPI=FreeType
FAPIhook RVJCAL+SymbolMT
Trying to render the font Font RVJCAL+SymbolMT with FAPI...
Font RVJCAL+SymbolMT is being rendered with FAPI=FreeType
FAPIhook RVJCAL+SymbolMT
Font RVJCAL+SymbolMT is mapped to FAPI=FreeType
FAPIhook HYLUQF+ComicSansMS
Trying to render the font Font HYLUQF+ComicSansMS with FAPI...
Font HYLUQF+ComicSansMS is being rendered with FAPI=FreeType
FAPIhook HYLUQF+ComicSansMS
Font HYLUQF+ComicSansMS is mapped to FAPI=FreeType
>>showpage, press <return> to continue<<

自然,上面最关心的线条是:

Font --nostringval-- ( aliased from ComicSansMS ) is being rendered with FAPI=FreeType

“ GS -H”表明,字体目录确实是在搜索路径中:

hope 77$ gs -h
GPL Ghostscript  9.00 (2010-09-14)
    [ ... ]
Search path:
   /usr/share/ghostscript/9.00/Resource/Init :
   /usr/share/ghostscript/9.00/lib :
   /usr/share/ghostscript/9.00/Resource/Font :
   /usr/share/ghostscript/fonts : /usr/share/fonts/Type1 : /usr/share/fonts

我尝试了字体示例文件中的几个格式排列,包括:

(Comic Sans MS) (comic.ttf) ;
(ComicSansMS) (comic.ttf) ;
/Comic Sans MS (comic.ttf) ;
/ComicSansMS /comic.ttf ;

我很确定我的原始一个是正确的,但是我变得绝望了。 :p

任何帮助将不胜感激。提前致谢。

有帮助吗?

解决方案 2

延迟后,我回到了这个问题。在用放大镜进一步调查后,问题与我最初认为的不同。

文本肯定会在文档的部分内容中呈现。每个字母太小了,尽管间距是正确的。但是,单个字母是字体的正确形状。

磁盘上的字体无法访问,但这是因为字体都嵌入文档中。对于我在原始问题中发布的输出中,这一事实可能很明显(我猜“ Hyluqf+”前缀是那里的吸烟枪),但我不多地使用Ghostscript。我的字体已正确安装,其他文档也能够毫无问题地访问它们。

当然,这仍然留下了这样一个问题,即为什么我的嵌入式字体被错误地渲染,但我将分别调查和/或发布不同的问题。我坚持认为PDF文件未腐败(我还有其他几个显示出同样问题的PDF),但我仍然不知道怎么了。

@pipitas:非常感谢您的尝试。您当然确实有助于验证我的安装字体不是问题所在。实际上,既然我再次看,您甚至可以轻轻地建议使用该字体,但是我要么没有看到它,不相信它,要么不知道该如何检查。

其他提示

我认为PDF没有Comicsansms字体嵌入?

您也应该考虑其他2种可能性:

  1. 您的PDF文件 card-01.pdf 某种程度上腐败了。 (其他PDF查看器是否毫无问题地渲染该文件?它在Widnows上的Acrobat Reader中显示正常吗?)
  2. 你的字体 comic.ttf 某种程度上腐败了。 (您使用哪种方法将其从Windows转移到Linux?)

您可以尝试通过使用ghostscript+comic.ttf来实现积极证明这两个组件相处得很好 创造 PDF(带有comic.ttf嵌入):

gs \
  -sFONTPATH=/usr/share/ghostscript/fonts \
  -o comic-ttf.pdf \
  -sDEVICE=pdfwrite \
  -g5950x8420 \
  -c "200 700 moveto" \
  -c "/ComicSansMS findfont 60 scalefont setfont" \
  -c "(comic.ttf) show showpage"

在Windows上,使用以上命令的这种变体:

gswin32c.exe ^
  -o comic-ttf.pdf ^
  -sDEVICE=pdfwrite ^
  -sFONTPATH=c:/windows/fonts ^
  -g5950x8420 ^
  -c "200 700 moveto" ^
  -c "/ComicSansMS findfont 60 scalefont setfont" ^
  -c "(comic.ttf) show showpage"

当我这样做时,我看到:

gswin32c.exe ^
   -o comic-ttf.pdf ^
   -sDEVICE=pdfwrite ^
   -sFONTPATH=c:/windows/fonts ^
   -dHaveTrueTypes=true ^
   -g5950x8420 ^
   -c "200 700 moveto" ^
   -c "/ComicSansMS findfont 60 scalefont setfont" ^
   -c "(comic.ttf) show showpage"
GPL Ghostscript  9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Scanning c:/windows/fonts for fonts... 423 files, 255 scanned, 240 new fonts.
Loading ComicSansMS font from c:/windows/fonts/comic.ttf... 3343720 1813337 2926116 1611207 1 done.

和我的输出PDF comic-ttf.pdf 看起来还不错,并且确实嵌入了漫画。TTF字体。

如果这也适用于您,那么您的ghostscript和漫画ttf还可以,但是您的pdf文件 cards-01.pdf 不是。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top