aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Font problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Font problem" Watch "Font problem" New topic
Author

Font problem

Sofie Deceuninck
Greenhorn

Joined: Feb 20, 2004
Posts: 11
How does it come the button's label isn't displayed with the font Broadway BT? In the method paint the font works.

When i use the method setFont it still doesn't work.

Thanks for the replies in advance.
Sofie
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

There are multiple problems here... Under some JVM/OS combinations the JVM is pretty good at finding the installed fonts on the system and using those, under others, you have to go to great lengths to install fonts (i.e. install them in the lib/fonts directory of the JRE, then edit font.properties to include them correctly). This is for applications.

You have an additional problem because you are running as an Applet. The applet runs on the JVM of the *user's* browser. If the *user* doesn't have the font installed, then the JVM will not know what font you are talking about, and will just use the default font.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Sofie Deceuninck
Greenhorn

Joined: Feb 20, 2004
Posts: 11

You have to go to great lengths to install fonts (i.e. install them in the lib/fonts directory of the JRE, then edit font.properties to include them correctly)

What do I have to edit about the font.properties? Does it satisfy when I just place the appropiated fonts in the directory lib/fonts of the JRE?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

No, you have to edit font.properties for Java to find it correctly, too. That is, *IF* your JDK version/OS requires this. Try calling -


And see what fonts are available to you.

A good description of what you have to do if you need to manually install fonts is here. Sun provides examples of how to install asian fonts in the JDK.
Sofie Deceuninck
Greenhorn

Joined: Feb 20, 2004
Posts: 11
I tried what you said and saw that the font Bangle was available but when I tried the following it still didn't work out! What's the problem then?

Try calling -
code:
--------------------------------------------------------------------------------
String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment(). getAvailableFontFamilyNames();
--------------------------------------------------------------------------------
And see what fonts are available to you.

Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Did it just use the default font or did a bunch of squares or question marks show up? If it just used the default then I'm not sure what's wrong, because the GraphicsEnvironment *told* you it was installed. If it's just displaying little empty squares or a bunch of question marks it means that the font isn't rendering correctly in UTF, which may be a solvable problem or may not.

I found more good resources on getting more fonts to work in Java :
  • MindProd Java Glossery entry on Fonts
  • A Sun forum thread on fonts that don't seem to render correctly.
  • Some font issues discussed in a FAQ for a Java program called "Kirrkirr".

  • Sofie Deceuninck
    Greenhorn

    Joined: Feb 20, 2004
    Posts: 11
    It was just displayed with the default font so tricky to solve the problem.
    Thanks for the links on how fonts work.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Font problem
     
    Similar Threads
    Observable/Observer - Application/Applet
    Default Font
    labeling in this Applet..
    labeling in this Applet..
    Applet help.....