Posted By:
20 Feb, 2014 12:42 pm PST

How to determine the fonts available in a local System ?

 Write a program to know which fonts are available in a local system.

//knowing the available fonts

import java.awt.*;

public class Fonts {

       public static void main(String[] args) {

//get the local graphics environment information into

//GraphicsEnvironment object ge

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

//From ge, get available Font Family names into fonts[]

String fonts[] = ge.getAvailableFontFamilyNames();

System.out.println("Available Fonts on this system: ");

//retrieve one by one the font names from fonts[] and display

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









Java.awt : Contains all of the classes for creating user interfaces and for painting graphics and images.

GraphicsEnvironment class : The GraphicsEnvironment class describes the collection of GraphicsDevice objects and Font objects available to a Java(tm) application on a particular platform. The resources in this GraphicsEnvironment might be local or on a remote machine. 

getLocalGraphicsEnvironment():Returns the local GraphicsEnvironment.



Returns an array containing the names of all font families in this GraphicsEnvironment localized for the default locale, as returned by Locale.getDefault().


Was it useful?  

Please login to reply to this problem.