Click to See Complete Forum and Search --> : Getting available fonts


Michel Crichton
April 5th, 1999, 08:43 AM
I am trying to get the availalable font types on the system which is running my java application. Right now I use a call to:

fonts = Toolkit.getDefaultToolkit().getFontList();

This only returns a couple of fonts (specifically the fonts available in the awt toolkit). I really want all the fonts available on the system. I am using Windows NT as my platform.

Does anyone have any ideas?

Mich

Bogdan Matasaru
April 6th, 1999, 11:10 AM
You can see only the fonts known by the Java Runtime. In the help which comes with the JDK you find information how to add a new font to the Java Runtime.
Unfortunatelly, you should do it by hand, modifying the font.properties file.

ANV
April 6th, 1999, 12:19 PM
Hi.

Actually, it is possible.
What I did last winter (when doing a simple paint applet) was something like this:

FontX oFontX = new FontX();
String[] oFonts = oFontx.getFontList();

(you might have to import com.ms.awt.*)


This works for getting all the available font types (for example for loading into a combo box) but that doesn't change the fact that you can't use any TrueType fonts in the applet. At least I couldn't. Let me know if you find out.

Javed
April 21st, 1999, 02:20 AM
hi,
the piece of code which iam giving will fetch all possible fonts on ur system.Actually it filled out my entire dos window :).
this works with java 2 only.

create an array of Font,
u have to use awt package for this.

GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
fonts=ge.getAllFonts();