jasper-reports Font-extensions Creating and using font extensions

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!


Create a font extension using the IDE. See the iReport or Jaspersoft Studio documentation for details. The font extension can also be created manually.

What are font extensions?

Using a textElement you can specify a font (if not specified default font SansSerif is used)

    <font fontName="DejaVu Sans"/>

To calculate font-metric (for line breaks, alignment etc) and render the font correctly, the font needs to be mapped in the JVM (Java virtual macchine). You could install the font file directly to the JVM but this is not encourage

From the JasperReport Ultimate Guide:

We strongly encourage people to use only fonts derived from font extensions, because this is the only way to make sure that the fonts will be available to the application when the reports are executed at runtime. Using system fonts always brings the risk for the reports not to work properly when deployed on a new machine that might not have those fonts installed

Default font extension

JasperReports provide a default font-extension (see maven distribution jasperreports-fonts.jar). Adding this to classpath you can use the following fontName's without creating your own font-extension

DejaVu Sans
DejaVu Serif
DejaVu Sans Mono

Common Issues

Issues to consider when using font's in pdf (itext):

  • When exporting to PDF, if the text is not rendered correctly (missing parts, characters not showed, not wrapping or sized correctly), the font-extensions are likely missing.

  • Is the actual .tff supported (OpenType) and can the font actually render the character? Not all fonts render all characters in UTF-8.

  • Is the correct encoding passed to iText? In doubts (or in general) use the encoding Identity-H this is recommend for newer PDF standards and gives you the ability to mix different encoding.

  • Is the font embedded so that a PDF shared across computers can display the content even if the font is not installed? If the font is not one of the 14 Standard Type 1 fonts always embed it.

Note the version of iText used by jasper report will not render all fonts (ligaturizer problem), You can test the ttf font and encoding directly see How can I test if my font is rendered correctly in pdf?

Got any jasper-reports Question?