fop pdf generation with font awesome 图标
fop pdf generation with font awesome icon
请帮帮我,
我对fop pdf生成有两个疑惑
如何在基于 FOP 的 pdf 生成中包含超棒的字体图标或 utf 字符
根据值应用颜色。
请帮帮我
接受任何建议。
您可以像使用任何其他字体一样使用 Font Awesome:
- 在FO文件中,在包含你需要的Unicode entities for the icons的
fo:block
(或fo:inline
, ...)上设置font-family
属性
- create/edit 一个 FOP 配置文件,用于将
font-family
值映射到 Font Awesome 发行版中包含的 TrueType 字体文件
- 告诉 FOP 使用您的配置文件
至于颜色,可以使用属性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 提供了一些关于字体配置的更多细节和你可以获得的 errors/warnings)
(披露:我是一名 FOP 开发人员,虽然现在不是很活跃)
请帮帮我, 我对fop pdf生成有两个疑惑
如何在基于 FOP 的 pdf 生成中包含超棒的字体图标或 utf 字符
根据值应用颜色。
请帮帮我
接受任何建议。
您可以像使用任何其他字体一样使用 Font Awesome:
- 在FO文件中,在包含你需要的Unicode entities for the icons的
fo:block
(或fo:inline
, ...)上设置font-family
属性 - create/edit 一个 FOP 配置文件,用于将
font-family
值映射到 Font Awesome 发行版中包含的 TrueType 字体文件 - 告诉 FOP 使用您的配置文件
至于颜色,可以使用属性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 提供了一些关于字体配置的更多细节和你可以获得的 errors/warnings)
(披露:我是一名 FOP 开发人员,虽然现在不是很活跃)