I'm having some issues with the fonts when I'm deploying the reports in my web app. The fonts I want to have in my result pdfs are Arial, Calibri and Century Gothic.
I followed all the steps pointed here but couldn't get it working.
Here's what I did:
I modified the content of my jasperreports_extension.properties like following:
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.dejavu=net/sf/jasperreports/fonts/fonts.xml
net.sf.jasperreports.extension.simple.font.families.arial=net/sf/jasperreports/fonts/fonts.xml
net.sf.jasperreports.extension.simple.font.families.calibri=net/sf/jasperreports/fonts/fonts.xml
net.sf.jasperreports.extension.simple.font.families.centurygothic=net/sf/jasperreports/fonts/fonts.xml
Then at net\sf\jasperreports\fonts I put the three folders for the fonts containing the four styles (normal, bold, italic and bold-italic) for each of the fonts before mentioned.
Also, modified the fonts.xml at net/sf/jasperreports/fonts and it looks like this now:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="DejaVu Sans">
<normal>net/sf/jasperreports/fonts/dejavu/DejaVuSans.ttf</normal>
<bold>net/sf/jasperreports/fonts/dejavu/DejaVuSans-Bold.ttf</bold>
<italic>net/sf/jasperreports/fonts/dejavu/DejaVuSans-Oblique.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/dejavu/DejaVuSans-BoldOblique.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
</exportFonts>
<!--
<locales>
<locale>en_US</locale>
<locale>de_DE</locale>
</locales>
-->
</fontFamily>
<fontFamily name="DejaVu Serif">
<normal>net/sf/jasperreports/fonts/dejavu/DejaVuSerif.ttf</normal>
<bold>net/sf/jasperreports/fonts/dejavu/DejaVuSerif-Bold.ttf</bold>
<italic>net/sf/jasperreports/fonts/dejavu/DejaVuSerif-Italic.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/dejavu/DejaVuSerif-BoldItalic.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Serif', 'Times New Roman', Times, serif</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Serif', 'Times New Roman', Times, serif</export>
</exportFonts>
</fontFamily>
<fontFamily name="DejaVu Sans Mono">
<normal>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono.ttf</normal>
<bold>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono-Bold.ttf</bold>
<italic>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono-Oblique.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/dejavu/DejaVuSansMono-BoldOblique.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
</exportFonts>
</fontFamily>
<!--
Mapping Java logical fonts, for the sake of HTML export only.
-->
<fontFamily name="SansSerif">
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Sans', Arial, Helvetica, sans-serif</export>
</exportFonts>
</fontFamily>
<fontFamily name="Serif">
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Serif', 'Times New Roman', Times, serif</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Serif', 'Times New Roman', Times, serif</export>
</exportFonts>
</fontFamily>
<fontFamily name="Monospaced">
<exportFonts>
<export key="net.sf.jasperreports.html">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
<export key="net.sf.jasperreports.xhtml">'DejaVu Sans Mono', 'Courier New', Courier, monospace</export>
</exportFonts>
</fontFamily>
<fontFamily name="Arial">
<normal>net/sf/jasperreports/fonts/arial/arial.ttf</normal>
<bold>net/sf/jasperreports/fonts/arial/ArialBold.ttf</bold>
<italic>net/sf/jasperreports/fonts/arial/ArialItalic.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/arial/ArialBoldItalic.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'Arial'</export>
<export key="net.sf.jasperreports.xhtml">'Arial'</export>
</exportFonts>
</fontFamily>
<fontFamily name="Calibri">
<normal>net/sf/jasperreports/fonts/calibri/calibri.ttf</normal>
<bold>net/sf/jasperreports/fonts/calibri/calibri-bold.ttf</bold>
<italic>net/sf/jasperreports/fonts/calibri/calibri-italic.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/calibri/calibri-bold-italic.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'Calibri'</export>
<export key="net.sf.jasperreports.xhtml">'Calibri'</export>
</exportFonts>
</fontFamily>
<fontFamily name="Century Gothic">
<normal>net/sf/jasperreports/fonts/centurygothic/century-gothic.ttf</normal>
<bold>net/sf/jasperreports/fonts/centurygothic/century-gothic-bold.ttf</bold>
<italic>net/sf/jasperreports/fonts/centurygothic/century-gothic-italic.ttf</italic>
<boldItalic>net/sf/jasperreports/fonts/centurygothic/century-gothic-bold-italic.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
<exportFonts>
<export key="net.sf.jasperreports.html">'Century Gothic'</export>
<export key="net.sf.jasperreports.xhtml">'Century Gothic'</export>
</exportFonts>
</fontFamily>
</fontFamilies>
Note that I just added the last three fonts.
After that I prepared the jar file and put it in my app classpath as mandatory. So far I just got the report exported with normal Sanserif font...
I don't know what I'm doing wrong, any ideas?
Thanks!
Quick informative note: I'm using Jaspersoft Studio Community edition (6.3.0) and my app is deployed in a JBoss server.
I finally found out what was happening in my case and now it's working.
When I introduced the fonts (.ttf extension) in Jaspersoft Studio Windows->Preferences->Fonts I selected a wrong value for the PDF Encoding selection combo. I first selected CP1252 (Western European ANSI aka WinAnsi) which is WRONG if you want to export reports in PDF, then I chose Identity-H (Unicode with horizontal writing) instead and it worked fine.
However, what I still don't understand is: if in my report I'm only using Calibri and Century Gothic fonts, why in earth when I go to see the fonts used in my PDF (File->Properties->Fonts) I get also Helvetica in the list of fonts used?