字体扩展名不适用于JasperReports [英] Font extensions does not work for JasperReports

查看:397
本文介绍了字体扩展名不适用于JasperReports的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Tahoma字体添加到我的网络应用中的jasper报告中。我使用字体扩展机制

I am trying to add Tahoma font to jasper report in my web app. I use font extension mechanism.

抛出此异常:
net.sf.jasperreports.engine.util.JRFontNotFoundException:字体TahomaFont不可用于JVM。有关详细信息,请参阅Javadoc。

This exception was thrown: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'TahomaFont' is not available to the JVM. See the Javadoc for more details.

这是我的font.xml文件:

Here is my font.xml file:

<fontFamiles>
  <fontFamily name="TahomaFont">
    <normal>export/fonts/BTahoma.ttf</normal>
    <pdfEncoding>Identity-H</pdfEncoding>
    <pdfEmbedded>true</pdfEmbedded>
  </fontFamily>
<fontFamiles>

这是我的jasperreports.properties文件:

and here is my jasperreports.properties file :

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.TahomaFont=export/fonts/fonts.xml

此外,我已将Tahoma.ttf字体文件放入我的类路径中。
以下是jasper报告中的样式标记:

Also i have put Tahoma.ttf font file in my classpath. Here is the style tag in jasper report:

<style fontName="TahomaFont" name="tahoma"/>

请告诉我哪里出错了。在此先感谢。

Please let me know where i am going wrong. Thanks in advance.

推荐答案

将Tahoma.ttf字体放在类路径中的方式去吧。

Putting the Tahoma.ttf font in your class path is not the way to go.

你使用字体扩展是正确的,这是一个很好的做法 - 但是你需要将你的字体作为字体扩展包装到一个jar中并将该jar添加到你的类路径。

You are right to use font extensions, it's a good practice - but you need to package your fonts as font extension, into a jar and add that jar to your classpath.


  • 在jasperReport中,在字体中 中管理你的字体选项卡,选择字体,然后单击导出为扩展名

  • 打包您的jar,事情应该正常工作,而无需在JVM上安装物理字体。

  • In jasperReport, manage your fonts, in options, in the Font tab, select the font and click export as extension.
  • Package your jar and things should work fine without having to install the physical font on the JVM.

更多信息记录此处

这篇关于字体扩展名不适用于JasperReports的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆