Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JasperReports 5.6: Could not load the following font

I am facing the problem, that JasperReports still cannot find the Arial font.

I created a simple Maven Project with following structure and included it to my main application. So the main application contains the installed JAR in classpath:

- jasperreports_extension.properties
- fonts
  |-> arial
    |-> ariali.ttf
    |-> arialbi.ttf
    |-> arialbd.ttf
    |-> arial.ttf
  |-> fonts.xml

But I still see following Exception while exporting report to PDF.

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : 
pdfFontName   : Arial
pdfEncoding   : Identity-H
isPdfEmbedded : true

jasperreports_extension.properties

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

fonts.xml:

<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
    <fontFamily name="Arial">
        <normal>fonts/arial/arial.ttf</normal>
        <bold>fonts/arial/arialbd.ttf</bold>
        <italic>fonts/arial/ariali.ttf</italic>
        <boldItalic>fonts/arial/arialbi.ttf</boldItalic>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
    </fontFamily>
</fontFamilies>

Template

<font fontName="Arial" size="8" pdfFontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
like image 687
Tunguska Avatar asked Aug 28 '14 12:08

Tunguska


1 Answers

The problem was the template itself: At one font-tag the <fontName> property was missing:

Does not work:

<font size="12" isBold="true" pdfFontName="Arial"/>

Does work:

<font fontName="Arial" size="12" isBold="true" pdfFontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
like image 164
Tunguska Avatar answered Sep 17 '22 14:09

Tunguska