【问题标题】:FOP- 1.1 Adding new FontsFOP- 1.1 添加新字体
【发布时间】:2015-10-21 09:16:22
【问题描述】:

我正在尝试使用 XSL 样式表生成 pdf
和一个带有 fop.bat 的 XML 文件(我使用的是 1.1 版本)。现在我需要在我的 FOP 中添加一个自定义字体,但我似乎不起作用。我只有一个字体的 TTF 文件并已经安装了它。我试图将字体添加到 Confi 文件中,但也许我做错了。我试图给出路径(C:\Windows\Fonts\Trade Gothic bd.ttf)并使用,但我仍然无法在样式表中使用字体系列,它会回滚到 TimesNewRoman。

       <font kerning="yes" embed-url="'C:/Windows/Fonts/Trade Gothic bd.ttf'" embedding-mode="subset">
           <font-triplet name="TradeGothic" style="normal" weight="normal"/>
   </font>

来自命令行的消息

WARNUNG: Font "TradeGothic,normal,400" not found. Substituting with "any,normal,400".
Okt 21, 2015 11:10:10 AM org.apache.fop.events.LoggingEventListener processEvent

这些行来自我的样式表

        <fo:block color="rgb(0,108,183)" font-family="TradeGothic" font-style="normal" font-weight="normal">
                <xs:value-of select="headdescription"/>
            </fo:block>

谁能给我一个关于如何添加字体的分步介绍?还是对我的尝试进行更正?

【问题讨论】:

  • 您是否正在调用 FOP(从命令行或代码)而没有告诉它使用您的配置文件?
  • 我没有特别告诉命令行这样做,因为它是刚刚编辑的普通配置文件。我尝试了以下方法: C:\Users\alisch\Desktop\xml xsl test>fop.bat -xml "C:\Users\alisch\Desktop\xml x sl test\test\xmltest.xml" -xsl "C: \Users\alisch\Desktop\xml xsl test\test\xsltes t.xsl" -pdf zpdf.pdf -c "C:\Users\alisch\Desktop\xml xsl test\conf\fop.xconf" 并命名该conf文件但还是一样。

标签: css xslt fonts apache-fop custom-font


【解决方案1】:

我找到了解决问题的方法!

我需要在 conf 文件中添加 (fop.xconf) :

 <font kerning="yes" embedurl="/Users/alisch/desktop/TradeGothicbold.ttf" embedding-mode="subset">
    <font-triplet name="TradeGothic" style="normal" weight="bold"/>
    </font>
    <directory>/Users/alisch/desktop/TradeGothicbold.ttf</directory>

在:

之间
 <renderer mime="application/pdf">
 <fonts>

  </fonts>
</renderer>

之后我需要添加

 -c "C:\Users\alisch\Desktop\xml xsl test\conf\fop.xconf"

到我的命令行,它工作了!

【讨论】:

  • embedurl 属性应该是 embed-url (但也许只是一个错字); directory 元素应指向 目录,而不是单个字体文件,并且 if 它有任何效果,因为已配置相同的字体文件,所以它是多余的font 元素。
  • 是的,谢谢,你是对的!该目录是不必要的,是的,这是一个错字,我不得不搜索一段时间!
猜你喜欢
  • 2013-11-23
  • 2014-12-30
  • 2018-06-17
  • 2013-07-18
  • 1970-01-01
  • 1970-01-01
  • 2021-01-16
  • 1970-01-01
  • 2012-10-28
相关资源
最近更新 更多