net.rim.device.api.ui
Class FontFamily

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

public class FontFamily
extends Object

A font family is a collection of font faces (fonts of differing sizes and styles) which belong to the same typeface and are referred to by the same family name. It can be used as a factory to create Font objects of specified sizes and styles.

See Also:
Font

Field Summary
static int BITMAP_FONT
          A bit flag indicating a bitmap font.
static int CBTF_FONT
          A type for CBTF (Compact Bitmap Typeface Format) fonts.
static String FAMILY_SYSTEM
          The family name of the system font.
static int MONO_BITMAP_FONT
          Deprecated.  
static int SCALABLE_FONT
          A bit flag indicating a scalable font.
static int SFF4_FONT
          A type for SFF4 (Slangsoft Font Format 4) fonts.
static int TRUE_TYPE_FONT
          A type for TrueType fonts.
static int UNKNOWN_FONT
          A type for fonts of unknown type.
 
Method Summary
 boolean equals(Object object)
          Compares one font family to another.
static FontFamily forName(String name)
          Retrieves a FontFamily object from the font registry by name, creating a new one and adding it to the font registry if the name is not found.
 Font getFont(int style, int height)
          Returns a font specified by style and size.
 Font getFont(int style, int height, int units)
          Returns a font specified by style and size.
static FontFamily[] getFontFamilies()
          Return an array containing all registered font families.
 Font[] getFonts()
          Deprecated. Use FontFamily.getFont(int, int)
 int[] getHeights()
          Returns an array of heights in pixels supported by this font family.
 String getName()
          Returns the font family's name.
 int getTypefaceType()
          Get the typeface type.
 int hashCode()
          Returns the hash code based on font family.
 boolean isHeightSupported(int height)
          Determines if this font family supports a specific height.
 boolean isStyleSupported(int style)
          Determines if this font family supports a specific style.
 String toString()
          Retrieves a string representation of a font family.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 



Field Detail

FAMILY_SYSTEM

public static String FAMILY_SYSTEM
The family name of the system font.


BITMAP_FONT

public static int BITMAP_FONT
A bit flag indicating a bitmap font. Used in font types.

Since:
BlackBerry API 5.0.0

MONO_BITMAP_FONT

public static int MONO_BITMAP_FONT
Deprecated. 
A flag indicating a monochrome bitmap font. An obsolete name maintained for backward compatibility. Use BITMAP_FONT. It is incorrect because the flag is set in the CBTF font type, and CBTF fonts can be colored.

Since:
BlackBerry API 3.7.0

SCALABLE_FONT

public static int SCALABLE_FONT
A bit flag indicating a scalable font. Used in font types.

Since:
BlackBerry API 3.7.0

UNKNOWN_FONT

public static int UNKNOWN_FONT
A type for fonts of unknown type.

Since:
BlackBerry API 3.7.0

CBTF_FONT

public static int CBTF_FONT
A type for CBTF (Compact Bitmap Typeface Format) fonts.

Since:
BlackBerry API 4.5.0

SFF4_FONT

public static int SFF4_FONT
A type for SFF4 (Slangsoft Font Format 4) fonts.

Since:
BlackBerry API 4.5.0

TRUE_TYPE_FONT

public static int TRUE_TYPE_FONT
A type for TrueType fonts.

Since:
BlackBerry API 4.5.0


Method Detail

forName

public static FontFamily forName(String name)
                          throws ClassNotFoundException
Retrieves a FontFamily object from the font registry by name, creating a new one and adding it to the font registry if the name is not found.

Parameters:
name - The name of the font family. One of the permitted values is FontFamily.FAMILY_SYSTEM.
Returns:
The FontFamily object.
Throws:
ClassNotFoundException

getFont

public Font getFont(int style,
                    int height)
Returns a font specified by style and size.

Parameters:
style - Bits selecting styles (Font.BOLD, Font.Italic, etc.).
height - Desired height in pixels.
Returns:
The font most closely matching the parameters.
See Also:
Font

getFont

public Font getFont(int style,
                    int height,
                    int units)
Returns a font specified by style and size.

Parameters:
style - Bits selecting styles (Font.BOLD, Font.Italic, etc.).
height - Desired height in units specified by units.
units - The units for height. See the UNITS_* constants in the Ui class.
Returns:
The font most closely matching the parameters.
See Also:
Font
Since:
BlackBerry API 3.7.0

getFontFamilies

public static FontFamily[] getFontFamilies()
Return an array containing all registered font families.

Returns:
Array of registered font family objects.

getTypefaceType

public int getTypefaceType()
Get the typeface type.

Returns:
The typeface type.
Since:
BlackBerry API 5.0.0

getHeights

public int[] getHeights()
Returns an array of heights in pixels supported by this font family.

Returns:
Array of heights.

getName

public final String getName()
Returns the font family's name.

Returns:
The fanily name.

toString

public String toString()
Retrieves a string representation of a font family. This is in fact the family's name.

Overrides:
toString in class Object
Returns:
String representation of this font family.

isHeightSupported

public final boolean isHeightSupported(int height)
Determines if this font family supports a specific height.

Parameters:
height - A font height in pixels.
Returns:
true if this font family supports height.

isStyleSupported

public boolean isStyleSupported(int style)
Determines if this font family supports a specific style.

Use this method to determine if this font family supports a given font style.

Subclasses of FontFamily must implement this method. We recommend that this method should return true only if every font contained in the font family supports the specified style.

Parameters:
style - Font style you want to check (that is, PLAIN, BOLD, and so on.)
Returns:
This method always returns true.
See Also:
Font

getFonts

public Font[] getFonts()
Deprecated. Use FontFamily.getFont(int, int)

Returns fonts in all sizes supported by this family.

If this font family supports scalable fonts, this method should return null.

Returns:
Array of Font objects supported by this family.

equals

public boolean equals(Object object)
Compares one font family to another.

Overrides:
equals in class Object
Parameters:
object - The other font family object.
Returns:
true if the two font families are the same.
See Also:
Boolean.hashCode(), Hashtable
Since:
BlackBerry API 3.7.0

hashCode

public int hashCode()
Returns the hash code based on font family. Warning: The hash code is based on the String value of the FontFamily. Thus, two unique FontFamilys may have the same hash code.

Overrides:
hashCode in class Object
Returns:
hash code for this FontFamily object
See Also:
Object.equals(java.lang.Object), Hashtable
Since:
BlackBerry API 5.0.0





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