Use custom fonts in JasperReports PDF exporter

I was using custom font in a customer report embedded in the web application. The font (available in the operating system) was displayed correctly in HTML, RTF and Excel export. However, in the generated PDF text elements were displayed using Arial font.

The solution is to wrap required fonts as JasperReports Font Extensions. Font TTF files can be included in the same project generating Jasper reports or, a more elegant solution, in a separate JAR file.

I found an interesting blog post Fonts in JasperServer about providing custom fonts. The author is configuring the font extensions using Spring. However, you can do it in a simpler way.

First, install fonts in iReport and let create it the required configuration. In iReport, go to Tools -> Options, click on iReport group and go to Fonts tab. Here are some screenshots from the installation wizard:

iReport creates font extensions configuration and copies the recently installed font into the iReport installation directory/ireport/fonts directory (C:\Program Files (x86)\iReport-3.7.2\ireport\fonts in my case). You should find the following files there:

  • – it configures net.sf.jasperreports.extensions.ExtensionsRegistryFactory as net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory and points to the font family configuration:
  • net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
  • irfonts.xml – font family configuration:
       <fontfamily name="Calibri">
  • one or more TTF font files

All files found there that need to be packed in the JAR; let’s use Maven to create it:

  1. Create the Maven project directory (e.g. jasperreports-font-extensions) with src/main/resources subdirectory.
  2. Copy all files from iReport installation directory/ireport/fonts to Maven font extensions project directory/src/main/resources.
  3. Add pom.xml:
  4. <project xmlns="" xmlns:xsi="" xsi:schemalocation="">
  5. Build the JAR and install it in the local Maven repository:
  6. mvn install

The final step is to reference the newly created JAR as dependency in your reports project:


After that, the fonts contained it JAR will be available to JasperReports when generating a PDF report.

Just before publishing my post, Matt Dahlmann, author of the published an update of his previous article mentioned in this post. Check Jaspersoft v3 Font Extensions for the more actual version.