XSL-FO:如何添加“helvetica neue"字体和输出到pdf [英] XSL-FO: how to add "helvetica neue" fonts and output to pdf

查看:56
本文介绍了XSL-FO:如何添加“helvetica neue"字体和输出到pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 XSL-FO (Apache FOP) 生成 pdf 时无法使用来自 windows 7 c:\windows\fonts* 的字体,我是否正确?

Am I correct that it's not possible to use fonts from windows 7 c:\windows\fonts* when using XSL-FO (Apache FOP) to generate a pdf?

我刚刚安装了 OTF 格式的helvetica neue"字体.

I've just installed the "helvetica neue" font in OTF format.

根据https://xmlgraphics.apache.org/fop/trunk/fonts.html

对系统字体的支持依赖于 Java AWT 子系统的字体度量信息.通过操作系统注册,AWT 子系统知道系统上可用的字体,以及每种字体的字体度量.

"Support for system fonts relies on the Java AWT subsystem for font metric information. Through operating system registration, the AWT subsystem knows what fonts are available on the system, and the font metrics for each one.

当使用支持系统字体的渲染器(见上表)并且您缺少一种字体时,您可以将它安装在您的操作系统中,并且它应该可用于这些渲染器.请注意,这不适用于仅支持自定义字体的输出格式,例如 PDF 或 PostScript."

When working with renderers that supports system fonts (see above table) and you're missing a font, you can just install it in your operating system and it should be available for these renderers. Please note that this is not true for output formats, such as PDF or PostScript, that only support custom fonts."

如果我的理解是正确的,就是说如果我的渲染是 PDF(意思是输出是 pdf??),那么我无法通过 AWT/OS 访问字体,因此,我将无法生成使用 Windows 7 字体在 PDF 中使用此类字体的文本?

If my understanding is correct, it's saying that if my render is PDF (meaning output is pdf??), then I can't access the fonts through AWT/OS, therefore, I won't be able to generate the text with such fonts in PDF using the the windows 7 fonts?

------------------------------更新,这仅适用于 ttf 字体,不适用于 otf.不知道如何让 otf 字体工作.

------------------------------Update, this works only for ttf font, not otf. Not sure how I can get otf fonts to work.

-----------------------------更新:20150402:

-----------------------------update: 20150402:

使用 FOP 1.1:

Using FOP 1.1:

我从以下地址下载了这种特殊的免费 Helvetica neue 字体:http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html

I downloaded this particular free helvetica neue font from: http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html

我将 fop 配置为使用 fop.xconf,但在处理 ttf 文件时出现错误,而且我不知道如何使用 fontforge 编辑字体 ttf 文件:

I configured fop to use fop.xconf but I'm getting an error processing the ttf file, and I don't know how to edit the font ttf file with fontforge:

fop -c fop.xconf -xml xml.xml -xsl coversheet.xsl -pdf output.pdf

fop -c fop.xconf -xml xml.xml -xsl coversheet.xsl -pdf output.pdf

Apr 2, 2015 6:53:55 PM org.apache.fop.fonts.truetype.TTFFile readCMAP
SEVERE: Unsupported TrueType font: No Unicode or Symbol cmap table not    present. Aborting
Apr 2, 2015 6:53:55 PM org.apache.fop.events.LoggingEventListener    processEvent
WARNING: Unable to load font file: file:/C:/windows/FONTS/HelveticaNeue.ttf. Reason: java.io.IOException: TrueType font is not supported: file:/C:/windows/FONTS/HelveticaNeue.ttf

Apr 2, 2015 6:53:55 PM org.apache.fop.fonts.truetype.TTFFile getTTCnames
INFO: This is a TrueType collection file with 4 fonts

谢谢

推荐答案

(初步披露:我是 FOP 开发人员)

我是否正确无法使用 Windows 7 中的字体c:\windows\fonts* 使用 XSL-FO (Apache FOP) 生成 pdf 时?

Am I correct that it's not possible to use fonts from windows 7 c:\windows\fonts* when using XSL-FO (Apache FOP) to generate a pdf?

字体需要配置才能被 FOP 识别和使用,但配置可以真的简单:你可以告诉 FOP 查看所有字体特定目录中的文件(甚至递归),或者只是在常用"位置查找字体.

Fonts need to be configured in order to be recognised and used by FOP, but the configuration can be really simple: you can tell FOP to look at all the font files in a specific directory (even recursively), or simply to look for font in the "usual" places.

此配置片段取自相同的字体配置页面链接在您的问题中:

This configuration fragment is taken from the same font configuration page linked in your question:

<renderers>
  <renderer mime="application/pdf">
     <fonts>
        <!-- register all the fonts found in a directory -->
        <directory>C:\MyFonts1</directory>

        <!-- register all the fonts found in a directory and all of its sub directories (use with care) -->
        <directory recursive="true">C:\MyFonts2</directory>

        <!-- automatically detect operating system installed fonts -->
        <auto-detect/>
     </fonts>
  </renderer>
</renderers>

您可以在此答案中找到有关字体配置的其他详细信息.

You can find additional details concerning the font configuration in this answer.

更新,这仅适用于 ttf 字体,不适用于 otf.不知道我怎么能得到otf 字体.

Update, this works only for ttf font, not otf. Not sure how I can get otf fonts to work.

OpenType 字体支持已在 2.0 版中添加.

这篇关于XSL-FO:如何添加“helvetica neue"字体和输出到pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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