Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2006

Tip: Looking for answers? Try searching our database.

True Type Fonts in Java

Thread view: 
M.Loeffler - 20 Feb 2006 07:58 GMT
Hi all

I'm currently trying to use a True Type Font in Java. I installed the
font under windows and it works fine in e.g. Word, but when I try to
use it in Java all I can see are "rectangles". I'm not sure if the
problem lies in the font itself or if it is a problem of Java. The
fonts are named "Fughetta" and "Toccata" and can be found here:
http://www.efn.org/~bch/aboutfonts.html. He is are code snippets I'm
using to test the font:

public void setFonts(Graphics g)
   {
       if (f != null) {
           return;
       }

       f = new Font("Fughetta", Font.TRUETYPE_FONT, 26);
       System.out.println(f);
   }

   public void paintComponent(Graphics g)
   {
       super.paintComponent(g);

       setFonts(g);

       String s1 = "1234567890ß´!\"§$%&/(()=?`";
       String s2 = "qwertzuiopü+asdfghjklöä#yxcvbnm,.-<";
       String s3 = "QWERTZUIOPÜ*ASDFGHJKLÖÄ'YXCVBNM;:_>";
       String s4 = "1²³{[]\\}@€~µ|";

       g.setFont(f);
       g.drawString(s1, 10, 30);
       g.drawString(s2, 10, 70);
       g.drawString(s3, 10, 110);
       g.drawString(s4, 10, 150);
   }

All help is appreciated ;)

- marc
Roedy Green - 23 Feb 2006 15:08 GMT
>I'm currently trying to use a True Type Font in Java. I installed the
>font under windows and it works fine in e.g. Word, but when I try to
>use it in Java all I can see are "rectangles".

There are sorts of cheapie fonts around without Unicode encodings and
other features. It is very much a Chinese menu what the font maker
includes in his font. see http://mindprod.com/jgloss/truetype.html
and read the spec to understand the predicament..

In the meantime you can test the font with my fontshower applets.  You
can then see if the problem is your code or the font not being
suitable for Unicode.

see http://mindprod.com/applets/fontshower.html
http://mindprod.com/applets/fontshowerawt.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.