// TestFonts.java   try various font methods
 
import java.awt.*;
import java.awt.event.*;

public class TestFonts extends Frame
{

  public TestFonts() // constructor
  {
    System.out.println("TestFonts from Java");
    setTitle("TestFonts");
    setSize(400,300);
    setBackground(Color.white);
    setForeground(Color.black);
    addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent e)
      {
        System.exit(0);
      }
    });
    setVisible(true);
  }

  public void paint(Graphics g)
  {
    GraphicsEnvironment ge = GraphicsEnvironment.
              getLocalGraphicsEnvironment();
    Font f[] = ge.getAllFonts();
    g.setColor(Color.black);
    for(int i=0; i<f.length; i++)
    {
      String fs = f[i].getName();
      System.out.println(fs); // write to terminal for saving
    }
    Font f18 = new Font("Courier New", Font.PLAIN, 18);
    g.setFont(f18);
    g.drawString("Courier New 18pt", 50, 60);
    g.drawString("abcdefghijklmnopqrstuvwxyz", 50, 90);
    g.drawString("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 50, 120);
    g.drawString("0123456789", 50, 150);
    Font f12 = new Font("Times New Roman", Font.BOLD, 12);
    g.setFont(f12);
    g.drawString("Times New Roman  BOLD  12pt", 50, 200);
    g.drawString("abcd ABCD 0123456789", 50, 230);
  }

  public static void main (String[] args) 
  {
    new TestFonts(); // construct and execute
  }
}
