简体   繁体   English

FOP-2.6 自定义字体未在 PDF 中呈现

[英]FOP-2.6 Custom Font are Not rendered in PDF

After updating to FOP 2.6, while trying to use Apache FOP to use custom fonts GT Super Display Light, I am getting below error.更新到 FOP 2.6 后,在尝试使用 Apache FOP 来使用自定义 fonts GT 超级显示灯时,我遇到了以下错误。

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".

Configuration file:配置文件:

<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>

Edit: adding Java File Which Calls Configuarion File and picks fonts installed on the user's computer, but custom fonts can be specified.编辑:添加 Java 文件,该文件调用配置文件并选择安装在用户计算机上的 fonts,但可以指定自定义 fonts。 Please refer to Apache FOP official请参考Apache FOP官方


         /*
              * 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;
           }

This Issue got resolved with JDK 11 JDK 11 解决了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM