// TestFonts2.java // Unicode "\u0000 hex" http://www.unicode.org/charts/charindex.html import java.awt.*; import java.awt.event.*; class TestFonts2 extends Frame { TestFonts2() { setTitle("TestFonts2 example"); setSize(600,500); setBackground(Color.white); setForeground(Color.black); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); } public void paint(Graphics g) { Font cur18 = new Font("courier", Font.BOLD, 18); Font cur16 = new Font("courier", Font.BOLD, 16); Font math16 = new Font("DejaVu Sans Bold", Font.BOLD, 16); Font arial = new Font("Arial", Font.PLAIN, 16); Font cent16 = new Font("Century Schoolbook L Bold", Font.BOLD, 16); Font symbol = new Font("symbol", Font.PLAIN, 16); // yuk! Font symb16 = new Font("L M Math Symbols10 Bold", Font.BOLD, 16); // yuk! Font symb5 = new Font("L M Math Symbols5 Bold", Font.BOLD, 16); // yuk! // any unrecognized font name seems to give courier g.setColor(Color.blue); g.setFont(cur18); g.drawString("TestFonts2 "+(char)33, 20, 50); g.setColor(Color.black); g.drawString("Pi: \u03C0 Part: \u2202",400,50); g.setFont(cur16); System.out.println("cur16="+cur16); g.drawString("Pi: \u03C0 Part: \u2202",400,80); for(int i= 0; i< 16; i++) { if(i<10) g.drawString(" "+(char)(48+i),60+25*i, 150); else g.drawString(" "+(char)(55+i),60+25*i, 150); } for(int i= 0; i< 16; i++) { if(i<10) g.drawString("x"+(char)(48+i),20, 180+20*i); else g.drawString("x"+(char)(55+i),20, 180+20*i); for(int j=0; j<16; j++) g.drawString(" "+(char)(16*i+j),60+25*j, 180+20*i); } int npts = 4; int xpts[] = {500,510,560,550}; //new int[npts]; int ypts[] = { 90, 80,120,130}; //new int[npts]; g.drawString("fillRect 40 by 20", 60, 80); g.fillRect(40, 90, 40, 20); g.setColor(Color.yellow); g.fillOval(100, 90, 20, 30); g.setColor(Color.gray); g.drawLine(400, 50, 450, 100); g.setColor(Color.blue); g.drawOval(200, 90, 50, 30); g.setColor(Color.red); g.drawRect(300, 90, 60, 40); g.setColor(Color.green); g.fillPolygon(xpts, ypts, npts); g.setFont(cur18); g.drawString("courier 18", 400, 120); GraphicsEnvironment ge = GraphicsEnvironment. getLocalGraphicsEnvironment(); Font f[] = ge.getAllFonts(); for(int i=0; i i = f.iterator(); i.hasNext(); ) //{ // Font f2 = i.next(); // if ( ! f2.canDisplay( '\u03C0' ) ) // i.remove(); // remove ant that do not have Unicode Pi // else // System.out.println(f2); //} } public static void main(String args[]) { new TestFonts2(); } } // end TestFonts2.java