refermycode.com

Develop your world..

Add new font in Jasper Reports Font Library.

In this blog we are going to add new font in Jasper Font Library to remove font dependency. Hope you have read my previous blog on Remove font dependency from Jasper Report Font Library. As discussed in previous blog if we are using any font which is not present in our Jasper Report Font Library then it will raised following exception while export phase,

net.sf.jasperreports.engine.util.JRFontNotFoundException:
Font ‘Font_Name’ is not available to the JVM.

we can also resolve above exception by adding the font which is missing in our Jasperreports-font.X.X.X.jar Library. So let us have look on this method in detail.

Method 2 : by adding missing font property.
To add missing fonts into the library we can create our own custom library for Jasperreports-font.X.X.X.jar. So follow below given steps to create your custom font library for Jasper Report Font with the help of iReport.

Step 1:
To install missing fonts in iReport go to ” Tools >> Options >> Fonts >> Install Font ” as shown in following screenshot.

Blog2_2

Step 2:
Add your fonts ttf file from browse button and click on Next button as shown in following screenshot.

Blog2_3

Step 3:
After adding fonts ttf file, you need to add family details by adding Bold, Italic and Bold-Italic version of font. If you have not added these version of fonts then it will not change the font style even if we add in our report design. Click on next button after adding the font family version ttf files as shown in following screenshot.

Blog2_4

Step 4:
In this step select the locale for your region, In this example I have added English(India) as shown in following screenshot.

Blog2_5

Step 5:
After that you can also manage the font mapping for avoiding the missing font property in OS.
as it is not mandatory you can skip this and click on finish button as shown in following screenshot.

Blog2_6

Step 6:
You can add multiple fonts by repeating step 2 to 5. After adding all required fonts click on Export as Extension button and save the the library with .jar Extension. as shown in following screenshot.

Blog2_7

Step 7:
After following all above steps you will get the your custom library with all your fonts.

Blog2_8

Now you can use this jar for Jasperreports-font.X.X.X.jar which will be present in your project library or classpath. After replacing this library you will get the your desire output with proper fonts.

Hope this blog will help you to add new font in Jasper Font Library to remove font dependency.

Please don’t forget to comment your feedback for this post 🙂

2 Comments

  • Reply Ashwini Ghonge |

    Nice …..!!!
    Its very useful to all buddies those who really need some technical ideas, well strategies & all. Good Mayur.
    Thanks !!!

Post a comment