如何在ApacheFop中从Java代码配置字体?

如何在ApacheFop中从Java代码配置字体?,java,fonts,apache-fop,Java,Fonts,Apache Fop,声明说,从java代码配置字体“不容易”。我如何做到这一点? 我在从法语和日语等国际语言渲染某些HTML时遇到问题 WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400". May 08, 2015 4:45:39 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "ZapfDingbats,

声明说,从java代码配置字体“不容易”。我如何做到这一点? 我在从法语和日语等国际语言渲染某些HTML时遇到问题

WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".
May 08, 2015 4:45:39 PM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400". 
因此,生成的PDF已损坏

更新

我的Html包含法语单词,如“ModifiéCrée le Propriétaire”

我正在使用Antenahouse提供的XSLT将HTML标记转换为FO标记。

示例代码

/** The Constant FOP_CONFIG. */
    private static final String FOP_CONFIG = "pdf.fop.cfg.xml";

fopFactory = FopFactory.newInstance();
                    // for image base URL
                    String serverPath = request.getSession().getServletContext().getRealPath("/");
                    //disable strict validatetion
                    fopFactory.setStrictValidation(false);
                    fopFactory.setBaseURL(serverPath);
                    // for fonts base URL
                    fopFactory.getFontManager().setFontBaseURL(serverPath);
                    // read custom font setting
                    StreamSource configSrc = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(PDFComponentFactory.FOP_CONFIG));
                    DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
                    Configuration cfg = cfgBuilder.build(configSrc.getInputStream());
                    fopFactory.setUserConfig(cfg);

希望它能对您有所帮助。

您能发布您的代码吗?我已经更新了它…“已损坏”并不是问题的真实描述,生成的PDF有什么问题使您得出它已损坏的结论?可能会有所帮助;请注意,从发布的错误消息中,问题不是来自法语重音字符,而是来自一些符号和Wingdings标志符号(可能使用sa bullet points?),您可以使用配置文件中的元素,它告诉FOP查看操作系统的默认字体文件夹。
/** The Constant FOP_CONFIG. */
    private static final String FOP_CONFIG = "pdf.fop.cfg.xml";

fopFactory = FopFactory.newInstance();
                    // for image base URL
                    String serverPath = request.getSession().getServletContext().getRealPath("/");
                    //disable strict validatetion
                    fopFactory.setStrictValidation(false);
                    fopFactory.setBaseURL(serverPath);
                    // for fonts base URL
                    fopFactory.getFontManager().setFontBaseURL(serverPath);
                    // read custom font setting
                    StreamSource configSrc = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(PDFComponentFactory.FOP_CONFIG));
                    DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
                    Configuration cfg = cfgBuilder.build(configSrc.getInputStream());
                    fopFactory.setUserConfig(cfg);