3.6.1 and the JRFontNotFoundException

JasperForge: JasperReports JasperReports 的討論區

This exception was introduced in JR 3.6.1 so that is more obvious to our users that they are creating reports using fonts that are not available on the machines that run those reports.

Very many problems that are reported on these forums are related to misuse of fonts in reports.

 

You get this error because you are using fontName="BlairITC TT" in your reports and this particular font is not available to the JVM that renders your report.

 

You have two options here:

1. configure JR to ingnore missing fonts and continue using what is basically an invalid report template, which is missing an important resource: the font.

You can do this by setting the net.sf.jasperreports.awt.ignore.missing.font=true in the jasperreports.properties file or as a custom property in that particular report template.

Note that this is not recomended as unpredictable results will be obtained when the JVM will use some other font to calculate your report layout.

 

2. Package the TTF files that make up the BlairTC TT font into a JAR that represents a JR font extension and add it to your application classpath. This will make the font available to the JVM and thus the report will work properly on all machines.

The easiest way to do so is to rely on a few Spring JARs and package your fonts the same way we did with the DejaVu fonts that we ship under the /demo/fonts sample. Note the fonts.xml file in the folder hierachy. If you don’t want to use Spring, you would need to implement some JR extensions interfaces. You could do so by looking into the implementations that are already shipped as part of JR, and follow the Javadoc.

 

Note that exception is related to fonts being used with AWT, at report fill time and they do not have to do with PDF. What you have tried are some PDF-related settings that are nowadays deprecated, as PDF font mappings are done in the font extensions as well.

 

The easiest way to create font extensions is by using iReport 3.6.1, which comes with a TTF install wizard and a font export tool, in the Tools/Options/iReport/Fonts menu.

 

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

What is 8 + 10 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)