请帮帮我, 我对fop pdf生成有两个疑问
如何在基于FOP的pdf生成中包含font-awesome图标或utf字符
根据值应用颜色。
请帮帮我
接受任何建议。
答案 0 :(得分:3)
您可以像使用任何其他字体一样使用Font Awesome:
font-family
(或fo:block
,...)上设置fo:inline
属性font-family
值映射到Font Awesome发行版中包含的TrueType字体文件对于颜色,您可以使用属性color
和background-color
来设置字形字体颜色和背景颜色。
使用FOP 2.0测试的一个例子:
FO片段
<fo:block>
Icons:
<fo:inline font-family="FontAwesome">
   
</fo:inline>
</fo:block>
<fo:block>
Coloured icons:
<fo:inline font-family="FontAwesome" color="#AA0000">
   
</fo:inline>
</fo:block>
<fo:block>
Coloured icons with background:
<fo:inline font-family="FontAwesome" color="#FFFFFF" background-color="#AA0000">
   
</fo:inline>
</fo:block>
FOP配置片段:
<renderer mime="application/pdf">
...
<fonts>
<font embed-url="/Users/furini/font-awesome-4.4.0/fonts/fontawesome-webfont.ttf">
<font-triplet name="FontAwesome" style="normal" weight="normal"/>
</font>
...
</fonts>
...
</renderer>
<强>输出:强>
请注意,您会收到警告,但无需担心(它只是告诉您Font Awesome没有默认连字符的字形,但您不会使用带图标的连字符!):
25-ott-2015 13.31.38 org.apache.fop.fo.properties.CommonHyphenation getHyphChar
WARNING: Substituted specified hyphenation character (0x2d) with 0x20 because the font doesn't have the specified hyphenation character: FontAwesome,normal,400
(this old answer of mine提供了有关字体配置和错误/警告的更多详细信息)
(披露:我是FOP开发人员,但现在不是很活跃)