Jump to content
Changes to the Jaspersoft community edition download ×

Adding fonts programmatically


aristedes.maniatis

Recommended Posts

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

Problem

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 http://grepcode.com/file/repo1.maven.org/maven2/net.sf.jasperreports/jasperreports/4.6.0/net/sf/jasperreports/extensions/DefaultExtensionsRegistry.java#103

Does anyone have ideas on this?

Link to comment
Share on other sites

  • 2 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...