我正在尝试使用DynamicJasper生成报告,但是出现了以下错误:
net.sf.jasperreports.engine.util.JRFontNotFoundException:
Font 'Arial' is not available to the JVM.
msttcorefonts已经被安装,但是我猜JVM没有使用它提供的任何字体。
我正在使用Ubuntu 10.04。
我该如何解决这个问题?
我正在尝试使用DynamicJasper生成报告,但是出现了以下错误:
net.sf.jasperreports.engine.util.JRFontNotFoundException:
Font 'Arial' is not available to the JVM.
msttcorefonts已经被安装,但是我猜JVM没有使用它提供的任何字体。
我正在使用Ubuntu 10.04。
我该如何解决这个问题?
请尝试在jasperreports.properties文件中添加以下行:
net.sf.jasperreports.awt.ignore.missing.font=true
filename.Arial=Arial.ttf
filename.Arial_Bold=Arial_Bold.ttf
filename.Arial_Italic=Arial_Italic.ttf
filename.Arial_Bold_Italic=Arial_Bold_Italic.ttf
你可以通过 iReport 并将其转换为 JAR 文件等方式来创建自定义字体。
在多种语言(Unicode)中创建jasper报告
1)在ireport desginer中安装字体
2)创建字体扩展名(我们将在应用程序类路径中使用它)
3)在操作系统上安装字体(可选)
4)将字体的所有.ttf粘贴到jre->lib->fonts目录中(否则,Web应用程序将抛出错误,JVM无法使用字体)
https://mvnrepository.com/artifact/com.mpobjects.jasperreports.font/jasperreports-fonts-liberation
如果您正在使用CentOS,解决方案分为两步:
下载 Microsoft 核心字体 rpm 包。
[root@WEBSVR~/]# wget http://www.itzgeek.com/msttcore-fonts-2.0-3.noarch.rpm
安装 rpm 包。
[root@WEBSVR~/]# rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm
实际上,我用非常简单的方法解决了这个问题
主目录
,例如/root
.fonts
的文件夹所有字体文件
复制到.fonts
中,如果您使用的是Windows,则可以从C:\windows\fonts
复制字体。sudo apt-get install fontconfig
fc-cache –fv
重新构建字体缓存。<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>
嘿,你在Windows上查看文档时遇到了问题吗?
你可以尝试一个简单的好方法:
yum install curl cabextract xorg-x11-font-utils fontconfig
完成后,我需要重新启动我的CentOS6系统。