net.rim.device.api.ui
Class FontManager

java.lang.Object
  extended by net.rim.device.api.ui.FontManager

public abstract class FontManager
extends Object

FontManager handles loading and unloading of custom fonts for system-wide or application-specific use. Custom fonts may be loaded into persistent memory (see FontManager.SYSTEM_FONT) or into application memory (see FontManager.APPLICATION_FONT).

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

Field Summary
Category: Signed static int APPLICATION_FONT
          Application font: Use this flag in FontManager.load(InputStream, String, int) or FontManager.load(String, String, int) to load a custom application-specific font.
Category: Signed static int DUPLICATE_DATA
          Status code: Returned if the font data already exists with a different name.
Category: Signed static int DUPLICATE_NAME
          Status code: Returned if the typeface name already exists.
Category: Signed static int EXCEEDS_LIMIT
          Status code: Returned if the font data exceeds the limit.
Category: Signed static int FAILED_TO_LOAD_FILE
          Status code: Returned if a font file could not be loaded for some reason not covered by one of the other error codes.
Category: Signed static int FONTS_ARRAY_FULL
          Status code: Returned if the internal font array's capacity would be exceeded by loading a font.
Category: Signed static int MISSING_TYPEFACE_NAME
          Status code: Returned if the typeface name provided is null or zero-length.
Category: Signed static int MISS_RESOURCE
          Status code: Returned if no data could be found.
Category: Signed static int NO_FONT_DATA
          Status code: Returned if no font data was found when trying to load or unload a font.
Category: Signed static int NO_PERMISSION
          Status code: Returned if do not have the permission to continue the load/unload request.
Category: Signed static int READ_FAIL
          Status code: Returned if can not read the InputStream passed into the load function.
Category: Signed static int SUCCESS
          Status code: Returned if the font is loaded/unloaded successfully.
Category: Signed static int SYSTEM_FONT
          System font: Use this flag in FontManager.load(InputStream, String, int) or FontManager.load(String, String, int) to load a custom system-wide font.
 
Method Summary
Category: Signed static FontManager getInstance()
          Returns an instance of the font manager (singleton), which handles the loading and unloading of custom fonts.
Category: Signed abstract  int load(InputStream fontData, String fontName, int flag)
          Load a font into memory from the specified input stream.
Category: Signed abstract  int load(String fileName, String fontName, int flag)
          Load a font into memory from the specified file.
Category: Signed abstract  void setApplicationFont(Font applicationFont)
          Sets the default font for the current application.
Category: Signed abstract  void setSystemFont(Font systemFont)
          Sets the default system font.
Category: Signed abstract  int unload(String fontName)
          Unload a font from memory with the specified font family (typeface) name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

SUCCESS

public static final int SUCCESS
Status code: Returned if the font is loaded/unloaded successfully.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

NO_FONT_DATA

public static final int NO_FONT_DATA
Status code: Returned if no font data was found when trying to load or unload a font.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

FONTS_ARRAY_FULL

public static final int FONTS_ARRAY_FULL
Status code: Returned if the internal font array's capacity would be exceeded by loading a font.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

MISSING_TYPEFACE_NAME

public static final int MISSING_TYPEFACE_NAME
Status code: Returned if the typeface name provided is null or zero-length.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

FAILED_TO_LOAD_FILE

public static final int FAILED_TO_LOAD_FILE
Status code: Returned if a font file could not be loaded for some reason not covered by one of the other error codes.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

MISS_RESOURCE

public static final int MISS_RESOURCE
Status code: Returned if no data could be found.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

DUPLICATE_NAME

public static final int DUPLICATE_NAME
Status code: Returned if the typeface name already exists.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

DUPLICATE_DATA

public static final int DUPLICATE_DATA
Status code: Returned if the font data already exists with a different name.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

READ_FAIL

public static final int READ_FAIL
Status code: Returned if can not read the InputStream passed into the load function.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

NO_PERMISSION

public static final int NO_PERMISSION
Status code: Returned if do not have the permission to continue the load/unload request.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

EXCEEDS_LIMIT

public static final int EXCEEDS_LIMIT
Status code: Returned if the font data exceeds the limit.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

APPLICATION_FONT

public static final int APPLICATION_FONT
Application font: Use this flag in FontManager.load(InputStream, String, int) or FontManager.load(String, String, int) to load a custom application-specific font. A custom application font is available to applications, but not visible in the font list found in Options. It is automatically unloaded when the loading application terminates.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

SYSTEM_FONT

public static final int SYSTEM_FONT
System font: Use this flag in FontManager.load(InputStream, String, int) or FontManager.load(String, String, int) to load a custom system-wide font. A custom system font is available to applications and is also visible in the font list found in Options. It is stored persistently in the file system and automatically re-loaded if the device restarts.

See Also:
Constant Field Values
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0


Method Detail

getInstance

public static FontManager getInstance()
Returns an instance of the font manager (singleton), which handles the loading and unloading of custom fonts.

Returns:
Instance of this FontManager.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

setApplicationFont

public abstract void setApplicationFont(Font applicationFont)
Sets the default font for the current application.

The Font.GUID_FONT_CHANGED event is sent to the current application. If the font is set prior to the application instance being created, no notification is sent to the application that the font has been changed.

Parameters:
applicationFont - Font to set as default; if null, application inherits the default system font.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

setSystemFont

public abstract void setSystemFont(Font systemFont)
                            throws IllegalArgumentException
Sets the default system font. Only system fonts visible in the font list found in Options may be set as the default system font.

The Font.GUID_FONT_CHANGED event is sent to the current application. If the font is set prior to the application instance being created, no notification is sent to this application that the font has been changed.

Parameters:
systemFont - Font to set as default system font.
Throws:
IllegalArgumentException - If the specified font is invalid (null) or does not exist (not loaded).
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

load

public abstract int load(InputStream fontData,
                         String fontName,
                         int flag)
                  throws IllegalArgumentException
Load a font into memory from the specified input stream.

If the font is loaded as a system font (i.e. FontManager.SYSTEM_FONT), it is available to applications and is also visible in the font list found in Options. It is stored persistently in the file system and automatically re-loaded if the device restarts.

If the font is loaded as an application font (i.e. FontManager.APPLICATION_FONT), it is available to applications, but not visible in the font list found in Options. It is automatically unloaded when the loading application terminates.

Fonts are currently limited to 90k in size. Supported font formats: *.ttf (TrueType Unicode).

Parameters:
fontData - InputStream containing font data.
fontName - Name of the font family (typeface).
flag - Flag to indicate it is a system font (FontManager.SYSTEM_FONT) or an application font (FontManager.APPLICATION_FONT).
Returns:
FontManager.SUCCESS if font loads successfully.
FontManager.FONTS_ARRAY_FULL if too many fonts loaded.
FontManager.MISSING_TYPEFACE_NAME if typeface name is invalid.
FontManager.DUPLICATE_NAME if font name is duplicate.
FontManager.DUPLICATE_DATA if font data is duplicate.
FontManager.NO_FONT_DATA if no font data is found.
FontManager.EXCEEDS_LIMIT if font data exceeds 90k in size.
FontManager.READ_FAIL if cannot read the input stream.
FontManager.FAILED_TO_LOAD_FILE if font data is invalid or font format is invalid.
Throws:
IllegalArgumentException - If the flag is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

load

public abstract int load(String fileName,
                         String fontName,
                         int flag)
                  throws IllegalArgumentException
Load a font into memory from the specified file.

If the font is loaded as a system font (i.e. FontManager.SYSTEM_FONT), it is available to applications and is also visible in the font list found in Options. It is stored persistently in the file system and automatically re-loaded if the device restarts.

If the font is loaded as an application font (i.e. FontManager.APPLICATION_FONT), it is available to applications, but not visible in the font list found in Options. It is automatically unloaded when the loading application terminates.

Fonts are currently limited to 60k in size. Supported font formats: *.ttf (TrueType Unicode).

Parameters:
fileName - Name of the font file in calling module.
fontName - Name of the font family (typeface).
flag - Flag to indicate it is a system font (FontManager.SYSTEM_FONT) or an application font (FontManager.APPLICATION_FONT).
Returns:
FontManager.SUCCESS if font loads successfully.
FontManager.FONTS_ARRAY_FULL if too many fonts loaded.
FontManager.MISSING_TYPEFACE_NAME if typeface name is invalid.
FontManager.DUPLICATE_NAME if font name is duplicate.
FontManager.DUPLICATE_DATA if font data is duplicate.
FontManager.NO_FONT_DATA if no font data is found.
FontManager.EXCEEDS_LIMIT if font data exceeds 60k in size.
FontManager.MISS_RESOURCE if font file cannot be found.
FontManager.FAILED_TO_LOAD_FILE if font data is invalid or font format is invalid.
Throws:
IllegalArgumentException - If the flag is invalid.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0

unload

public abstract int unload(String fontName)
Unload a font from memory with the specified font family (typeface) name.

If the unloaded font is a system font (i.e. FontManager.SYSTEM_FONT), it is removed from the file system and is no longer visible in the font list in Options.

Parameters:
fontName - Name of the font family (typeface).
Returns:
FontManager.SUCCESS if the font was unloaded successfully.
FontManager.MISSING_TYPEFACE_NAME if the typeface name is not valid.
FontManager.NO_PERMISSION if the application does not have permission to unload the font.
Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 5.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.