how-to

Graphics

How to get throught all font families

For this sample you must use:

import java.awt.*;

This sample code lists names of all font families in your system.

String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

/* -- go throught font families and get more informations */

for ( int i = 0; i < fonts.length; i++ ) {

  /* -- show only "ari*" font families */
  if ( ! fonts[i].toLowerCase().startsWith( "ari") ) continue;

  System.out.println( fonts[i] );
}

The output could be:

Arial
Arial Black
Arial Narrow
Arial Unicode MS