com.icesoft.pdf.pobjects.fonts
Class FontManager

java.lang.Object
  extended bycom.icesoft.pdf.pobjects.fonts.FontManager

public class FontManager
extends Object

The FontManager class is responsible for finding available fonts on the client operating system. This class by default checks the following directories when the readSystemFonts method is called without any parameters.

The default font directories are as follows:

It is possible to specify other directories to search for fonts via the readSystemFonts methods extraFontPaths parameter readSystemFonts(java.lang.String[]). Reading all of an operating systems font's can be time consuming. To help speed up this process the method getFontProperties exports font data via a Properties object. The font Properties object can then be saved to disk or be read back into the FontManager via the setFontProperties method.

Since:
2.0

Field Summary
static int WEIGHT_BOLD
          Indicates that a font's weight is bold.
static int WEIGHT_NORMAL
          Indicates that a font's weight is normal.
 
Constructor Summary
FontManager()
           
 
Method Summary
 String[] getAvailableFamilies()
          Gets all available font family names on the operating system.
 String[] getAvailableNames()
          Gets all available font names on the operating system.
 String[] getAvailableStyle()
          Gets all available font styles on the operating system.
 NFont getChineseSimplifiedInstance(String name, int fontFlags)
           
 NFont getChineseTraditionalInstance(String name, int fontFlags)
           
 Properties getFontProperties()
          Gets a Properties object containing font information for the operating system which the FontManager is running on.
static FontManager getInstance()
          Returns a static instance of the FontManager class.
 NFont getInstance(String name, int flags)
          Get an instance of a NFont from the given font name and flag decoration information.
 NFont getJapaneseInstance(String name, int fontFlags)
           
 NFont getKoreanInstance(String name, int fontFlags)
           
static String guessFamily(String name)
          Utility method for guessing a font family name from its base name.
static int guessWeight(String name)
          Utility method for guessing the weight of a family.
 void readSystemFonts(String[] extraFontPaths)
          Searches all default system font paths and any font paths specified by the extraFontPaths parameter, and records data about all found fonts.
 void setFontProperties(Properties fontProperties)
          Reads font data from the Properties file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEIGHT_BOLD

public static final int WEIGHT_BOLD
Indicates that a font's weight is bold.


WEIGHT_NORMAL

public static final int WEIGHT_NORMAL
Indicates that a font's weight is normal.

Constructor Detail

FontManager

public FontManager()
Method Detail

getInstance

public static FontManager getInstance()

Returns a static instance of the FontManager class.

Returns:
instance of the FontManager.

getFontProperties

public Properties getFontProperties()

Gets a Properties object containing font information for the operating system which the FontManager is running on. This Properties object can be saved to disk and read at a later time using the setFontProperties(java.util.Properties) method.

Returns:
Properties object containing font data information.

setFontProperties

public void setFontProperties(Properties fontProperties)
                       throws IllegalArgumentException

Reads font data from the Properties file. All name and key data replaces any existing font information.

Parameters:
fontProperties - Properties object containing valid font information.
Throws:
IllegalArgumentException - thrown, if there is a problem parsing the Properties file. If thrown, the calling application should re-read the system fonts.

readSystemFonts

public void readSystemFonts(String[] extraFontPaths)

Searches all default system font paths and any font paths specified by the extraFontPaths parameter, and records data about all found fonts. This font data is used to substitute fonts which are not embedded inside a PDF document.

Parameters:
extraFontPaths - array String object where each entry represents a system directory path containing font programs.

guessFamily

public static String guessFamily(String name)

Utility method for guessing a font family name from its base name.

Parameters:
name - base name of font.
Returns:
guess of the base fonts name.

guessWeight

public static int guessWeight(String name)

Utility method for guessing the weight of a family.

Parameters:
name - base name of font.
Returns:
if base name contains weight key words, NFont.WEIGHT_BOLD is return; otherwise, NFont.WEIGHT_NORMAL.

getAvailableNames

public String[] getAvailableNames()

Gets all available font names on the operating system.

Returns:
font names of all found fonts.

getAvailableFamilies

public String[] getAvailableFamilies()

Gets all available font family names on the operating system.

Returns:
font family names of all found fonts.

getAvailableStyle

public String[] getAvailableStyle()

Gets all available font styles on the operating system.

Returns:
font style names of all found fonts.

getJapaneseInstance

public NFont getJapaneseInstance(String name,
                                 int fontFlags)

getKoreanInstance

public NFont getKoreanInstance(String name,
                               int fontFlags)

getChineseTraditionalInstance

public NFont getChineseTraditionalInstance(String name,
                                           int fontFlags)

getChineseSimplifiedInstance

public NFont getChineseSimplifiedInstance(String name,
                                          int fontFlags)

getInstance

public NFont getInstance(String name,
                         int flags)

Get an instance of a NFont from the given font name and flag decoration information.

Parameters:
name - base name of font.
flags - flags used to describe font.
Returns:
a new instance of NFont which best approximates the font described by the name and flags attribute.