Jasper 不再寻找一种字体

发布于 2024-09-28 03:44:57 字数 2111 浏览 3 评论 0原文

将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

酒废 2024-10-05 03:44:57

行添加

尝试将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.

指尖上得阳光 2024-10-05 03:44:57

在 ubuntu 上,我需要卸载字体并重新安装它们:

sudo apt-get remove  ttf-mscorefonts-installer
sudo apt-get install  ttf-mscorefonts-installer

然后,它就可以正常工作了。

On ubuntu I needed to uninstall the fonts and reinstall them:

sudo apt-get remove  ttf-mscorefonts-installer
sudo apt-get install  ttf-mscorefonts-installer

Then, it works ok.

傲世九天 2024-10-05 03:44:57

那么该字体必须安装在运行报告的操作系统中。

Well the font must be installed in the OS where the report run.

z祗昰~ 2024-10-05 03:44:57

解决这个问题的简单步骤是

  1. 打开 jasperreports-xxxjar,在我的例子中是 jasperreports-3.7.2.jar。
  2. 找到 default.jasperreports.properties 文件并打开它。
  3. 找到 net.sf.jasperreports.awt.ignore.missing.font=false 行并将值从 false 更改为 true net.sf.jasperreports.awt.ignore.missing.font=true
  4. 更新罐子。
  5. 添加到项目的类路径中。

问题解决了。

The easy steps to solve this problem would be

  1. Open jasperreports-x.x.x.jar, in my case jasperreports-3.7.2.jar.
  2. Locate default.jasperreports.properties file and open it.
  3. Find the line net.sf.jasperreports.awt.ignore.missing.font=false and change value from false to true net.sf.jasperreports.awt.ignore.missing.font=true.
  4. Update the jar.
  5. Add to classpath of your project.

The problem is solved.

奶气 2024-10-05 03:44:57

我正在使用 JasperReports 6.3.1。我通过在 .jrxml 中添加以下行解决了该问题:

<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>

这样,我们的报告看起来会有所不同,具体取决于系统中预安装的字体。就我而言,它并不代表问题,而且我对在我的项目中添加额外的字体不感兴趣,因为我需要尽可能轻。


如果您想在所有运行时环境中使用报表的原始字体,一个简单的解决方案是将必要的依赖项添加到项目中。

以 Maven 为例:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-fonts</artifactId>
    <version>6.0.0</version>
</dependency>

您还可以下载库并将它们手动添加到项目中,但它会起作用。


我希望您发现它们很有用。

I'm using JasperReports 6.3.1. I solved the problem by adding the following line in my .jrxml:

<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>

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:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-fonts</artifactId>
    <version>6.0.0</version>
</dependency>

You can also download the libraries and add them manually to the project, however it will work.


I hope you find them useful.

故事与诗 2024-10-05 03:44:57

2015 年更新:

将其添加到(或取消注释)/etc/apt/sources.list

deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

然后运行:

sudo apt-get update
sudo apt-get install msttcorefonts

Update for year 2015:

Add this to (or uncomment in) /etc/apt/sources.list

deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

Then run this:

sudo apt-get update
sudo apt-get install msttcorefonts
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文