Jasper Reports: Font extension not working
<p>I'm using multiple fonts in one of my reports that I export as a PDF, I'm using IREPORT to design my report.</p>

<p>In the preview section the report looks good but when I export it from my web app it looks like I'm using one font for the whole report.</p>

<p>I've searched this issue and I found two solutions for it:</p>

<ol>
<li><p>Export the font as .jar file from IREPORT and add it to my project [ Not a Clean way, Since I'm using Maven ].</p></li>
<li><p>Use <code>jasperreports_extension.properties</code> [the one I'm having problem with!].</p></li>
</ol>

<p>I followed <a href="http://javaskeleton.blogspot.com/2010/12/embedding-fonts-into-pdf-generated-by.html" rel="noreferrer">this</a> tutorial step by step but still no result no error no nothing.</p>

<p>Here is the code I'm using:</p>

<p><strong>jasperreports_extension.properties:</strong></p>

<pre><code>net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.myfamily=fonts/fonts.xml
</code></pre>

<p><strong>fonts.xml:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;fontFamilies&gt;

    &lt;fontFamily name="Arial"&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/arial.ttf]]&gt;&lt;/normal&gt;
        &lt;pdfEmbedded&gt;&lt;![CDATA[true]]&gt;&lt;/pdfEmbedded&gt;
    &lt;/fontFamily&gt;

    &lt;fontFamily name="Algerian"&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/Algerian.ttf]]&gt;&lt;/normal&gt;
        &lt;pdfEmbedded&gt;&lt;![CDATA[true]]&gt;&lt;/pdfEmbedded&gt;
    &lt;/fontFamily&gt;

    &lt;fontFamily name="Bell Mt"&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/bell-mt.ttf]]&gt;&lt;/normal&gt;
        &lt;pdfEmbedded&gt;&lt;![CDATA[true]]&gt;&lt;/pdfEmbedded&gt;
    &lt;/fontFamily&gt;

    &lt;fontFamily name="Savoye Std"&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/SavoyeStd.ttf]]&gt;&lt;/normal&gt;
        &lt;pdfEmbedded&gt;&lt;![CDATA[true]]&gt;&lt;/pdfEmbedded&gt;
    &lt;/fontFamily&gt;

    &lt;fontFamily name="Cambria"&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/Cambria.ttf]]&gt;&lt;/normal&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/cambriab.ttf]]&gt;&lt;/normal&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/cambriai.ttf]]&gt;&lt;/normal&gt;
        &lt;normal&gt;&lt;![CDATA[fonts/cambriaz.ttf]]&gt;&lt;/normal&gt;
        &lt;pdfEmbedded&gt;&lt;![CDATA[true]]&gt;&lt;/pdfEmbedded&gt;
    &lt;/fontFamily&gt;

&lt;/fontFamilies&gt;
</code></pre>

<p>Since I'm using spring I tried this also <strong>fonts.xml:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;beans:beans 

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"

    xmlns:jee="http://www.springframework.org/schema/jee"

    xsi:schemaLocation="

        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd

        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"&gt;

    &lt;beans:bean id="Arial" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"&gt;

        &lt;beans:property name="name" value="Arial"/&gt;
        &lt;beans:property name="normal" value="fonts/arial.ttf"/&gt;       
        &lt;beans:property name="pdfEncoding" value="Identity-H"/&gt;
        &lt;beans:property name="pdfEmbedded" value="true"/&gt;

    &lt;/beans:bean&gt;

    &lt;beans:bean id="Algerian" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"&gt;

        &lt;beans:property name="name" value="Algerian"/&gt;
        &lt;beans:property name="normal" value="fonts/Algerian.ttf"/&gt;       
        &lt;beans:property name="pdfEncoding" value="Identity-H"/&gt;
        &lt;beans:property name="pdfEmbedded" value="true"/&gt;

    &lt;/beans:bean&gt;

    &lt;beans:bean id="BellMt" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"&gt;

        &lt;beans:property name="name" value="Bell Mt"/&gt;
        &lt;beans:property name="normal" value="fonts/bell-mt.ttf"/&gt;       
        &lt;beans:property name="pdfEncoding" value="Identity-H"/&gt;
        &lt;beans:property name="pdfEmbedded" value="true"/&gt;

    &lt;/beans:bean&gt;

    &lt;beans:bean id="SavoyeStd" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"&gt;

        &lt;beans:property name="name" value="Savoye Std"/&gt;
        &lt;beans:property name="normal" value="fonts/SavoyeStd.ttf"/&gt;       
        &lt;beans:property name="pdfEncoding" value="Identity-H"/&gt;
        &lt;beans:property name="pdfEmbedded" value="true"/&gt;

    &lt;/beans:bean&gt;

    &lt;beans:bean id="Cambria" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"&gt;

        &lt;beans:property name="name" value="Cambria"/&gt;
        &lt;beans:property name="normal" value="fonts/Cambria.ttf"/&gt;
        &lt;beans:property name="bold" value="fonts/cambriab.ttf"/&gt;
        &lt;beans:property name="italic" value="fonts/cambriai.ttf"/&gt;
        &lt;beans:property name="boldItalic" value="fonts/cambriaz.ttf"/&gt;       
        &lt;beans:property name="pdfEncoding" value="Identity-H"/&gt;
        &lt;beans:property name="pdfEmbedded" value="true"/&gt;

    &lt;/beans:bean&gt;

&lt;/beans:beans&gt;
</code></pre>

<p>And the font files in the font folder in the root package.</p>