org.icepdf.core.pobjects.fonts
Class FontManager

java.lang.Object
  extended by org.icepdf.core.pobjects.fonts.FontManager

public class FontManager
extends java.lang.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

Constructor Summary
FontManager()
           
 
Method Summary
 void clearFontList()
          Clears internal font list of items.
 java.lang.String[] getAvailableFamilies()
          Gets all available font family names on the operating system.
 java.lang.String[] getAvailableNames()
          Gets all available font names on the operating system.
 java.lang.String[] getAvailableStyle()
          Gets all available font styles on the operating system.
 FontFile getChineseSimplifiedInstance(java.lang.String name, int fontFlags)
           
 FontFile getChineseTraditionalInstance(java.lang.String name, int fontFlags)
           
 java.util.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.
 FontFile getInstance(java.lang.String name, int flags)
          Get an instance of a NFont from the given font name and flag decoration information.
 FontFile getJapaneseInstance(java.lang.String name, int fontFlags)
           
 FontFile getKoreanInstance(java.lang.String name, int fontFlags)
           
static java.lang.String guessFamily(java.lang.String name)
          Utility method for guessing a font family name from its base name.
 void readSystemFonts(java.lang.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(java.util.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
 

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 java.util.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(java.util.Properties fontProperties)
                       throws java.lang.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:
java.lang.IllegalArgumentException - thrown, if there is a problem parsing the Properties file. If thrown, the calling application should re-read the system fonts.

clearFontList

public void clearFontList()
Clears internal font list of items. Used to clean list while custructing a new list.


readSystemFonts

public void readSystemFonts(java.lang.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 java.lang.String guessFamily(java.lang.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.

getAvailableNames

public java.lang.String[] getAvailableNames()

Gets all available font names on the operating system.

Returns:
font names of all found fonts.

getAvailableFamilies

public java.lang.String[] getAvailableFamilies()

Gets all available font family names on the operating system.

Returns:
font family names of all found fonts.

getAvailableStyle

public java.lang.String[] getAvailableStyle()

Gets all available font styles on the operating system.

Returns:
font style names of all found fonts.

getJapaneseInstance

public FontFile getJapaneseInstance(java.lang.String name,
                                    int fontFlags)

getKoreanInstance

public FontFile getKoreanInstance(java.lang.String name,
                                  int fontFlags)

getChineseTraditionalInstance

public FontFile getChineseTraditionalInstance(java.lang.String name,
                                              int fontFlags)

getChineseSimplifiedInstance

public FontFile getChineseSimplifiedInstance(java.lang.String name,
                                             int fontFlags)

getInstance

public FontFile getInstance(java.lang.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.