假设我正在使用Apache FOP创建PDF文件。PDF中的所有字符都应为Times New Roman Italic
。由于我的系统中没有这样的字体,因此Apache FOP将尝试在/ data / fonts中查找由fop.xconf设置的字体。
<directory>/data/fonts</directory>
但是,/ data / fonts中只有一个文件,即Times New Roman Regular.ttf
。是的,不Times New Roman Italic.ttf
,也不Times New Roman Bold.ttf
。
ls /data/fonts
'Times New Roman Regular.ttf'
在这种情况下,Apache FOP报告它找不到Times New Roman Italic
字体,并且回退到默认字体,默认字体也不是Times New Roman
,也不是斜体。
我可以通过Times New Roman Italic.ttf
输入/ data / fonts来解决问题,但是如果我没有该字体的特定斜体/粗体字怎么办?AFAIK有些字体根本没有特定的粗体/斜体版本。即使结果不如特定的斜体/粗体字样,Apache FOP是否可以从常规字体自动创建斜体/粗体字样?
如果使用的是FOP 2.2版,则有一个配置选项可以自动创建模拟的斜体和粗体字形:simulate-style
。
这个例子中,四个组合的映射style
和weight
到同一TrueType字体,加粗并在需要时倾斜的字形:
<font kerning="yes" embed-url="Times.ttf" simulate-style="true">
<font-triplet name="Times" style="normal" weight="normal"/>
<font-triplet name="Times" style="italic" weight="normal"/>
<font-triplet name="Times" style="normal" weight="bold"/>
<font-triplet name="Times" style="italic" weight="bold"/>
</font>
注意,注册所有不同的font-triplet
元素很重要;如果只有<font-triplet name="Times" style="normal" weight="normal"/>
字体替换机制,则将首先将粗体,斜体和粗斜体映射到已注册的普通变体,然后FOP将模拟样式(不执行任何操作)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句