Skip to main content
Skip table of contents

Report fonts

Basics

Fonts can be stored in the report by the editor. This should be done in the styles to adjust the layout of the report as a whole. Note that subreports must be configured separately.

JasperStudio allows the selection of all fonts in the system via the drop-down box. But this is the problem. The selected font exists on the client system, but does not have to exist on the application server. The problem already occurs with the 'Tahoma' font on Linux systems. Although the report can be filled without errors, the set font is not used when exporting as a PDF file or when displaying in the Web Client.

In older JasperReports versions, a PDF font could be stored per text field, but it did not match the normal font, nor could it display formatting in HTML text. In JasperStudio, this setting is no longer offered because they are no longer necessary and is issued as an obsolete setting as a warning. In older reports, this setting should therefore be removed/emptied.

The solution lies in the 'Font Extension' of JasperReports. This allows any True Type fonts to be added to the application without them having to be installed in the system. The basis for this is a self-created library, which has to be copied into the custExt directory in the server and in the client. In general, this library (a ZIP file with the extension .jar) contains all font files (*.ttf) and a descriptive XML file in which all ttf files are referenced.

For licensing reasons, CURSOR is not allowed to deliver frequently used Windows fonts directly with the version. A template and support can be gladly requested from CURSOR support.

Create font library

1. Create the fontlibrary directory
2. In this directory, create the file jasperreports_extension.properties with the following content:

CODE
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.font=font/fonts.xml

3. Create the font subdirectory
4. Copy the font files (*.ttf) into this directory
5. In this directory, create the file fonts.xml with the following content:

XML
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
 <fontFamily name="Tahoma">
  <normal>font/tahoma.ttf</normal>
  <bold>font/tahomabd.ttf</bold> <!-- auch 'italic' und 'boldItalic' -->
  <pdfEncoding>Identity-H</pdfEncoding>
  <pdfEmbedded>true</pdfEmbedded>
  <exportFonts>
   <export key="net.sf.jasperreports.html">Tahoma, Helvetica, sans-serif</export>
   <export key="net.sf.jasperreports.xhtml">Tahoma, Helvetica, sans-serif</export>
  </exportFonts>
 </fontFamily>
</fontFamilies>

6. Zip the content of the fontlibrary directory and save it as cursor-font.jar

Embed font library

The created library must now be made available in the application server and the client. This process is handled in a similar way to a version patch.

Application server

  • Copy to JBoss\modules\custom\main

  • Inclusion of the library in the JBoss\modules\custom\main\module.xml

  • The application server must now be restarted.

Client

  • Copy to Client\custExt

  • Distribute the directory with the new library via client update

JasperStudio

  • The font must be installed in the system.

  • The library must be copied to the lib directory.

  • When editing, the classpath to the lib/cursor-font.jar file is created automatically

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.