首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FOP-2.6自定义字体不以PDF格式呈现

FOP-2.6自定义字体不以PDF格式呈现
EN

Stack Overflow用户
提问于 2022-06-14 07:50:26
回答 1查看 202关注 0票数 1

在更新到FOP2.6之后,当尝试使用Apache使用自定义字体GT超级显示时,我得到了以下错误。

代码语言:javascript
运行
复制
org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".
org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400".
org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "Arial,normal,700" not found. Substituting with "any,normal,700".
org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "GTSuperDisplayLight,normal,700" not found. Substituting with "any,normal,700".

配置文件:

代码语言:javascript
运行
复制
<fonts>
   <!-- automatically detect operating system installed fonts -->
    <auto-detect/>  
    <!-- embedded fonts -->
    <!--
    This information must exactly match the font specified
    in the fo file. Otherwise it will use a default font.

    For example,
    <fo:inline font-family="Arial" font-weight="bold" font-style="normal">
        Arial-normal-normal font
    </fo:inline>
    for the font triplet specified by:
    <font-triplet name="Arial" style="normal" weight="bold"/>

    If you do not want to embed the font in the pdf document
    then do not include the "embed-url" attribute.
    The font will be needed where the document is viewed
    for it to be displayed properly.

    possible styles: normal | italic | oblique | backslant
    possible weights: normal | bold | 100 | 200 | 300 | 400
                      | 500 | 600 | 700 | 800 | 900
    (normal = 400, bold = 700)
    -->
    <font kerning="yes" embed-url="GTSuperDisplayLight.ttf" embedding-mode="subset">
        <font-triplet name="GTSuperDisplayLight" style="normal" weight="700" />
    </font>
</fonts>

编辑:添加Java文件,它调用Configuarion并选择安装在用户计算机上的字体,但是可以指定自定义字体。请参阅Apache FOP官员。

代码语言:javascript
运行
复制
         /*
              * Register Apache FOP to use our fonts. By default we set this config file to auto-detect the fonts
         */
            File xconf = new File( getConfigFileURI( xslFullName ) );
            FopConfParser parser = new FopConfParser( xconf ); //parsing configuration
            FopFactoryBuilder builder = parser.getFopFactoryBuilder(); //building the factory with the user options
            fopFactory = builder.build();


            fopFactory = FopFactory.newInstance( new File( "." ).toURI() );

            foUserAgent = fopFactory.newFOUserAgent();
            bufferedOutputStream = new FileOutputStream( pdfFilename );
            bufferedOutputStream = new BufferedOutputStream( 
            bufferedOutputStream );


           private String getConfigFileURI( String xslFilePath )
           {
               File f = new File( xslFilePath );
               String configFileURI = f.getParent() + "/userconfig.xml";

               return configFileURI;
           }
EN

回答 1

Stack Overflow用户

发布于 2022-08-07 16:14:13

这个问题用JDK 11解决了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72613284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档