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

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

问题描述

我正确的说,使用XSL-FO(Apache FOP)生成pdf文件时,无法使用windows 7 c:\ windows \ fonts *中的字体。



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

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



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



当使用支持系统字体的渲染器(参见上表),并且缺少字体时,可以将其安装在操作系统中,并且应该可用于这些渲染器。请注意,对于只支持自定义字体的输出格式,如PDF或PostScript,这种情况不适用。



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



--------------------------- ---更新,这只适用于ttf字体,而不是otf。
不知道如何让otf字体正常工作。

-------------------- ---------更新:20150402:使用FOP 1.1:

特定的免费helvetica neue字体从:
http:// www。 ephifonts.com/free-helvetica-font-helvetica-neue.html

我配置了fop来使用fop.xconf,但是我得到一个错误处理ttf文件,我不知道如何使用fontforge编辑字体ttf文件:



fop -c fop.xconf -xml xml.xml -xsl封面。 xsl -pdf output.pdf

  2015年4月2日6:53:55 org.apache.fop.fonts.truetype。 TTFFile readCMAP 
SEVERE:不支持的TrueType字体:不存在Unicode或符号cmap表不存在。正在中止
2015年4月2日6:53:55 org.apache.fop.events.LoggingEventListener processEvent
警告:无法加载字体文件:file:/ C:/windows/FONTS/HelveticaNeue.ttf 。原因:java.io.IOException:不支持TrueType字体:file:/ C:/windows/FONTS/HelveticaNeue.ttf

Apr 2,2015 6:53:55 PM org.apache.fop .fonts.truetype.TTFFile getTTCnames
INFO:这是一个包含4种字体的TrueType集合文件

谢谢

解决方案

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


当我使用XSL-FO(Apache FOP)时,我正确的说不能使用windows 7
c:\windows\fonts *中的字体)生成pdf?

需要配置字体需要以便被FOP识别和使用,但配置可以非常简单:您可以告诉FOP查看特定目录中的所有字体文件(甚至是递归的),或者只是在常规的地方寻找字体。 / p>

这个配置片段取自同一个字体配置页面链接到您的问题:

 <渲染> 
< renderer mime =application / pdf>
< fonts>
<! - 注册目录中的所有字体 - >
<目录> C:\MyFonts1< / directory>

<! - 注册目录及其所有子目录中的所有字体(小心使用) - >
< directory recursive =true> C:\MyFonts2< / directory>

<! - 自动检测操作系统安装的字体 - >
< auto-detect />
< / fonts>
< /渲染器>
< /渲染器>

您可以在

lockquote

更新,这只适用于ttf字体,而不适用于otf。不知道如何获得
otf字体。


OpenType字体支持已添加2.0版。


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?

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

According to https://xmlgraphics.apache.org/fop/trunk/fonts.html

"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.

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."

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?

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

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

Using FOP 1.1:

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

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

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

Thanks

解决方案

(preliminary disclosure: I'm a FOP developer)

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?

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.

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

OpenType fonts support has been added with version 2.0.

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

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