|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.FontManager
public abstract class FontManager
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
).
Field Summary | ||
---|---|---|
|
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. |
|
static int |
DUPLICATE_DATA
Status code: Returned if the font data already exists with a different name. |
|
static int |
DUPLICATE_NAME
Status code: Returned if the typeface name already exists. |
|
static int |
EXCEEDS_LIMIT
Status code: Returned if the font data exceeds the limit. |
|
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. |
|
static int |
FONTS_ARRAY_FULL
Status code: Returned if the internal font array's capacity would be exceeded by loading a font. |
|
static int |
MISSING_TYPEFACE_NAME
Status code: Returned if the typeface name provided is null or zero-length. |
|
static int |
MISS_RESOURCE
Status code: Returned if no data could be found. |
|
static int |
NO_FONT_DATA
Status code: Returned if no font data was found when trying to load or unload a font. |
|
static int |
NO_PERMISSION
Status code: Returned if do not have the permission to continue the load/unload request. |
|
static int |
READ_FAIL
Status code: Returned if can not read the InputStream passed into the load function. |
|
static int |
SUCCESS
Status code: Returned if the font is loaded/unloaded successfully. |
|
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 | ||
---|---|---|
|
static FontManager |
getInstance()
Returns an instance of the font manager (singleton), which handles the loading and unloading of custom fonts. |
|
abstract int |
load(InputStream fontData,
String fontName,
int flag)
Load a font into memory from the specified input stream. |
|
abstract int |
load(String fileName,
String fontName,
int flag)
Load a font into memory from the specified file. |
|
abstract void |
setApplicationFont(Font applicationFont)
Sets the default font for the current application. |
|
abstract void |
setSystemFont(Font systemFont)
Sets the default system font. |
|
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 |
---|
public static final int SUCCESS
public static final int NO_FONT_DATA
public static final int FONTS_ARRAY_FULL
public static final int MISSING_TYPEFACE_NAME
public static final int FAILED_TO_LOAD_FILE
public static final int MISS_RESOURCE
public static final int DUPLICATE_NAME
public static final int DUPLICATE_DATA
public static final int READ_FAIL
public static final int NO_PERMISSION
public static final int EXCEEDS_LIMIT
public static final int APPLICATION_FONT
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.
public static final int SYSTEM_FONT
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.
Method Detail |
---|
public static FontManager getInstance()
public abstract void setApplicationFont(Font applicationFont)
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.
applicationFont
- Font to set as default; if null, application inherits
the default system font.public abstract void setSystemFont(Font systemFont) throws IllegalArgumentException
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.
systemFont
- Font to set as default system font.
IllegalArgumentException
- If the specified font is invalid (null) or
does not exist (not loaded).public abstract int load(InputStream fontData, String fontName, int flag) throws IllegalArgumentException
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 6Mb in size. Supported font formats: *.ttf (TrueType Unicode).
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
).
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.
IllegalArgumentException
- If the flag is invalid.public abstract int load(String fileName, String fontName, int flag) throws IllegalArgumentException
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 6Mb in size. Supported font formats: *.ttf (TrueType Unicode).
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
).
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.
IllegalArgumentException
- If the flag is invalid.public abstract int unload(String fontName)
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.
fontName
- Name of the font family (typeface).
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal