Packaging fonts
According to official JasperReport documentation, it is very recommended to package your fonts with your reports to prevent exceptions like:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.
Unless you specify a physical font file (i.e. a .ttf file), for a given font name (like “Arial”) the JVM will ask the underlying S.O. for such font, if not present: Exception. But you can package your fonts in a jar file and JasperReports will look form them.
We already packaged 7 well known fonts in the following jar file that you can add to your project as a maven dependency (remember to add our maven repository)
<dependency> <groupId>ar.com.fdvs</groupId> <artifactId>DynamicJasper-core-fonts</artifactId> <version>1.0</version> </dependency>
Such fonts are:
- Arial
- Times New Roman
- Courier New
- Comic Sans MS
- Georgia
- Verdana
- Monospaced
Important: Since JasperReports 6.3.1, packaged fonts created with previous versions will not work (e.g: packaged using iReport version older than 6.3.1, or JasperStudio). You will need to create your font package again with a newer version.
You’ll need to repackage them with the new format. An step-by-step guide can be found here: https://community.jaspersoft.com/wiki/custom-font-font-extension