【问题标题】:ghostscript fonts鬼脚本字体
【发布时间】:2011-01-19 15:58:29
【问题描述】:

我正在尝试让 ghostscript 从 Windows 框中呈现 pdf 文件。 pdf 文件使用 ComicSansMS 字体。我已将 Comic.ttf 文件从我的 Windows7 框中复制到我的 /usr/share/ghostscript/fonts 目录中,并在包含此行的同一目录中创建了一个 Fontmap 文件:

/ComicSansMS (comic.ttf) ;

据我所知,尽管如此,仍找不到该字体。文本出来的效果很差,一些较小的字体大小呈现为应有大小的一半。访问时间和 strace 显示正在读取 Fontmap 文件,但根本没有访问字体文件 (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

我在 Fontmap 文件中尝试了几种格式排列,包括:

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

我很确定我原来的那个是正确的,但我越来越绝望了。 :-P

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

【问题讨论】:

  • 你能提供一个样本PDF吗? ComicSansMS 字体是否嵌入在 PDF 中(或者为什么您会看到字体名称的“有趣”前缀?)?
  • 嗯,嗯...我不确定我能否提供该文件,因为它的大小接近 1 兆字节。我假设字体没有嵌入,或者它会工作,对吧?
  • 现在,我已经有些放弃了。我挖出了一个旧的 PhotoShop 副本并编写了一些 Javascript 来让 PhotoShop 做我需要做的事情。这很丑陋,但涉及的摔跤要少得多。 =/ 我仍然希望看到 ghostscript 完成这项工作,因为它似乎应该能够做到,但现在它更适合我自己的教育。

标签: linux fonts ghostscript truetype


【解决方案1】:

我假设 PDF 没有嵌入 ComicSansMS 字体?

您还应该考虑其他两种可能性:

  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 看起来不错,并且确实嵌入了 comic.ttf 字体。

如果这也适用于您,那么您的 Ghostscript 和您的 comic.ttf 都可以,但您的 PDF 文件 cards-01.pdf 不是。

【讨论】:

  • PDF 文件绝对没问题。我可以在 Windows 和 Macintosh 上的 Acrobat Reader 中轻松阅读它。至于comic.ttf 文件,我不知道它是否已损坏,但我相当确定它无关紧要,因为该文件根本没有被打开。我确保文件系统是使用 strictatime 选项安装的,并且访问时间没有改变。另外,我在 strace 下运行了 ghostscript,我可以看到 Fontmap 文件正在打开,但 ghostscript 从不访问字体文件。我尝试了您建议的命令,它似乎确实有效,输出 Comic-ttf.pdf 没有错误。
  • 我想我的 PDF 可能没有引用我认为的字体。鉴于我从 gs -dFAPIDEBUG 看到的消息(请参阅原始帖子),我对这种可能性持怀疑态度,但我不是 ghostscript 专家。
  • @Rick Koshi:如果您的 PDF 没有嵌入 ComicSansMS,您的 PDF 查看器需要使用系统上的那个。因此,如果该文件已损坏或有效,则 NOT 完全无关紧要!
  • @Rick Koshi:...所以你现在有确凿的证据证明 comic.ttf 是有效的,并且你的 Ghostscript 9.00 也能够处理该字体!所以很可能PDF有问题......
  • @Rick Koshi:您应该知道 Acrobat 有时会默默地“修复”损坏的 PDF 文件并正常显示。但是,其他查看器/后处理器可能会遇到此类损坏的 PDF 的问题......
【解决方案2】:

延迟后我又回到了这个问题。用放大镜进一步调查,问题和我最初想的不一样。

文档的某些部分中的文本肯定呈现不正确。每个字母都太小了,尽管间距非常正确。但是,单个字母是字体的正确形状。

磁盘上的字体没有被访问,但那是因为字体都嵌入在文档中。从我在原始问题中发布的输出中,对于 Ghostscript 专家来说,这一事实可能是显而易见的(我猜“HYLUQF+”前缀是那里的确凿证据),但我不太使用 Ghostscript。我的字体安装正确,其他文档可以毫无问题地访问它们。

当然,这仍然留下了为什么我的嵌入字体渲染不正确的问题,但我会单独调查和/或发布不同的问题。我坚持认为 PDF 文件没有损坏(我有几个其他 PDF 也出现了同样的问题),但我仍然不知道出了什么问题。

@pipitas:非常感谢您的尝试。您确实确实帮助验证了我安装的字体不是问题。其实,现在我再看,你还轻轻地暗示可能是嵌入了字体,但我要么没看到,要么不相信,要么不知道如何检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 1970-01-01
    • 1970-01-01
    • 2011-02-18
    相关资源
    最近更新 更多