I am trying to add Tahoma font to jasper report in my web app. I use font extension mechanism.
This exception was thrown: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'TahomaFont' is not available to the JVM. See the Javadoc for more details.
Here is my font.xml file:
<fontFamiles>
<fontFamily name="TahomaFont">
<normal>export/fonts/BTahoma.ttf</normal>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
</fontFamily>
<fontFamiles>
and here is my jasperreports.properties file :
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.TahomaFont=export/fonts/fonts.xml
Also i have put Tahoma.ttf font file in my classpath. Here is the style tag in jasper report:
<style fontName="TahomaFont" name="tahoma"/>
Please let me know where i am going wrong. Thanks in advance.
The best way to use a font in JasperReports Library is to use a font extension. Jaspersoft fonts can be configured in Studio and Server and displayed in the PDF view. Fonts can be referred from an URL and from the file system using the Preferences dialog window from the Jaspersoft Studio.
Putting the Tahoma.ttf font in your class path is not the way to go.
You are right to use font extensions, it's a good practice - but you need to package your fonts as font extension, into a jar and add that jar to your classpath.
More information documented here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With