iReport字体报错“JRFontNotFoundException”

net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Times-Roman' is not available to the JVM. See the Javadoc for more details.
	net.sf.jasperreports.engine.util.JRFontUtil.checkAwtFont(JRFontUtil.java:358)
	net.sf.jasperreports.engine.util.JRStyledText.getAwtAttributedString(JRStyledText.java:226)
	net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:326)
	net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:510)
	net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:593)
	net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:328)


可通过Jaspersoft iReprot Designer软件生成字体包:
1.点击 Tools>>Options>>iReport>>Fonts 标签项
iReport字体报错“JRFontNotFoundException”_第1张图片
2.Install Font
iReport字体报错“JRFontNotFoundException”_第2张图片
3.选择字体,可选择添加粗体、斜体等配套字体。
iReport字体报错“JRFontNotFoundException”_第3张图片
iReport字体报错“JRFontNotFoundException”_第4张图片
4.选择需要打包的字体 >>Export as extension ,输入名字保存成jar文件
iReport字体报错“JRFontNotFoundException”_第5张图片

生成jar包里面主要有两个配置文件 jasperreports_extension.properties,fontsfamily.xml,也可以不通过iReport自己手动创建字体jar包,按照如下结构:
iReport字体报错“JRFontNotFoundException”_第6张图片
iReport字体报错“JRFontNotFoundException”_第7张图片

jasperreports_extension.properties内容如下:
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.ireportfamily1381460521792=fonts/fontsfamily1381460521792.xml

fontsfamily.xml内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
   <fontFamily name="Arial Unicode MS">
       <normal><![CDATA[fonts/ARIALUNI.TTF]]></normal>
       <pdfEmbedded><![CDATA[false]]></pdfEmbedded>
   </fontFamily>
   <fontFamily name="SimSun">
       <normal><![CDATA[fonts/simsun.ttf]]></normal>
       <pdfEmbedded><![CDATA[false]]></pdfEmbedded>
   </fontFamily>
   <fontFamily name="Times-Roman">
       <normal><![CDATA[fonts/Times-Roman.ttf]]></normal>
       <pdfEmbedded><![CDATA[false]]></pdfEmbedded>
   </fontFamily>
</fontFamilies>




你可能感兴趣的:(java,IREPORT,Jasper)