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.

8 thoughts on “Use custom fonts in JasperReports PDF exporter

  1. Good article. I don’t know maven well, so those details are interesting for me. Thanks for the mention of my article. Rather than link to my article of a year ago, it might be better to link to the one published just four days before yours. It parallels your idea of using iReport’s new abilities to create the font extensions, which is indeed much easier than doing things manually. But then it focuses on JasperServer rather than on JasperReports.

  2. In case anybody is facing a more mundane question of e.g. bold text not displaying properly in generated pdfs paste this into your pom:


    I have decided to post it here because I read on many forums that people are struggling with this trifle and I got a bit frustrated over it too. Obviously it is only vaguely related to a more advanced topic you are describing in your post but I have landed here looking for a solution to my problem and your post gave me a hint. Thanks.

    1. It is a maven dependency but tags got stripped as I posted my comment.

  3. I created the jar with the fonts but when I went up the application on a linux server, can not generate a report. It gives the following error:

    12:47:07,248 ERROR [stderr] (http– Caused by: net.sf.jasperreports.engine.JRRuntimeException: Problem reading font data.
    12:47:07,249 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontFace.(
    12:47:07,250 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontFace.(
    12:47:07,250 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontFace.getInstance(
    12:47:07,251 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(
    12:47:07,251 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(
    12:47:07,252 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(
    12:47:07,253 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(
    12:47:07,256 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(
    12:47:07,256 ERROR [stderr] (http– at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(
    12:47:07,257 ERROR [stderr] (http– at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(
    12:47:07,261 ERROR [stderr] (http– at net.sf.jasperreports.engine.util.JRStyledTextParser.(
    12:47:07,261 ERROR [stderr] (http– … 36 more

  4. Absolutely great post. I wasted hours with half-baked and deprecated explanations, until I came here.


Comments are closed.