Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: how do I prove java uses unicode? plz need HELP :0 /
|
Posted: Mar 13, 2002 3:13 PM
|
|
For starters, you should be running the Java 2 platform.
You can use the Font.canDisplay() method to see if the font you are using has glyphs for all the characters in your string.
Here is an example from the book Java Internationalization (all the examples from this book are available at http://www.javainternationalization.com, by the way):
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DrawStringDemo extends JFrame {
String message = "David says, \"\u05E9\u05DC\u05D5\u05DD \u05E2\u05D5\u05DC\u05DD\"";
public DrawStringDemo() {
super("DrawStringDemo");
}
public void paint(Graphics g) {
Graphics2D graphics2D = (Graphics2D)g;
GraphicsEnvironment.getLocalGraphicsEnvironment();
Font font = new Font("LucidaSans", Font.PLAIN, 40);
graphics2D.setFont(font);
graphics2D.drawString(message, 50, 75);
}
public static void main(String[] args) {
JFrame frame = new DrawStringDemo();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
//frame.pack();
frame.setSize(new Dimension(500,100));
frame.setVisible(true);
}
}
|
|