Font is not available to the JVM with Jasper Reports
JasperReports raises a JRFontNotFoundException in the case where the font used inside a report template is not available to the JVM as either as a system font or a font coming from a JR font extension. This ensure that all problems caused by font metrics mismatches are avoided and we have an early warning about the inconsistency.
Jasper reports is trying to help you in your report development, stating that it can not export your report correctly since it can not find the font defined in TextField
or StaticText
<font fontName="Arial"/>
Yes you can disable this by setting net.sf.jasperreports.awt.ignore.missing.font to true but you will have export inconsistencies.
Yes you can install the font as JVM system font (but you need to do it on every PC used that may generate report and you can still have encoding problems).
The correct way!
Use Font Extensions!, if you like to create your own (see link below), jasper reports also distributes a default font-extension jar (jasperreports-fonts-x.x.x.jar
), that supports fontName DejaVu Sans
, DejaVu Serif
and DejaVu Sans Mono
<font fontName="DejaVu Sans"/>
From the JasperReport Ultimate Guide:
We strongly encourage people to use only fonts derived from font extensions, because this is the only way to make sure that the fonts will be available to the application when the reports are executed at runtime. Using system fonts always brings the risk for the reports not to work properly when deployed on a new machine that might not have those fonts installed
Links on StackOverflow on how to render fonts correctly in pdf
Checklist on how to render font correctly in pdf
Generate font-extensions with JasperSoft Studio
Generate font-extensions with iReport
sudo apt-get install msttcorefonts
works (on our Ubuntu development environment), but is not a very good solution.
Instead, we bundled the fonts with our application based on this tip. Their JAR file bundles the following fonts,
- Arial
- Times New Roman
- Courier New
- Comic Sans MS
- Georgia
- Verdana
- Monospaced
Direct Link to download jar: Maven ver 1.0. DynamicFonts
I use IReport to install font:
tools -> options -> fonts -> click install font
Then select the font and click
-> export as extension and type name myfont.jar
add this jar and also spring.jar* to your build path.
*copy spring.jar from Jaspersoft\iReport-3.7.0\ireport\modules\ext
I tried installing mscorefonts, but the package was installed and up-to-date.
sudo apt-get update
sudo apt-get install ttf-mscorefonts-installer
I tried searching for the font in the filesystem, with:
ls /usr/share/fonts/truetype/msttcorefonts/
This folder just had the README, with the correct instructions on how to install.
cat /usr/share/fonts/truetype/msttcorefonts/README
You need an internet connection for this:
sudo apt-get install --reinstall ttf-mscorefonts-installer
I re-installed ttf-mscorefonts-installer
(as shown above, making sure to accept the EULA!) and the problem was solved.