14

After upgrading Jasper to the last version, it stopped finding one font: Symbol. The rest of the fonts seem to be fine. I have a bunch of ttfs in the same directory as where jasper is run, the program is just a small wrapper to generate PDFs, and it's throwing this error:

net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Symbol' is not available to the JVM. See the Javadoc for more details.
    at net.sf.jasperreports.engine.util.JRFontUtil.checkAwtFont(JRFontUtil.java:358)
    at net.sf.jasperreports.engine.util.JRStyledText.getAwtAttributedString(JRStyledText.java:226)
    at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:362)
    at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:1129)
    at net.sf.jasperreports.engine.fill.JRFillStaticText.prepare(JRFillStaticText.java:183)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:329)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:419)
    at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:378)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2028)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:757)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:269)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:127)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:860)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    at XmlJasperInterface.report(XmlJasperInterface.java:82)
    at XmlJasperInterface.main(XmlJasperInterface.java:60)</pre>

The directory where the program is running:

# ls *.ttf
arial.ttf  arialbd.ttf  lsans.ttf  lsansd.ttf  lsansi.ttf  symbol.ttf

All other fonts are found. Oh, in my laptop (macosx), it works fine, it only breaks on the server (Debian). I opened symbol.ttf and it opened fine on Mac OS X (just in case the file was corrupt).

Any ideas what may be going on?

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

6 Answers6

17

Try adding the line

net.sf.jasperreports.awt.ignore.missing.font=true

to your jasperreports.properties file.

Matjaž Tercelj
  • 715
  • 5
  • 10
  • 5
    That doesn't make it find the font, but it makes it not complain about it and use any other font it can. Since that was the previous behavior and everybody was happy with it before, I've just did this although it's not the optimal solution. – Pablo Fernandez Oct 29 '10 at 05:49
  • 2
    This does not solve the problem, it just ignores the problem. – Meow Jul 20 '12 at 09:18
  • 1
    This is the default for jasperserver, but I still get the error about missing fonts. – Paul Brannan Aug 01 '12 at 14:39
5

On ubuntu I needed to uninstall the fonts and reinstall them:

sudo apt-get remove  ttf-mscorefonts-installer
sudo apt-get install  ttf-mscorefonts-installer

Then, it works ok.

fselvatici
  • 79
  • 1
  • 4
2

Well the font must be installed in the OS where the report run.

Condemateguadua
  • 576
  • 5
  • 9
  • 1
    Indeed. jasperreports looks out for fonts available in the OS. For example, if you design the report in Windows and run the app in linux, you will get something apart from what you saw in iReport unless you use fonts that can be used in both environments. – Alfabravo Dec 13 '11 at 22:56
1

I'm using JasperReports 6.3.1. I solved the problem by adding the following line in my .jrxml:

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

This way our report will look something different, depending on the fonts that are preinstalled in the system. In my case it does not represent a problem, and I'm not interested in adding an extra font in my project, since I need to be as light as possible.


In case you want to use the original fonts of the report in all runtime environments, an easy solution is to add the necessary dependencies to the project.

An example, for Maven:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-fonts</artifactId>
    <version>6.0.0</version>
</dependency>

You can also download the libraries and add them manually to the project, however it will work.


I hope you find them useful.

cesAR
  • 606
  • 5
  • 16
  • I added this dependency to my project , but it work only my local laptop, when running in a different runtime I got the same issue. – LMH Nov 19 '22 at 15:14
  • @LMH Bro, unfortunately I am unable to help you. I don't work in Java anymore, and I'm away from that project. What it can tell you is that after compiling, the dependencies were traveling with the complete solution, and everything worked fine. I intuit that you are having a portability problem when compiling, with which you are not taking the corresponding dependencies with your final solution. Sorry I can't be of more help, good luck! – cesAR Dec 28 '22 at 18:25
1

The easy steps to solve this problem would be

  1. Open jasperreports-x.x.x.jar, in my case jasperreports-3.7.2.jar.
  2. Locate default.jasperreports.properties file and open it.
  3. Find the line net.sf.jasperreports.awt.ignore.missing.font=false and change value from false to true net.sf.jasperreports.awt.ignore.missing.font=true.
  4. Update the jar.
  5. Add to classpath of your project.

The problem is solved.

Beschi
  • 185
  • 1
  • 3
  • 7
    There's no need to edit the JAR. You just need to create a jasperreports.properties and add it to the classpath just with the properties you want to modify (as stated in the accepted solution). – Juan Calero Apr 02 '12 at 10:11
  • I did that its working fine when running class from eclipse. but its not working when i export as Runnable jar its gives me below errror "net.sf.jasperreports.engine.JRException: Input stream not found at : fonts.xml" – Dhrumil Shah Oct 13 '17 at 05:09
0

Update for year 2015:

Add this to (or uncomment in) /etc/apt/sources.list

deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

Then run this:

sudo apt-get update
sudo apt-get install msttcorefonts
Aram Paronikyan
  • 1,598
  • 17
  • 22