最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Docbook中用fop生成pdf过程中出现警告:warning: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400"

Docbook crifan 3118浏览 0评论

【问题】

docbook中已经用xsltproc生成了fo,现去用fop将fo转换为pdf,过程中出现警告:

Administrator@K470 /cygdrive/e/Dev_Root/docbook/dev/books/VBR/src
$ E:/Dev_Root/docbook/tools/fop-1.0/fop.cmd -c E:/Dev_Root/docbook/dev/config/fop/conf/fop.xconf ../output/fo/MPEG_VBR.fo -pdf ../output/pdf/MPEG_VBR.pdf
五月 12, 2012 9:58:29 上午 org.apache.fop.apps.FopFactoryConfigurator configure
信息: Default page-height set to: 11in
五月 12, 2012 9:58:29 上午 org.apache.fop.apps.FopFactoryConfigurator configure
信息: Default page-width set to: 8.26in
五月 12, 2012 9:58:31 上午 org.apache.fop.events.LoggingEventListener processEvent
警告: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".
五月 12, 2012 9:58:31 上午 org.apache.fop.events.LoggingEventListener processEvent
警告: Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400".
五月 12, 2012 9:58:31 上午 org.apache.fop.hyphenation.Hyphenator getHyphenationTree
严重: Couldn't find hyphenation pattern zh_cn
五月 12, 2012 9:58:34 上午 org.apache.fop.events.LoggingEventListener processEvent
警告: Line 2 of a paragraph overflows the available area by 28837 millipoints. (See position 105:732)

现在想要搞懂其含义,如果能解决掉,就尽量解决掉。

【解决过程】

1.找到这里:Re: Font warnings during docbook build,其解释了700和400的含义:

700 = bold,400=normal

所以,上述警告的含义就很清楚了,即没有找到bold类型的Symbol,ZapfDingbats字体,然后取而代之用normal字体代替。

所以,那人说可以忽略此warning。

2.但是我此处,貌似没有设置这两种字体,只是设置了雅黑字体:

<xsl:param name="title.font.family">msyhbd</xsl:param>
<xsl:param name="body.font.family">msyh</xsl:param>
<xsl:param name="monospace.font.family">msyh</xsl:param>

所以,还是想要搞清楚,到底是哪里设置了这两种字体。

关于fop中配置已有字体的,是fop.xconf,然后去其中找了下,也没发现Symbol和ZapfDingbats字体。

3.又参考:Converting an xml file with xsltproc/fop (was: Re: [docbook] DocBook SGML article and titlepage, + remove header),打算去fop.xconf中添加substitution部分的内容,结果无意间就看到了,原来本身该文件中,就有对700和400的解释:

        possible styles: normal | italic | oblique | backslant
        possible weights: normal | bold | 100 | 200 | 300 | 400
                          | 500 | 600 | 700 | 800 | 900
        (normal = 400, bold = 700)

另外也说了,如果对于不想要把字体嵌入pdf中的话,那么在写就不要添加embed-url这个属性,即可。

在添加substitutions之前,去搜了下fop substitutions,然后找到FOP的官网解释的部分:

Apache™ FOP: Fonts,然后得知,原来Symbol和ZapfDingbats,都是属于Base-14 font,其是pdf规范规定的,不论哪个pdf reader都应该支持的字体,对于fop来说,是“hard-coded ”到fop里面的了。

然后其也解释了,和上面那个人说的一样的,关于Substitution的部分的含义。

然后照葫芦画瓢去添加了:

      <substitutions>
         <substitution>
            <from font-family="Symbol"/>
            <to font-family="msyh"/>
         </substitution>
         <substitution>
            <from font-family="ZapfDingbats"/>
            <to font-family="msyh"/>
         </substitution>
      </substitutions>
        

期望将Symbol和ZapfDingbats都替换为微软雅黑msyh,结果fop运行结果,还是同样的警告:

Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".

然后有去试了试:

         <substitution>
            <from font-family="Symbol" font-weight="bold" font-style="normal" />
            <to font-family="msyh"/>
         </substitution>

和:

         <substitution>
            <from font-family="Symbol" font-weight="700" font-style="normal" />
            <to font-family="msyh" font-weight="bold" font-style="normal" />
         </substitution>

以及:

      <substitutions>
        <substitution>
            <from font-family="Symbol" font-weight="700"/>
            <to font-family="Symbol" font-weight="400"/>
        </substitution>
        <substitution>
            <from font-family="ZapfDingbats" font-weight="700"/>
            <to font-family="ZapfDingbats" font-weight="400"/>
        </substitution>
      </substitutions>

结果页还是不行。

所以,貌似此配置没有生效。不知道为何。

4.去查看那个fo文件,发现里面有类似这样的内容:

<fo:block text-align="center" font-size="24.8832pt" space-before="18.6624pt" font-weight="bold" font-family="msyhbd,Symbol,ZapfDingbats">

所以,猜测可能是里面带了bold,然后bold属性应用到Symbol中了,所以由此warning了。

猜想可能是之前xsl中,虽然指定了字体,但是对于某些其他部分没有指定,所以其他某些内容,会被系统字体的Symbol等字体,所以生成的fo中才会有这两个字体的。但是好像是不论如何设置,都还是会有这个warning的。

5.后来找到这里:

fop: WARNING: Cannot Find a Base-14 Font (docbook bug?)

然后有人解释了此问题的现象,的确是,即使你正确指定了字体,而且所有内容都可以之用该字体显示,比如

所有内容都可以用"sans-serif,Symbol,ZapfDingbats". 中的sans-serif表示了,但是由于本身Symbol bold和ZapfDingbats bold不存在,所以结果还是会提醒你上述warning的。

这样看来,那的确是一个bug,虽然不严重,但是会误导用户,至少我就被误导了。

然后又参考Bela的解释,去看:

symbol.font.family

然后把:

<xsl:param name="symbol.font.family">微软雅黑</xsl:param>

加入到我的xsl中,然后再运行fop,结果就的确消除了此warning了。

同时,也才看懂,这个Symbol,不是一种字体,而是和之前的title,body,monospace并列的,指的是符号所用的字体。这也就是我之前所猜想的“但是对于某些其他部分没有指定,所以其他某些内容,会被系统字体的Symbol等字体,所以生成的fo中才会有这两个字体的。”

然后,就接着去找,所有的font.family的相关项,有哪些,找到了,在这里:

Font Families

中的:

body.font.family — The default font family for body text
dingbat.font.family — The font family for copyright, quotes, and other symbols
monospace.font.family — The default font family for monospace environments
sans.font.family — The default sans-serif font family
title.font.family — The default font family for titles
symbol.font.family — The font families to be searched for symbols outside of the body font

所以,以后如果再有font类型的问题,就可以好好去看看这几个相关参数的设置了。

【总结】

折腾半天,终于搞定此问题。也更加清楚了,docbook中,如何去设置不同部分(title,body等)的字体。也明白了,此警告:

Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".

Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400".

其实是docbook相关的fop中做的不够好,不应该出现此警告才对,也算是一个bug了。

而如果真的想要消除此warning,添加相关symbol的字体的设置就可以了

<xsl:param name="symbol.font.family"></xsl:param>

其中也可以设置为你自己想要的某种字体,比如我这里的:

<xsl:param name="symbol.font.family">微软雅黑</xsl:param>

转载请注明:在路上 » 【已解决】Docbook中用fop生成pdf过程中出现警告:warning: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400"

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.160 seconds, using 21.99MB memory