Normally, JasperReport uses system default font when generating a report. This blog will introduce step by step how you can embed other font types in JasperReport.
Step 1: Create a file called jasperreports_extension.properties and put it in your classpath
net.sf.jasperreports.extension.registry.factory.fonts=
net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.fontfamily=
fonts/fontfamily.xml
Step 2: Create a “fonts” folder in classpath.
Step 3: Create fontfamily.xml file in the properties file mentioned and place it in the “fonts” folder of the project
fonts/arial.ttf
fonts/arialbd.ttf
fonts/ariali.ttf
fonts/arialbi.ttf
true
Step 4: Place the desired font file/s (*.ttf) in the “fonts” directory
Step 5: Specify the desired font name in *.jrxml file
Step 6: This method only works on JasperReport version 3.7.6 or later. If you are using ZK 5.0.7, please download the latest version of jasperreport.jar to replace the original one.
Muchas gracias por el dato.
Nice tutorial man…
very good tutorial
how to load fonts in .jar extension??
I have try to every way and solution on the internet but unable to success that jrxml always give blank for the Hindi font of “Arial Unicode MS” font family
Please Please give me the solution for the above.
For me it worked when configuring the fontfamily.xml as follows:
(mind the correct case in the element names, e.g. fontFamily instead of fontfamily)
<fontFamilies>
<fontFamily name=”Arial Unicode MS”>
<normal>fonts/ARIALUNI.TTF</normal>
<pdfEmbedded>true</pdfEmbedded>
<pdfEncoding>Identity-H</pdfEncoding>
</fontFamily>
</fontFamilies>
inside the report I can then specify Hindi characters like this:
<text><![CDATA[ZK स्वागत हे ZK]]></text>
refer to http://community.jaspersoft.com/wiki/adding-fonts-embedding-pdf