net.rim.device.api.ui
Class Font

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

public class Font
extends Object

A font is a set of glyphs in a certain style and size, and an associated set of metrics describing their placement and overall size. Font objects are immutable, allowing references to Font objects to be used freely with the guarantee that they will always refer to the same style and size.

The size of a font is the height of an imaginary rectangle, the 'em square', in which the glyphs are drawn.

A glyph is drawn relative to its origin, which is a point on the baseline of the line. After the glyph is drawn, the current drawing position is moved by the advance.

The total vertical space used to display the glyph (the block height is equal to the leading plus the ascent (the space reserved to draw the glyph above the baseline) plus the descent (the space reserved to draw the glyph below the baseline).

Font sizes normally refer to the font's block height, which includes leading, but can optionally refer to the height excluding leading (the sum of ascent and descent) if the flag HEIGHT_EXCLUDES_LEADING is used.

When fonts are created their heights can be given in various units including points, millimeters and pixels; but font metrics obtained by inquiry functions are always given in pixels.

Transformations can be used to scale, rotate, and otherwise modify the glyphs of a font. Their principal use is in scaling web pages. The transformation is applied after hinting, therefore the relative proportions and metrics all scale by the same amount. For a good explanation of how to use transformations, using the same notation that is used here in the documentation of the Font and FontFamily classes, see http://www.adobe.com/products/postscript/pdfs/PLRM.pdf, pages 187-189.


Field Summary
static int ANTIALIAS_LOW_RES
          Anti-aliasing using 16 intensity levels.
static int ANTIALIAS_NONE
          No anti-aliasing.
static int ANTIALIAS_STANDARD
          Anti-aliasing using 256 intensity levels.
static int ANTIALIAS_SUBPIXEL
          Anti-aliasing by treating the three sub-pixels of a pixel on an LCD display separately.
static int APPLICATION
          In a global event, check this flag to see if the change was an application or a global one.
static int ARABIC_SCRIPT
          A script flag to select the Arabic script.
static int ARMENIAN_SCRIPT
          A script flag to select the Armenian script.
static int BENGALI_SCRIPT
          A script flag to select the Bengali script.
static int BOLD
          A style bit for bold-face.
static int BROKEN_LINE_UNDERLINED
          A style bit for broken underlining.
static int CJK_SCRIPT
          A script flag to select the CJK script (Han ideographs used in Chinese, Japanese and Korean).
static int CURSIVE_STYLE
          A style value to select a cursive font.
static int CYRILLIC_SCRIPT
          A script flag to select the Cyrillic script.
static int DEVANAGARI_SCRIPT
          A script flag to select the Devanagari script.
static int DOTTED_UNDERLINED
          A style bit for dotted underlining.
static int ETHIOPIC_SCRIPT
          A script flag to select the Ethiopic script.
static int EXTRA_BOLD
          A style bit for extra-bold.
static int FANTASY_STYLE
          A style value to select a fantasy font as described in http://www.w3.org/TR/CSS2/fonts.html#generic-font-families.
static int GEORGIAN_SCRIPT
          A script flag to select the Georgian script.
static int GREEK_SCRIPT
          A script flag to select the Greek script.
static long GUID_FONT_CHANGED
          The GUID for the global event sent when the system font changes.
static int GUJARATI_SCRIPT
          A script flag to select the Gujarati script.
static int GURMUKHI_SCRIPT
          A script flag to select the Gurmukhi script.
static int HANGUL_SCRIPT
          A script flag to select the Hangul (Korean) script.
static int HEBREW_SCRIPT
          A script flag to select the Hebrew script.
static int HIRAGANA_SCRIPT
          A script flag to select the Hiragana script.
static int ITALIC
          A style bit for italics.
static int KANNADA_SCRIPT
          A script flag to select the Kannada script.
static int KATAKANA_SCRIPT
          A script flag to select the Katakana script.
static int KHMER_SCRIPT
          A script flag to select the Khmer (Cambodian) script.
static int LAO_SCRIPT
          A script flag to select the Lao script.
static int LATIN_SCRIPT
          A script flag to select the Latin script.
static int MALAYALAM_SCRIPT
          A script flag to select the Malayalam script.
static int MONGOLIAN_SCRIPT
          A script flag to select the Mongolian script.
static int MYANMAR_SCRIPT
          A script flag to select the Myanmar (Burmese) script.
static int ORIYA_SCRIPT
          A script flag to select the Oriya script.
static int PLAIN
          A style value: plain, not bold, italic, underlined, etc.
static int SANS_SERIF_STYLE
          A style value to select a sans-serif font.
static int SERIF_STYLE
          A style value to select a serif font.
static int SERIF_STYLE_MASK
          The serif/sans-serif style is stored in these two bits in the style flags.
static int SINHALA_SCRIPT
          A script flag to select the Sinhala script.
static int STRIKE_THROUGH
          A style bit for strike-through.
static int TAMIL_SCRIPT
          A script flag to select the Tamil script.
static int TELUGU_SCRIPT
          A script flag to select the Telugu script.
static int THAI_SCRIPT
          A script flag to select the Thai script.
static int TIBETAN_SCRIPT
          A script flag to select the Tibetan script.
static int UNDERLINED
          A style bit for underlining.
static int UNSPECIFIED_SERIF_STYLE
          A style value for an unspecified serif/sans-serif style.
static int WAVY_UNDERLINED
          A style bit for wavy underlining.
 
Method Summary
 Font derive(int style)
          Creates a new font that is the same except for the specified style.
 Font derive(int style, int height)
          Creates a new font that is the same except for the specified style and height.
 Font derive(int style, int height, int units)
          Creates a new font that is the same except for the specified style and height.
 Font derive(int style, int height, int units, int aAntialiasMode, int aEffects)
          Creates a new font that is the same except for the specified style, height, anti-alias mode, and effects.
 Font derive(int style, int height, int units, int aAntialiasMode, int aEffects, int aA, int aB, int aC, int aD, int aTx, int aTy)
          Creates a new font that is the same except for the specified style, height, anti-alias mode, effects and affine transform.
 Font derive(int style, int height, int units, int aAntialiasMode, int aEffects, int[] aTransform)
          Creates a new font that is the same except for the specified style, height, anti-alias mode, effects and affine transform.
 int getAdvance(char aChar)
          Returns the advance width of a character.
 int getAdvance(char[] aText, int aOffset, int aLength)
          Returns the advance width of a substring of some text.
 int getAdvance(String aText)
          Returns the advance width of some text.
 int getAdvance(String aText, int aOffset, int aLength)
          Returns the advance width of a substring of some text.
 int getAdvance(StringBuffer aText, int aOffset, int aLength)
          Returns the advance width of a substring of some text.
 int getAntialiasMode()
          Returns the anti-alias mode.
 int getAscent()
          Returns the ascent height.
 int getBaseline()
          Returns the baseline position.
 int getBounds(char aChar)
          Returns the horizontal width needed to draw a character: which is the maximum of the advance width and the width of the inked pixels.
 int getBounds(char[] aText, int aOffset, int aLength)
          Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.
 int getBounds(String aText)
          Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.
 int getBounds(String aText, int aOffset, int aLength)
          Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.
 int getBounds(StringBuffer aText)
          Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.
 int getBounds(StringBuffer aText, int aOffset, int aLength)
          Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.
static Font getDefault()
          Returns the default font.
 int getDescent()
          Returns the font's descent.
 FontFamily getFontFamily()
          Returns the font family containing this font.
 int getHeight()
          Returns the font's height.
 int getHeight(int units)
          Returns the font's height.
 int getLeading()
          Returns the font's leading.
 String getName(int aNameCode)
          Gets one of the font's name or other strings (e.g., copyright, family, version, license, etc.).
 int getStyle()
          Returns the font's style flags - bold, italic, underline, strikethrough, etc.
 boolean isBold()
          Determines if this font is bold.
 boolean isItalic()
          Determines if this font is italic.
 boolean isPlain()
          Determines if this font is plain.
 boolean isUnderlined()
          Determines if this font is underlined.
static void setDefaultFont(Font aDefaultFont)
          Deprecated. Use FontManager.setApplicationFont(net.rim.device.api.ui.Font).
 String toString()
          Retrieves the font name as a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 



Field Detail

PLAIN

public static final int PLAIN
A style value: plain, not bold, italic, underlined, etc.

See Also:
Constant Field Values

BOLD

public static final int BOLD
A style bit for bold-face.

See Also:
Constant Field Values

ITALIC

public static final int ITALIC
A style bit for italics.

See Also:
Constant Field Values

UNDERLINED

public static final int UNDERLINED
A style bit for underlining.

See Also:
Constant Field Values

DOTTED_UNDERLINED

public static final int DOTTED_UNDERLINED
A style bit for dotted underlining. {@link #UNDERLINED) must also be set.

See Also:
Constant Field Values

BROKEN_LINE_UNDERLINED

public static final int BROKEN_LINE_UNDERLINED
A style bit for broken underlining. {@link #UNDERLINED) must also be set.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

STRIKE_THROUGH

public static final int STRIKE_THROUGH
A style bit for strike-through.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

EXTRA_BOLD

public static final int EXTRA_BOLD
A style bit for extra-bold. Note: at small sizes, depending on the font, extra-bold may not differ from ordinary bold-face.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

WAVY_UNDERLINED

public static final int WAVY_UNDERLINED
A style bit for wavy underlining. {@link #UNDERLINED) must also be set.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

SERIF_STYLE_MASK

public static final int SERIF_STYLE_MASK
The serif/sans-serif style is stored in these two bits in the style flags.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

UNSPECIFIED_SERIF_STYLE

public static final int UNSPECIFIED_SERIF_STYLE
A style value for an unspecified serif/sans-serif style.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

SANS_SERIF_STYLE

public static final int SANS_SERIF_STYLE
A style value to select a sans-serif font.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

SERIF_STYLE

public static final int SERIF_STYLE
A style value to select a serif font.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CURSIVE_STYLE

public static final int CURSIVE_STYLE
A style value to select a cursive font.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

FANTASY_STYLE

public static final int FANTASY_STYLE
A style value to select a fantasy font as described in http://www.w3.org/TR/CSS2/fonts.html#generic-font-families.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ANTIALIAS_NONE

public static final int ANTIALIAS_NONE
No anti-aliasing.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ANTIALIAS_STANDARD

public static final int ANTIALIAS_STANDARD
Anti-aliasing using 256 intensity levels.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ANTIALIAS_SUBPIXEL

public static final int ANTIALIAS_SUBPIXEL
Anti-aliasing by treating the three sub-pixels of a pixel on an LCD display separately.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ANTIALIAS_LOW_RES

public static final int ANTIALIAS_LOW_RES
Anti-aliasing using 16 intensity levels.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

GUID_FONT_CHANGED

public static final long GUID_FONT_CHANGED
The GUID for the global event sent when the system font changes.

See Also:
Constant Field Values

APPLICATION

public static final int APPLICATION
In a global event, check this flag to see if the change was an application or a global one.

See Also:
Constant Field Values

LATIN_SCRIPT

public static final int LATIN_SCRIPT
A script flag to select the Latin script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

GREEK_SCRIPT

public static final int GREEK_SCRIPT
A script flag to select the Greek script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CYRILLIC_SCRIPT

public static final int CYRILLIC_SCRIPT
A script flag to select the Cyrillic script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ARMENIAN_SCRIPT

public static final int ARMENIAN_SCRIPT
A script flag to select the Armenian script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

HEBREW_SCRIPT

public static final int HEBREW_SCRIPT
A script flag to select the Hebrew script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ARABIC_SCRIPT

public static final int ARABIC_SCRIPT
A script flag to select the Arabic script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

DEVANAGARI_SCRIPT

public static final int DEVANAGARI_SCRIPT
A script flag to select the Devanagari script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

BENGALI_SCRIPT

public static final int BENGALI_SCRIPT
A script flag to select the Bengali script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

GURMUKHI_SCRIPT

public static final int GURMUKHI_SCRIPT
A script flag to select the Gurmukhi script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

GUJARATI_SCRIPT

public static final int GUJARATI_SCRIPT
A script flag to select the Gujarati script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ORIYA_SCRIPT

public static final int ORIYA_SCRIPT
A script flag to select the Oriya script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

TAMIL_SCRIPT

public static final int TAMIL_SCRIPT
A script flag to select the Tamil script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

TELUGU_SCRIPT

public static final int TELUGU_SCRIPT
A script flag to select the Telugu script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

KANNADA_SCRIPT

public static final int KANNADA_SCRIPT
A script flag to select the Kannada script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

MALAYALAM_SCRIPT

public static final int MALAYALAM_SCRIPT
A script flag to select the Malayalam script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

SINHALA_SCRIPT

public static final int SINHALA_SCRIPT
A script flag to select the Sinhala script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

THAI_SCRIPT

public static final int THAI_SCRIPT
A script flag to select the Thai script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

LAO_SCRIPT

public static final int LAO_SCRIPT
A script flag to select the Lao script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

TIBETAN_SCRIPT

public static final int TIBETAN_SCRIPT
A script flag to select the Tibetan script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

MYANMAR_SCRIPT

public static final int MYANMAR_SCRIPT
A script flag to select the Myanmar (Burmese) script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

GEORGIAN_SCRIPT

public static final int GEORGIAN_SCRIPT
A script flag to select the Georgian script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

HANGUL_SCRIPT

public static final int HANGUL_SCRIPT
A script flag to select the Hangul (Korean) script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

ETHIOPIC_SCRIPT

public static final int ETHIOPIC_SCRIPT
A script flag to select the Ethiopic script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

KHMER_SCRIPT

public static final int KHMER_SCRIPT
A script flag to select the Khmer (Cambodian) script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

MONGOLIAN_SCRIPT

public static final int MONGOLIAN_SCRIPT
A script flag to select the Mongolian script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

HIRAGANA_SCRIPT

public static final int HIRAGANA_SCRIPT
A script flag to select the Hiragana script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

KATAKANA_SCRIPT

public static final int KATAKANA_SCRIPT
A script flag to select the Katakana script.

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0

CJK_SCRIPT

public static final int CJK_SCRIPT
A script flag to select the CJK script (Han ideographs used in Chinese, Japanese and Korean).

See Also:
Constant Field Values
Since:
BlackBerry API 5.0.0


Method Detail

derive

public Font derive(int style)
Creates a new font that is the same except for the specified style. For example, if this font is a plain font, you can get a bold version by calling derive(Font.BOLD).

Parameters:
style - The new style.

derive

public Font derive(int style,
                   int height)
Creates a new font that is the same except for the specified style and height. A height of zero or less causes the height of the default font to be used. Heights greater than 256 pixels are clamped to 256 pixels.

Parameters:
style - The new style.
height - The new height in pixels.

derive

public Font derive(int style,
                   int height,
                   int units)
Creates a new font that is the same except for the specified style and height. A height of zero or less causes the height of the default font to be used. Heights greater than 256 pixels are clamped to 256 pixels.

Parameters:
style - The new style.
height - The new height, in units specified by units.
units - The units for height. See the UNITS_* constants in the Ui class.
Since:
BlackBerry API 3.7.0

derive

public Font derive(int style,
                   int height,
                   int units,
                   int aAntialiasMode,
                   int aEffects)
Creates a new font that is the same except for the specified style, height, anti-alias mode, and effects. A height of zero or less causes the height of the default font to be used. Heights greater than 256 pixels are clamped to 256 pixels. If the anti-alias mode or effects are illegal the original font is returned unchanged.

Parameters:
style - The new style.
height - The new height, in units specified by units.
units - The units for height. See the UNITS_* constants in the Ui class.
aAntialiasMode - Desired anti-alias mode. See the ANTIALIAS_* constants.
aEffects - Desired glyph effects. See the *_EFFECT constants.
Since:
BlackBerry API 3.7.0

derive

public Font derive(int style,
                   int height,
                   int units,
                   int aAntialiasMode,
                   int aEffects,
                   int[] aTransform)
Creates a new font that is the same except for the specified style, height, anti-alias mode, effects and affine transform. A height of zero or less causes the height of the default font to be used. Heights greater than 256 pixels are clamped to 256 pixels. If the anti-alias mode or effects are illegal the original font is returned unchanged. The affine transform converts 2D coordinates (x, y) to (x', y') using the assignments x' = A * x + C * y + Tx; y' = B * x + D * y + Ty. It can be used to scale, rotate or otherwise modify the appearance of the font. The parameters are 16.16 fixed-point numbers, and the translation parameters Tx and Ty are in pixels. The identity transform (which does nothing) is therefore A=1<<16, B=0, C=0, D=1<<16, Tx=0, Ty=0. The parameters A, B, C, D, Tx and Ty are stored in that order in the six elements of an integer array.

Parameters:
style - The new style.
height - The new height, in units specified by units.
units - The units for height. See the UNITS_* constants in the Ui class.
aAntialiasMode - Desired anti-alias mode. See the ANTIALIAS_* constants.
aEffects - Desired glyph effects. See the *_EFFECT constants.
aTransform - The six elements of the affine transform, as described above.
Since:
BlackBerry API 3.7.0

derive

public Font derive(int style,
                   int height,
                   int units,
                   int aAntialiasMode,
                   int aEffects,
                   int aA,
                   int aB,
                   int aC,
                   int aD,
                   int aTx,
                   int aTy)
Creates a new font that is the same except for the specified style, height, anti-alias mode, effects and affine transform. A height of zero or less causes the height of the default font to be used. Heights greater than 256 pixels are clamped to 256 pixels. If the anti-alias mode or effects are illegal the original font is returned unchanged. The affine transform converts 2D coordinates (x, y) to (x', y') using the assignments x' = A * x + C * y + Tx; y' = B * x + D * y + Ty. It can be used to scale, rotate or otherwise modify the appearance of the font. The parameters are 16.16 fixed-point numbers, and the translation parameters Tx and Ty are in pixels. The identity transform (which does nothing) is therefore A=1<<16, B=0, C=0, D=1<<16, Tx=0, Ty=0.

Parameters:
style - The new style.
height - The new height, in units specified by units.
units - The units for height. See the UNITS_* constants in the Ui class.
aAntialiasMode - Desired anti-alias mode. See the ANTIALIAS_* constants.
aEffects - Desired glyph effects. See the *_EFFECT constants.
aA - The A parameter of the affine transform, as a 16.16 fixed-point number.
aB - The B parameter of the affine transform, as a 16.16 fixed-point number.
aC - The C parameter of the affine transform, as a 16.16 fixed-point number.
aD - The D parameter of the affine transform, as a 16.16 fixed-point number.
aTx - The Tx parameter of the affine transform, as a 16.16 fixed-point number.
aTy - The Ty parameter of the affine transform, as a 16.16 fixed-point number.
Since:
BlackBerry API 3.7.0

getAdvance

public final int getAdvance(String aText)
Returns the advance width of some text.

Parameters:
aText - The text, which may be null.
Returns:
The advance width in pixels.

getAdvance

public int getAdvance(char aChar)
Returns the advance width of a character.

Parameters:
aChar - The character.
Returns:
The advance width in pixels.

getAdvance

public int getAdvance(String aText,
                      int aOffset,
                      int aLength)
               throws IllegalArgumentException
Returns the advance width of a substring of some text.

Parameters:
aText - The text, which may be null if the length is zero.
aOffset - The start offset of the text to be measured.
aLength - The length of the text to be measured; the special value Integer.MAX_VALUE specifies the whole of the text from aOffset onwards.
Returns:
The advance width in pixels.
Throws:
IllegalArgumentException

getAdvance

public int getAdvance(StringBuffer aText,
                      int aOffset,
                      int aLength)
               throws IllegalArgumentException
Returns the advance width of a substring of some text.

Parameters:
aText - The text, which may be null if the length is zero.
aOffset - The start offset of the text to be measured.
aLength - The length of the text to be measured; the special value Integer.MAX_VALUE specifies the whole of the text from aOffset onwards.
Returns:
The advance width in pixels.
Throws:
IllegalArgumentException

getAdvance

public int getAdvance(char[] aText,
                      int aOffset,
                      int aLength)
               throws IllegalArgumentException
Returns the advance width of a substring of some text.

Parameters:
aText - The text, which may be null if the length is zero.
aOffset - The start offset of the text to be measured.
aLength - The length of the text to be measured; the special value Integer.MAX_VALUE specifies the whole of the text from aOffset onwards.
Returns:
The advance width in pixels.
Throws:
IllegalArgumentException

getAntialiasMode

public int getAntialiasMode()
Returns the anti-alias mode.

Since:
BlackBerry API 5.0.0

getAscent

public int getAscent()
Returns the ascent height.

Use this method to retrieve the height, in pixels, reserved for drawing glyphs above the baseline.

Returns:
Ascent for this font, in pixels.

getBaseline

public int getBaseline()
Returns the baseline position.

Use this method to retrieve the position of this font's baseline, in pixels from the top of the font.

Notice that this.getBaseline - this.getAscent produces the amount of leading at the top of this font.

Returns:
Baseline position, in pixels from the top.

getDefault

public static Font getDefault()
Returns the default font.

If the current application doesn't have a default font, it automatically inherits (and this method returns) the current system font.

Returns:
Application's current default font. If no default is set for the application, return the system font. If the system font cannot be found, then return null (this should be treated as an unrecoverable error).

getDescent

public int getDescent()
Returns the font's descent.

Use this method to retrieve the height, in pixels, reserved for drawing glyphs below the baseline.

Returns:
Descent of this font, in pixels.

getFontFamily

public FontFamily getFontFamily()
Returns the font family containing this font.

Returns:
Font family object for this current font.

getHeight

public int getHeight()
Returns the font's height.

Use this method to retrieve this font's "block" height (the drawing area for glyphs plus the leading). It is the actual height, after the font transformation has been applied.

Returns:
The font height in pixels.

getHeight

public int getHeight(int units)
Returns the font's height.

Use this method to retrieve this font's "block" height (the drawing area for glyphs plus the leading). It is the actual height, after the font transformation has been applied.

Parameters:
units - The units in which to return the height; must be one of Ui.UNITS_*.
Returns:
The font height in the specified units.
Since:
BlackBerry API 5.0.0

getLeading

public int getLeading()
Returns the font's leading.

Use this method to retrieve this font's leading (pixels in font blocks reserved for inter-line spacing). In our font system, a font's leading height is drawn principally at the top of the font "block" height.

Returns:
Leading of this font in pixels.

getStyle

public int getStyle()
Returns the font's style flags - bold, italic, underline, strikethrough, etc.

Returns:
Bitfield containing this font's style.
See Also:
Font.isBold(), Font.isItalic(), Font.isPlain()

isBold

public boolean isBold()
Determines if this font is bold.

Returns:
True if this font has the Font.BOLD or Font.EXTRA_BOLD style; otherwise false.

isItalic

public boolean isItalic()
Determines if this font is italic.

Returns:
True if this font has the Font.ITALIC style; otherwise false.

isUnderlined

public boolean isUnderlined()
Determines if this font is underlined.

Returns:
True if this font has the Font.UNDERLINED style; otherwise false.

isPlain

public boolean isPlain()
Determines if this font is plain.

Returns:
True if this font is not bold, italic, underlined or struck through; false otherwise.

getBounds

public int getBounds(String aText)
Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.

Parameters:
aText - The text: may be null.
Returns:
The width in pixels.
Since:
BlackBerry API 5.0.0

getBounds

public int getBounds(StringBuffer aText)
Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.

Parameters:
aText - The text: may be null.
Returns:
The width in pixels.
Since:
BlackBerry API 5.0.0

getBounds

public int getBounds(char aChar)
Returns the horizontal width needed to draw a character: which is the maximum of the advance width and the width of the inked pixels.

Parameters:
aChar - The character.
Returns:
The width in pixels.
Since:
BlackBerry API 5.0.0

getBounds

public int getBounds(StringBuffer aText,
                     int aOffset,
                     int aLength)
              throws IllegalArgumentException
Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.

Parameters:
aText - The text to measure; may be null only if aLength is 0.
aOffset - Start offset of the substring.
aLength - Length of substring.
Returns:
The width in pixels.
Throws:
IllegalArgumentException
Since:
BlackBerry API 5.0.0

getBounds

public int getBounds(String aText,
                     int aOffset,
                     int aLength)
              throws IllegalArgumentException
Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.

Parameters:
aText - The text to measure; may be null only if aLength is 0.
aOffset - Start offset of the substring.
aLength - Length of substring.
Returns:
The width in pixels.
Throws:
IllegalArgumentException
Since:
BlackBerry API 5.0.0

getBounds

public int getBounds(char[] aText,
                     int aOffset,
                     int aLength)
              throws IllegalArgumentException
Returns the horizontal width needed to draw a text string: which is the maximum of the advance width and the width of the inked pixels.

Parameters:
aText - The text to measure; may be null only if aLength is 0.
aOffset - Start offset of the substring.
aLength - Length of substring.
Returns:
The width in pixels.
Throws:
IllegalArgumentException
Since:
BlackBerry API 5.0.0

setDefaultFont

public static void setDefaultFont(Font aDefaultFont)
Deprecated. Use FontManager.setApplicationFont(net.rim.device.api.ui.Font).

Sets the default font for this 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 this application that the font has been changed.

Parameters:
aDefaultFont - Font to set as default; if null, application inherits the default system font.
Since:
BlackBerry API 3.6.0

toString

public String toString()
Retrieves the font name as a string.

You should not use this method to compare two fonts, particularly because the style value is internationalized and therefore changes from locale to locale.

Overrides:
toString in class Object
Returns:
Combination of the family name, size in pixels and style of this font.

getName

public String getName(int aNameCode)
Gets one of the font's name or other strings (e.g., copyright, family, version, license, etc.).

Parameters:
aNameCode - the name code as defined for the TrueType and OpenType 'name' table.
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.