• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Font problem

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sofie Deceuninck
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It was just displayed with the default font so tricky to solve the problem.
    Thanks for the links on how fonts work.
    reply
      Bookmark Topic Watch Topic
    • New Topic