The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.awt.font  [5 examples]

e651. Listing All Available Font Families

A font family refers to a set of font faces with a related typographic design. For example, the font faces in the family Lucida Sans Typewriter might be Lucida Sans Typewriter Bold, and Lucida Sans Typewriter Regular. This example lists all available font family names.

Note: J2SE 1.4 only supports True Type fonts.

    // Get all font family names
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String fontNames[] = ge.getAvailableFontFamilyNames();
    
    // Iterate the font family names
    for (int i=0; i<fontNames.length; i++) {
    }
    // Aria
    // Comic Sans MS
    // Verdana
    // ...

 Related Examples
e652. Getting the Font Faces for a Font Family
e653. Drawing a Paragraph of Text
e654. Getting the Shape from the Outline of Text
e655. Drawing Text with Mixed Styles


© 2002 Addison-Wesley.