File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Packaging Fonts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Packaging Fonts?" Watch "Packaging Fonts?" New topic

Packaging Fonts?

Alex English

Joined: Feb 26, 2007
Posts: 8

I'm building my application on Linux, and I'm having trouble displaying a font that does not look terrible. The default system fonts do not seem to show up. I have been able to get it to work if I package an actual font ttf file into the jar, and then load the font from the jar.

My question is, am I breaking a rule? Is it ok to package a font that is not of my own creation? If so, should I add a note describing the license of the font? It's not a fancy font, just arial.


Lucy Hummel
Ranch Hand

Joined: Apr 07, 2005
Posts: 232
Hi Alex,

That sounds as a hack. I do not have a clue what went wrong. But I would not supply that hacking jar.

How did you set up the default look and feel? Did you call:

----------------------------------<br />| SCJP, SCWCD, SCBCD, SCEA, SCJD |<br />----------------------------------
Petr Hejl
Ranch Hand

Joined: Feb 26, 2006
Posts: 68
I think you would break the rule. IMHO the trouble is somewhere in you linux font configuration.

In addition I think that the fonts are something you can't easily get and distribute - somebody spent a lot of time creating it.
Romeo Son
Ranch Hand

Joined: Mar 12, 2007
Posts: 92

Hi Alex,

If you look in the API documentation for the Font class, you will see:

Logical fonts are the five font families defined by the Java platform which must be supported by any Java runtime environment: Serif, SansSerif, Monospaced, Dialog, and DialogInput.

Why don't you use one of them instead of Arial?

I agree. Here's the link:
subject: Packaging Fonts?
It's not a secret anymore!