Font 'Arial' is not available to the JVM

2019-03-21 02:01发布

I'm working on a Java project that uses Jasperreports. I worked several times in other projects using the same technology, and i had the same problem when trying to print a report in Unix environments.

My project uses:

  • JBoss 4.2.3.GA
  • Java 1.6
  • Jasperreports 4.7.0

The exception thrown is:

net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.

I found a common solution to solve this issue and ir really works:

sudo apt-get install msttcorefonts

However, I want to understand how Jasper works with fonts, and how it searches this fonts installed in Unix environments. Maybe a better question is: how JVM handles native fonts? Can anyone give me a detailed explanation on this subject? How are system fonts made available for the JVM in runtime?

5条回答
狗以群分
2楼-- · 2019-03-21 02:46

If you don't want to go through the hassle of downloading jars and what not, just go to software-center and click install Ubuntu restricted extras. This package will install not only MS Fonts but other supports for applications with restricted copyright.

This works for Ubuntu Systems.

查看更多
别忘想泡老子
3楼-- · 2019-03-21 02:58

for OpenSuse

validate the fonts is no aviable on SO fc-list | grep "Arial"

install the followin rpm sudo rpm -ivh msttcore-fonts-2.0-3.noarch.rpm

or Download from page:

http://www.mjmwired.net/resources/mjm-fedora-f11.html#ttf

Install the rpm

validate again fc-list | grep "Arial"

Restart your aplication server

查看更多
倾城 Initia
4楼-- · 2019-03-21 02:59

I was also facing the same issue on Jasper 5.0. I have followed the steps below:

  1. Place the jasper-fonts.jar;
  2. Install the missing fonts in the linux;
  3. Restart the JBoss server.
查看更多
太酷不给撩
5楼-- · 2019-03-21 03:00

Java asks the OS to provide the fonts. How that works depends on the OS.

http://en.wikipedia.org/wiki/Arial states its is installed on MS-Windows and MAC OSX

查看更多
贼婆χ
6楼-- · 2019-03-21 03:05

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
查看更多
登录 后发表回答