确定 postscript (.ps) 文件中使用的字体

发布于 2024-08-29 07:38:46 字数 1466 浏览 5 评论 0原文

给定一个具有以下标题的 postscript 文件,

%!PS-Adobe-3.0

我想列出该文件中使用的所有字体。输出不必是完美的,但我需要确保获得对所使用的任何字体的所有引用。我知道有不同类型的字体,并且字体可能会也可能不会嵌入到 postscript 文件中。

我目前最好的想法是不区分大小写地 grep/搜索“字体”一词,然后从那里开始。

  • 这会给我所有的字体参考吗?
  • 有更好的方法来实现这一目标吗?

我倾向于使用 .NET/C# 进行开发,但任何解决方案都值得赞赏。

谢谢,

伯纳德

更新: lhf 的答案解决了这个问题,由于格式和长度限制,我根据他的建议添加了一个工作使用示例。

可以保存到 .cmd 文件并从命令提示符运行的 Windows 批处理文件:示例

REM Prerequisites: 
REM - GPL Ghostscript 8.64 @ http://pages.cs.wisc.edu/~ghost/doc/GPL/gpl864.htm
REM - pdffonts @ 3.02pl4 win32 download @ http://www.foolabs.com/xpdf/download.html

REM Add directories to path, contains ps2pdf and its dependency gswin32c.exe
SET PATH=%PATH%;C:\Program Files\gs\gs8.64\lib;C:\Program Files\gs\gs8.64\bin
REM Add pdffonts directory to path
SET PATH=%PATH%;c:\temp\path-toxpdf-3.02pl4-win32

REM Convert postscript file to pdf file
call ps2pdf input.ps temp.pdf

REM list pdf file fonts
call pdffonts temp.pdf

输出:

name                                 type              emb sub uni object ID 
------------------------------------ ----------------- --- --- --- ---------
DQRDAA+BCC128Medium-Identity-H       CID TrueType      yes yes no      21  0
MIAVUG+Verdana-Identity-H            CID TrueType      yes yes no      13  0
BKNKQN+Verdana-Identity-H            CID TrueType      yes yes no      10  0

Given a postscript file that has the following header

%!PS-Adobe-3.0

I would like to list all fonts used in the file. The output does not have to be perfect, but I need to make sure I get all references to any font being used. I am aware there are different types of fonts, and that a font may or may not be embedded in the postscript file.

My current best idea is to grep/search for the word Font case insensitively and go from there.

  • Will this get me all the font references?
  • Any better way to achieve this?

I tend to use .NET/C# for development purposes, but any solution is appreciated.

Thanks,

Bernard

UPDATE:
lhf's answer solved the problem, due to formatting and length constraints I am adding a working usage example based on his recommendations.

Windows batch file that can be saved to a .cmd file and run from the command prompt:

REM Prerequisites: 
REM - GPL Ghostscript 8.64 @ http://pages.cs.wisc.edu/~ghost/doc/GPL/gpl864.htm
REM - pdffonts @ 3.02pl4 win32 download @ http://www.foolabs.com/xpdf/download.html

REM Add directories to path, contains ps2pdf and its dependency gswin32c.exe
SET PATH=%PATH%;C:\Program Files\gs\gs8.64\lib;C:\Program Files\gs\gs8.64\bin
REM Add pdffonts directory to path
SET PATH=%PATH%;c:\temp\path-toxpdf-3.02pl4-win32

REM Convert postscript file to pdf file
call ps2pdf input.ps temp.pdf

REM list pdf file fonts
call pdffonts temp.pdf

Sample output:

name                                 type              emb sub uni object ID 
------------------------------------ ----------------- --- --- --- ---------
DQRDAA+BCC128Medium-Identity-H       CID TrueType      yes yes no      21  0
MIAVUG+Verdana-Identity-H            CID TrueType      yes yes no      13  0
BKNKQN+Verdana-Identity-H            CID TrueType      yes yes no      10  0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

予囚 2024-09-05 07:38:47

将文件转换为 pdf,然后使用 pdffonts(如果有)。

如果您喜欢 PS 编程,您可以运行一个模拟 PS 解释器(在 PS 中),它会忽略除 findfont 之外的大多数内容。

Convert the file to pdf and then use pdffonts if you have it.

If you're into PS programming, you could run a mock PS intepreter (in PS) that ignores most things except findfont.

注定孤独终老 2024-09-05 07:38:47

如果 PostScript 文件符合 PostScript 语言文档结构约定规范< /a> 您可以查找以字符串开头的 PostScript 注释:

%%DocumentNeededResources:
%%DocumentSuppliedResources:
%%DocumentFonts:
%%DocumentNeededFonts:
%%DocumentSuppliedFonts:

If the PostScript file conforms to the PostScript Language Document Structuring Conventions Specification you may look for PostScript comments starting witht the strings:

%%DocumentNeededResources:
%%DocumentSuppliedResources:
%%DocumentFonts:
%%DocumentNeededFonts:
%%DocumentSuppliedFonts:
浅沫记忆 2024-09-05 07:38:47

尝试以下正则表达式:

@"/.*?\sfindfont"

它会给你一些额外的东西,但你可以从那里开始使用它。

try the following regular expression:

@"/.*?\sfindfont"

it will give you some extra stuff, but you can play with it from there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文