我用:沒有找到字體ARIAL.TTF與Apache FOP 1.0
- Apache防1.0
- 的Java
我需要有特殊字符,unicode是比U0100更高的處理。我應該使用的目標字體是Arial。因爲我不能指望Arial出現在目標平臺上(例如Linux),所以我在我的jar中嵌入了Arial.ttf。 我實際的配置文件看起來是這樣的:
<fop ...>
<!-- Base URL for resolving relative URLs -->
<base>./</base>
<!-- Font Base URL for resolving relative font URLs -->
<font-base>./</font-base>
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes" embed-url="arial.ttf" encoding-mode="auto">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
<!--<directory>C:/Windows/Fonts</directory>-->
</fonts>
<auto-detect/>
</renderer>
...
</fop>
這樣做,這樣我得到一個錯誤加載我的配置文件,以FOP:
org.apache.fop.apps.FOPException: Failed to resolve font with embed-url 'arial.ttf'
唯一的辦法我設法得到它的工作,直到現在是硬編碼文件夾路徑到配置文件:
<font kerning="yes" embed-url="C:/myapp/arial.ttf" encoding-mode="auto">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
但顯然這不能是解決方案!
使用「目錄」標籤在Windows上工作,只是因爲你有Arial。但是,如上所述,它也必須在Linux,Mac等上運行。
「自動檢測」標籤無法使用(即使不在Windows上) - 也不是解決方案,因爲我不能指望目標安裝了Arial的平臺。
任何建議來解決這個問題?
如果這是正確的答案,你可以接受你自己的答案。 – 2012-11-19 15:52:59