2015-03-31 151 views
0

我正确的说,使用XSL-FO(Apache FOP)生成时,无法使用Windows 7中的字体c:\ windows \ fonts *一个pdf?XSL-FO:如何添加“helvetica neue”字体并输出为pdf

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

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

“系统字体的支持依靠的字体度量信息在Java AWT子系统,通过操作系统注册,AWT子系统知道哪些字体在系统上可用,并且字体指标

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

如果我的理解是正确的,就是说如果我的渲染是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 coversheet.xsl -pdf输出。 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 

感谢

+0

你已经试过了吗?但是我会说你的解释是正确的,在渲染PDF时没有办法访问系统字体。但是,您仍然可以在FOP配置中将Helvetica Neue注册为自定义字体。 – 2015-03-31 22:04:43

+0

我试过了,能够插入ttf格式的字体,但是我不能输出otf字体文件。我认为这个文档已经过时了。 – Derick 2015-03-31 23:37:25

+0

那么为什么不将OTF字体转换为TTF,然后将其用作自定义字体呢? – 2015-04-01 08:51:46

回答

0

(初步公开:我是一个FOP开发商)

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查看特定目录中的所有字体文件(甚至递归)或s意味着在“平常”的地方寻找字体。

此配置片段是从你的问题联同font configuration page采取:

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

你可以找到关于this answer字体配置的其它详情。

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

OpenType字体支持已添加到版本2.0中。

+0

已下载www.ephifonts.com/free-helvetica-font-helvetica-neue.html但出现错误:org.apache.fop.fonts.truetype.TTFFile readCMAP SEVERE:不支持的TrueType字体:无Unicode或符号cmap表不存在。正在中止 org.apache.fop.events.LoggingEventListener processEvent 警告:无法加载字体文件:file:/ C:/windows/FONTS/HelveticaNeue.ttf。原因:java.io.IOException:不支持TrueType字体:file:/ C:/windows/FONTS/HelveticaNeue.ttf org.apache.fop.fonts.truetype.TTFFile getTTCnames 请参阅上面的更新。不知道如何使用字体伪造来编辑 – Derick 2015-04-03 02:06:25

+0

免费helvetica neue字体来自http://www.ephifonts.com/free-helvetica-font-helvetica-neue.html,但显然,它不适用于fop 1.1 – Derick 2015-04-03 02:21:28

+0

lfurini,我只是想和你确认一下,当你说“在FOP-1.1发布之后添加了OTF支持”时,这意味着fop 1.1将支持otf,无论我是否获得每晚构建。我下载了最新的稳定版本。 – Derick 2015-04-03 02:28:24

相关问题