我已经创建了一个项目。并创建了文件夹层次结构,如 xml->conf->font
在conf文件夹中我放置了我的XCONF文件,在font文件夹中我放置了我的字体(ttf文件)
现在我想引用 XCONF 文件中的字体。请给我解决方案: 我的 XCONF 文件
<?xml version="1.0" encoding="utf-8" ?>
<fop>
<renderers>
<renderer mime="application/pdf">
<fonts>
<directory>/font</directory>
<directory recursive="true">/font</directory>
<auto-detect/>
<font embed-url="/font/grotesque-mt-1361500685.ttf">
<font-triplet name="GrotesqueMT" style="normal" weight="normal"/>
</font>
<font embed-url="/font/grotesquemt-light.ttf">
<font-triplet name="GrotesqueMT-Light" style="normal" weight="normal"/>
</font>
<font embed-url="/font/grotesquemt-bold.ttf">
<font-triplet name="GrotesqueMT-Bold" style="normal" weight="bold"/>
</font>
</fonts>
</renderer>
我收到以下异常: 无法解析嵌入 url 的字体 '/font/grotesque-mt-1361500685.ttf
最佳答案
您可以尝试embed-url="./font/...ttf"
或embed-url="font/...ttf"
。前导/通常标识绝对 URL。您的 URL 指向文件系统根目录下的字体目录。
最诚挚的问候,Majo
关于java - 如何在 xml 文件中给出当前目录路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30774605/