net.rim.device.api.ui
Class FontFamily

java.lang.Object
  |
  +--net.rim.device.api.ui.FontFamily

public abstract class FontFamily
extends Object

Represents a typeface (a collection of fonts).

A font family is a collection of font faces (fonts of differing sizes and styles). We recommend that a font family should meet the following criteria:

See Also:
Font

Field Summary
static String FAMILY_SYSTEM
          The system font family.
 
Method Summary
static FontFamily forName(String name)
          Retrieves font family by name.
abstract  Font getFont(int style, int height)
          Retrieves a font specified by style and size.
static FontFamily[] getFontFamilies()
          Retreives manifest of known font families.
abstract  Font[] getFonts()
          Retrieves fonts provided in this family.
abstract  int[] getHeights()
          Retrieves list of heights supported by this font family.
 String getName()
          Retrieves this font family's name.
 boolean isHeightSupported(int height)
          Determines if this font family supports a specific height.
abstract  boolean isStyleSupported(int style)
          Determines if this font family supports a specific style.
 String toString()
          Retrieves a string representation of this font family.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FAMILY_SYSTEM

public static String FAMILY_SYSTEM
The system font family.
Since:
JDE 3.6
Method Detail

forName

public static FontFamily forName(String name)
                          throws ClassNotFoundException
Retrieves font family by name.

Use this method to retrieve the font family object that was registered with your provided name.

Parameters:
name - Fully qualified name of font family you want to find (note that getName() returns only a shortened version of the name, not the fully qualified name). Currently, the permitted value is FAMILY_SYSTEM.
Returns:
An instance of the FontFamily identified by name if one exists; otherwise, null.
Throws:
ClassNotFoundException - If the font could not be found.
Since:
JDE 3.6

getFont

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

Use this method to retrieve a font by specifying the style and size combination you want.

Subclasses of FontFamily must implement this method.

Parameters:
style - Bitmask of desired styles (that is PLAIN, BOLD, and so on).
height - Desired height, in pixels.
Returns:
Font matching your criteria; if no font in this family matches your criteria, this method returns null.
Since:
JDE 3.6
See Also:
Font

getFontFamilies

public static FontFamily[] getFontFamilies()
Retreives manifest of known font families.

Use this method to retrieve an array of all the font families registered with the system.

Returns:
Array of registered font family objects.

getHeights

public abstract int[] getHeights()
Retrieves list of heights supported by this font family.

Subclasses must implement this method as appropriate for their contained fonts.

Returns:
Array of heights supported by this family.

getName

public final String getName()
Retrieves this font family's name.

Returns:
Name of this font family.

toString

public String toString()
Retrieves a string representation of this font family.

By default, this method returns only the font family's name. Subclasses of FontFamily can return a more specific representation by overriding this method.

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.

Use this method to determine if this font family contains a font of a specific font height.

Parameters:
height - Font height you want to check.
Returns:
True if this font family contains a font of the height you specify; otherwise, false.
Since:
JDE 3.6

isStyleSupported

public abstract 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:
True if this font family supports your specified font style; otherwise, false.
Since:
JDE 3.6
See Also:
Font

getFonts

public abstract Font[] getFonts()
Retrieves fonts provided in this family.

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

Note: sublcasses must implement this method.

Returns:
Array of Font objects supported by this family.


Copyright 1999-2002 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.