/opt/jasperreports-server-cp-4.7.0/apache-tomcat/webapps/jasperserver/WEB-INF/classes/net/sf/jasperreports/fonts/fonts.xml
在文件最后加入
1
2
3
4
5
6
|
<bean id=
"stsongFamily"
class
=
"net.sf.jasperreports.engine.fonts.SimpleFontFamily"
>
<property name=
"name"
value=
"STSong"
/>
<property name=
"normal"
value=
"net/sf/jasperreports/fonts/dejavu/STSONG.TTF"
/>
<property name=
"pdfEncoding"
value=
"Identity-H"
/>
<property name=
"pdfEmbedded"
value=
"true"
/>
</bean>
|
/opt/jasperreports-server-cp-4.7.0/apache-tomcat/webapps/jasperserver/WEB-INF/classes/net/sf/jasperreports/fonts/dejavu/STSONG.TTF
#########################################################################
6.4
C:\Jaspersoft\jasperreports-server-cp-6.4.0\apache-tomcat\webapps\jasperserver\WEB-INF\lib\jasperreports-fonts-6.0.0.jar
将 jasperreports-fonts-6.0.0.jar解压,出现目录结构:net\sf\jasperreports\fonts\degavu,此目录下是目前JVM內所支持的字体类型。
网上下载ttf字体,选择simhei.ttf放入该目录下
打开目录net\sf\jasperreports\fonts下的font.xml进行JasperReport与字体的关联配置,将如下的配置信息键入font.xml中,将黑体关联到simhei.ttf文件,将文件保存。
<fontFamily name="黑体">
<normal>net/sf/jasperreports/fonts/dejavu/simhei.ttf</normal>
<bold>net/sf/jasperreports/fonts/dejavu/simhei.ttf</bold>
<italic>net/sf/jasperreports/fonts/dejavu/simhei.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/dejavu/simhei.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'黑体', Arial, Helvetica, sans-serif</export>
<export key="net.sf.jasperreports.xhtml">'黑体', Arial, Helvetica, sans-serif</export>
</exportFonts>
</fontFamily>
修改完成文件后用ue打开xml文件,将文件重新另保存为’UTF-8 无BOM’的格式(因为微软会在utf-8格式的文件前面加上EF BB BF三个字节,解析的时候无法识别,项目会报错)
将修改好的文件重新打包成jar,放在项目中引用即可