最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Apache Fop Font not found - Stack Overflow

programmeradmin4浏览0评论

I need a font that can handle glyphs like š,đ,ž,ć,č... and since Apache Fop doesn't have a single font that can handle these glyphs preinstalled I am trying to import new ones.

So far I tried all these options in fop.xconf:

<!-- register all the fonts found in a directory -->
<directory>C:\MyFonts1</directory>
    
<!-- register all the fonts found in a directory and all of its sub directories (use with care) -->
<directory recursive="true">C:\MyFonts2</directory>
    
<!-- automatically detect operating system installed fonts -->
<auto-detect/>

And it always ends up not loading the fonts.

This picture might help:

I need a font that can handle glyphs like š,đ,ž,ć,č... and since Apache Fop doesn't have a single font that can handle these glyphs preinstalled I am trying to import new ones.

So far I tried all these options in fop.xconf:

<!-- register all the fonts found in a directory -->
<directory>C:\MyFonts1</directory>
    
<!-- register all the fonts found in a directory and all of its sub directories (use with care) -->
<directory recursive="true">C:\MyFonts2</directory>
    
<!-- automatically detect operating system installed fonts -->
<auto-detect/>

And it always ends up not loading the fonts.

This picture might help:

Share Improve this question edited Mar 25 at 14:46 f_puras 2,5044 gold badges36 silver badges46 bronze badges asked Mar 25 at 14:27 Jura starčevićJura starčević 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

The problem was in fop.xconf not loading correctly.
I used to load it like this:

File configFile = new File("fop.xconf");
if (!configFile.exists()) {
    System.out.println("Config file not found: " + configFile.getAbsolutePath());
}

FopFactoryBuilder factoryBuilder = new FopFactoryBuilder(configFile.toURI());

In the end it would never load it.
So when you add this next code snippet behind the code above, it loads it correctly:

DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(configFile);

factoryBuilder.setConfiguration(cfg);

FopFactory fopFactory = factoryBuilder.build();

This ended up fixing the whole thing.

发布评论

评论列表(0)

  1. 暂无评论