Apache FOP 2.2使用相对路径包含字体

我正在设置一个fop.xconf并配置哪些字体可用于Apache FOP,并希望使用相对路径而不是绝对路径:

 <fop version="1.0"> <strict-configuration>true</strict-configuration> <strict-validation>true</strict-validation> <base>./</base> <font-base>./</font-base> <source-resolution>72</source-resolution> <target-resolution>72</target-resolution> <default-page-settings height="11in" width="8.26in"/> <hyphenation-pattern lang="en" country="ZA">en_ZA</hyphenation-pattern> <renderers> <renderer mime="application/pdf"> <fonts> <directory recursive="true">/Users/me/Code/company/project/src/main/resources/templates/fonts</directory> <substitutions> <substitution> <from font-family="Helvetica" /> <to font-family="OpenSans" /> </substitution> </substitutions> </fonts> </renderer> </renderers> </fop> 

是否有可能设置渲染器内的字体目录使用相对路径?

或者有可能以编程方式设置,在这种情况下,我可以利用

 this::class.java.getResource("/templates/fonts/MyFont.ttf") 

得到完整的路径?

 2017-10-24 05:24:48,591 WARN org.apache.fop.apps.FOUserAgent - The font directory ./fonts could not be found. 2017-10-24 05:24:48,591 WARN org.apache.fop.apps.FOUserAgent - The font directory ./templates/fonts could not be found. 2017-10-24 05:24:48,591 WARN org.apache.fop.apps.FOUserAgent - The font directory ./resources/templates/fonts could not be found. 

Interesting Posts