0. 在Linux下,在$Cocoon_Home/build/webapp/WEB-INF目录下创建目录fop-fonts,把windows下的c:\windows\fonts\arialuni.ttf文件复制到的刚创建的目录下
1. 生成font(s) metric file(s).
jiad4701@urts96:~/src/cocoon-2.1.9/build/webapp/WEB-INF>java -cp build/fop.jar:lib/avalon-framework-cvs-20020806.jar:lib/xml-apis.jar:lib/xercesImpl-2.2.1.jar:lib/xalan-2.4.1.jar org.apache.fop.fonts.apps.TTFReader /home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/fop-fonts/arialuni.ttf /home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/fop-fonts/
arialunittf
.xml
TTF Reader v1.1.1
Reading /home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/fop-fonts/arialuni.ttf...
Number of glyphs in font: 50377
Postscript format 3
Creating xml font file...
Creating CID encoded metrics
Writing xml font file /home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/fop-fonts/
arialunittf
.xml...
This font contains no embedding license restrictions
2. 为Cocoons PDF renderer创建配置文件,该配置告诉Cocoons PDF renderer有哪些字体可用,在什么位置可以找到可用的字体
创建文件 fop-config.xml:
<configuration>
<fonts>
<font metrics-file="/home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/fop-fonts/arialunittf.xml"
kerning="yes" embed-file="/home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/fop-fonts/arial.ttf">
<font-triplet name="Arial Unicode MS" style="normal" weight="normal"/>
<font-triplet name="Arial Unicode MS" style="normal" weight="bold"/>
<font-triplet name="Arial Unicode MS" style="italic" weight="normal"/>
<font-triplet name="Arial Unicode MS" style="italic" weight="bold"/>
</font>
<font metrics-file="pathto/arialb.ttf.xml"
kerning="yes" embed-file="pathto/arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</fonts>
</configuration>
3. 修改sitemap.xmap文件, 使fo2pdf serializer 能找到配置文件
<map:serializer name="fo2pdf"
xsrc="org.apache.cocoon.serialization.FOPSerializer" mce_src="org.apache.cocoon.serialization.FOPSerializer"
mime-type="application/pdf">
<user-config>/home/jiad4701/src/cocoon-2.1.9/build/webapp/WEB-INF/config.xml</user-config>
</map:serializer>
注意:
回复删除-cp 或者-classpath 在给出多个目录时,在windows下用分号 ; 隔开,在Linux下用冒号 : 隔开。