Jasper 不再寻找一种字体
将 Jasper 升级到最新版本后,它不再找到一种字体:Symbol。其余的字体看起来都不错。我在与运行 jasper 的目录相同的目录中有一堆 ttfs,该程序只是一个生成 PDF 的小包装器,并且它抛出此错误:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Symbol' is not available to the JVM. See the Javadoc for more details.
at net.sf.jasperreports.engine.util.JRFontUtil.checkAwtFont(JRFontUtil.java:358)
at net.sf.jasperreports.engine.util.JRStyledText.getAwtAttributedString(JRStyledText.java:226)
at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:362)
at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:1129)
at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:183)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:329)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:419)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:378)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2028)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:757)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:127)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
at XmlJasperInterface.report(XmlJasperInterface.java:82)
at XmlJasperInterface.main(XmlJasperInterface.java:60)</pre>
程序运行的目录:
# ls *.ttf
arial.ttf arialbd.ttf lsans.ttf lsansd.ttf lsansi.ttf symbol.ttf
找到所有其他字体。哦,在我的笔记本电脑(macosx)中,它工作正常,它只在服务器(Debian)上崩溃。我打开了 symbol.ttf,它在 Mac OS X 上可以正常打开(以防文件损坏)。
有什么想法可能会发生什么吗?
After upgrading Jasper to the last version, it stopped finding one font: Symbol. The rest of the fonts seem to be fine. I have a bunch of ttfs in the same directory as where jasper is run, the program is just a small wrapper to generate PDFs, and it's throwing this error:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Symbol' is not available to the JVM. See the Javadoc for more details.
at net.sf.jasperreports.engine.util.JRFontUtil.checkAwtFont(JRFontUtil.java:358)
at net.sf.jasperreports.engine.util.JRStyledText.getAwtAttributedString(JRStyledText.java:226)
at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:362)
at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:1129)
at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:183)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:329)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:419)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:378)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2028)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:757)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:127)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
at XmlJasperInterface.report(XmlJasperInterface.java:82)
at XmlJasperInterface.main(XmlJasperInterface.java:60)</pre>
The directory where the program is running:
# ls *.ttf
arial.ttf arialbd.ttf lsans.ttf lsansd.ttf lsansi.ttf symbol.ttf
All other fonts are found. Oh, in my laptop (macosx), it works fine, it only breaks on the server (Debian). I opened symbol.ttf and it opened fine on Mac OS X (just in case the file was corrupt).
Any ideas what may be going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
行添加
尝试将
net.sf.jasperreports.awt.ignore.missing.font=true
到您的 jasperreports.properties 文件中。
Try adding the line
net.sf.jasperreports.awt.ignore.missing.font=true
to your jasperreports.properties file.
在 ubuntu 上,我需要卸载字体并重新安装它们:
然后,它就可以正常工作了。
On ubuntu I needed to uninstall the fonts and reinstall them:
Then, it works ok.
那么该字体必须安装在运行报告的操作系统中。
Well the font must be installed in the OS where the report run.
解决这个问题的简单步骤是
问题解决了。
The easy steps to solve this problem would be
The problem is solved.
我正在使用 JasperReports 6.3.1。我通过在
.jrxml
中添加以下行解决了该问题:这样,我们的报告看起来会有所不同,具体取决于系统中预安装的字体。就我而言,它并不代表问题,而且我对在我的项目中添加额外的字体不感兴趣,因为我需要尽可能轻。
如果您想在所有运行时环境中使用报表的原始字体,一个简单的解决方案是将必要的依赖项添加到项目中。
以 Maven 为例:
您还可以下载库并将它们手动添加到项目中,但它会起作用。
我希望您发现它们很有用。
I'm using JasperReports 6.3.1. I solved the problem by adding the following line in my
.jrxml
:This way our report will look something different, depending on the fonts that are preinstalled in the system. In my case it does not represent a problem, and I'm not interested in adding an extra font in my project, since I need to be as light as possible.
In case you want to use the original fonts of the report in all runtime environments, an easy solution is to add the necessary dependencies to the project.
An example, for Maven:
You can also download the libraries and add them manually to the project, however it will work.
I hope you find them useful.
2015 年更新:
将其添加到(或取消注释)/etc/apt/sources.list
然后运行:
Update for year 2015:
Add this to (or uncomment in) /etc/apt/sources.list
Then run this: