Adding fonts programmatically

Many questions have previously been asked about fonts and JasperReports. This is a different set of issues to the ones usually asked.


1. Our application is a standalone, double-clickable application released for Linux, Windows and OSX. Report generation is integrated within the application and users are free to add additional reports of their own creation. The Windows app is bundled inside an .exe so adding items to the classpath is non-trivial.

2. Printing directly to a printer works just fine with custom fonts we specify inside the jrxml file. We don't use the new font extensions at all.

3. Printing to pdf via itext causes the font to be lost and some default Arial to be substituted.


Why we can't use the Jasper font extension

1. We want to use fonts located in the user's installed font location. This might be /Library/Fonts on a Mac for instance.

2. Users cannot easy edit fonts.xml themselves since we can't easily put that file into the classpath

3. Even if users were to create a copy of all their fonts, we need a mechanism to add them to the classpath programmatically. We don't know in advance which fonts they might like to use.


Attempted solutions

1. 'registering' fonts using the itext FontFactory.register(path) did not help

2. Trying to programmatically add the font to the Jasper font extension registry was met with a problem because the getExtensions(type) method makes a copy of the font list and therefore we can't append to it. See

Does anyone have ideas on this?

aristedes.maniatis's picture
Joined: Oct 28 2012 - 10:21pm
Last seen: 10 years 7 months ago

Did you managed to get a solution for this?

balizeiro_1 - 8 years 7 months ago

0 Answers:

No answers yet