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,
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.
To install missing fonts in iReport go to ” Tools >> Options >> Fonts >> Install Font ” as shown in following screenshot.
Add your fonts ttf file from browse button and click on Next button as shown in following screenshot.
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.
In this step select the locale for your region, In this example I have added English(India) as shown in following screenshot.
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.
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.
After following all above steps you will get the your custom library with all your fonts.
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 🙂