What Is the Jasperrepots-Fonts Jar for and How to Use It

What is the jasperrepots-fonts jar for and how to use it?

In jasper report (.jrxml file) you can use several fonts for displaying labels/texts. These fonts may not be always available on different platforms/OS. (e.g. There are some MS fonts which are unavailable on linux machines unless you install them manually). So, we bundle the fonts used in jasper report into a jar and make them work irrespective of underlying platform. Additionally, you can include your own (custom created) fonts in fonts extension jar and ship them along with jasper reports. More information is here.

Also there are couple of ways to configure and use this jar. Have a look at this to know one of the easiest way.

Note that if the font used in jrxml is not available in the JVM, it will throw an error while exporting the report as follows:

net.sf.jasperreports.engine.util.JRFontNotFoundException:  
Font 'Arial' is not available to the JVM.

This can be solved in 2 ways:

1. Use jasperreport-extension.jar OR

2. Set the property net.sf.jasperreports.awt.ignore.missing.font to true to ignore missing font.
e.g. In jrxml, you can set it as follows:

<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>

JasperReports: How to add font not in the application classpath

The problem was that the loading of font extensions jars is done from the thread context classloader and from the JRParameter.REPORT_CLASS_LOADER, nor the JRExporterParameter.CLASS_LOADER.

Therefore, in my case, the current (initial) thread classloader had to be saved, the we had to do something like Thread.currentThread().setContextClassLoader(cl), where cl was the context of the JasperReports based application and then the thread context classloader was reverted to the original one.

The question has been answered and details are available here.

I hope this answer will help others facing similar (font) issues.

Adding a font to a jasper report

I know this is a bit late answere XD, but now you have an oficial simple guide on how you could do this steps by steps.

GUIDE

It tells you how to used it on a simple jasper report file, and then how to export and import it to be used on all reports.

Jasper Reports: Font extension not working

A big thank you to @Tunaki for helping me to solve this issue.

The problem was solved by putting the jasperreports_extension.properties and the fonts folder in the root of the project like this:

Sample Image

how to install new fonts in jasperreports

I solved it using the option in ireport. To install a new font in jasperreport , install that in ireport and Export to jar file and then replace the jar file in your jasper project. to install a font in ireport , go to tools -> options -> fonts and click on install fonts. follow the steps and you will now install new fonts in ireport. please dont forget to check embed this font in pdf.

Now to export the fonts , go to tools -> options -> fonts and then from the list of availble fonts please select the fonts you needed and then click Export as extension . which wil export the fonts as jar file. now replace the jar file in jasperreport library .

JasperReports fonts

Do not use pdfEncoding or isPdfEmbedded. These attributes were deprecated years ago. Use Font Extensions. They were introduced to solve exactly this problem. They'll let you generate the PDF as you are attempting to do. If you Google "jasperreports font extensions" you should find the information that you need.

Fonts not working when deploying jasperreport in PDF from web app

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?



Related Topics



Leave a reply



Submit