获取由XPS文档编写器生成的odttf文件的字体名称 [英] Get font name of odttf files generated by XPS document writer

查看:578
本文介绍了获取由XPS文档编写器生成的odttf文件的字体名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有只使用2种字体的pdf文件。



但是,当将pdf导出为xps格式时,在生成的xps文档中有与odphf文件一样多的glyphs元素。



现在我希望每个具有相同字体类型的字形具有相同的FontUri值。但是,如何识别2个odttf文件是否是相同的字体类型?有时(但不是总是)有可能的数字通过查看odttf文件的最后部分来查看字体名称​​ 。实际上,我通过查看紧接在这是一个唯一的ID 之前和之后的内容,通过python脚本定期从odttf文件(由XPS Document Writer生成)中提取字体名称在我目前看到的每个odttf文件的最后100个字节中都可以找到。当然,这是一个可怕的破解 - 但它起作用(至少对我来说)。



这是否真的起作用似乎取决于什么程序生成PDF文件和/或哪些程序用于将PDF文件打印到XPS Document Writer和/或PDF文档包含什么特定字体。



我的经验大多局限于以这种方式转换PDFlatex生成的PDF:作为在线数学导师,我需要将公式,文本和图纸从PDF转换为XAML,以便能够将它们粘贴到基于WPF的共享白板中。所以这个黑客可能会或可能不会为你工作。 (另外:这个黑客可能会停止工作,任何时候...)

而不是试图找出字体名称,你也可以转换您的PDF到XAML通过消除字体完全引用:您可以在发送到XPS文档编写器之前用pdfcrop(Heiko Oberdiek)裁剪PDF。根据我的经验,这迫使Adobe Reader和XPS Document Writer的组合(出于我不知道的原因)生成不包含任何Glyph的XAML代码,因此没有引用字体(包含在obfuscated odttf中文件)。但是,不幸的是,你会得到更多的XAML代码,因为所有的字形都必须用路径表示(这涉及到大量的重复)。

p>问候,
基督徒


I have pdf file using only 2 type of fonts.

But when exporting the pdf to xps format, there are odttf files as many as glyphs elements in generated xps document.

Now I want every glyphs with the same font type to have the same FontUri value. But how to identify if 2 odttf files is the same font type?

解决方案

Sometimes (but not always) it is possible to figure out the font name by looking at the final part of the odttf file. In fact, I am routinely extracting font names from odttf files (generated by the XPS Document Writer) with a python script by looking at what immediately precedes and follows the phrase "This is a unique ID" that can be found in the last 100 or so bytes of every odttf file that I have seen so far. Of course, this is a terrible hack - but it works (for me, at least).

Whether this really works seems to depend on what program generated the PDF file and/or what program is used to print the PDF file to the XPS Document Writer and/or what specific fonts the PDF document contains.

My experience is mostly limited to converting PDFs generated by pdflatex in this way: as an online math tutor I need to convert formulas, text and drawings from PDF to XAML in order to be able to paste them into a shared whiteboard that is based on WPF. So this hack might or might not work for you. (Also: this hack might stop working any time...)

Instead of trying to figure out the font name you could also convert your PDFs to XAML by eliminating the font references entirely: You can crop the PDF with pdfcrop (by Heiko Oberdiek) before sending it to the XPS Document Writer. In my experience this forces the combination of Adobe Reader and XPS Document Writer (for reasons unknown to me) to produce XAML code that does not contain any Glyphs, and thus no references to fonts (contained in obfuscated odttf files). But, unfortunately, you get much more XAML code, because all glyphs have to be represented by paths (which involves a great deal of repetition).

Regards, Christian

这篇关于获取由XPS文档编写器生成的odttf文件的字体名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆