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.