net.rim.device.api.ui
Class FontSpec

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

public class FontSpec
extends Object

FontSpec is a light weight class wrapping a few key Font parameters: font family, style, and height. Instances of this class are used as arguments for the following OpenVG functions: vgDrawText, vgMeasureText, and vgCreateText.

Since:
BlackBerry API 7.0.0

Field Summary
static int BOLD
          A style bit for bold-face.
static int BROKEN_LINE_UNDERLINED
          A style bit for broken underlining.
static int CURSIVE_STYLE
          A style value to select a cursive font.
static int DOTTED_UNDERLINED
          A style bit for dotted underlining.
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 ITALIC
          A style bit for italics.
static int PLAIN
          A style value: plain, not bold, italic, underlined, etc.
static int STRIKE_THROUGH
          A style bit for strike-through.
static int UNDERLINED
          A style bit for underlining.
static int WAVY_UNDERLINED
          A style bit for wavy underlining.
 
Constructor Summary
FontSpec()
          Creates a new font.
FontSpec(FontFamily family)
          Creates a new font specified by font-family.
FontSpec(FontFamily family, int style)
          Creates a new font specified by font-family and style.
FontSpec(FontFamily family, int style, int height)
          Creates a new font specified by font-family, style and size.
 
Method Summary
 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 getStyle()
          Returns the font's style flags - bold, italic, underline, strikethrough, etc.
 void setFontFamily(FontFamily family)
          Sets font-family.
 void setHeight(int height)
          Sets font height.
 void setHeight(int height, int units)
          Sets font height.
 void setStyle(int style)
          Sets font style - bold, italic, underline, strikethrough, etc.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, 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
Since:
BlackBerry API 7.0.0

BOLD

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

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

ITALIC

public static final int ITALIC
A style bit for italics.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

UNDERLINED

public static final int UNDERLINED
A style bit for underlining.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

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
Since:
BlackBerry API 7.0.0

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 7.0.0

STRIKE_THROUGH

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

See Also:
Constant Field Values
Since:
BlackBerry API 7.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 7.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 7.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 7.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 7.0.0


Constructor Detail

FontSpec

public FontSpec()
Creates a new font. Sets font-family, style, and height to default values.

Since:
BlackBerry API 7.0.0

FontSpec

public FontSpec(FontFamily family)
Creates a new font specified by font-family. Sets style and height to default values.

Parameters:
family - The font-family.
Since:
BlackBerry API 7.0.0

FontSpec

public FontSpec(FontFamily family,
                int style)
Creates a new font specified by font-family and style. Sets height to a default value.

Parameters:
family - The font-family.
style - Bits selecting styles (FontSpec.BOLD, FontSpec.Italic, etc.).
Since:
BlackBerry API 7.0.0

FontSpec

public FontSpec(FontFamily family,
                int style,
                int height)
Creates a new font specified by font-family, style and size.

Parameters:
family - The font-family.
style - Bits selecting styles (FontSpec.BOLD, FontSpec.Italic, etc.).
height - Desired height in pixels.
Since:
BlackBerry API 7.0.0


Method Detail

getFontFamily

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

Returns:
Font font-family object for this current font.
Since:
BlackBerry API 7.0.0

setFontFamily

public void setFontFamily(FontFamily family)
Sets font-family.

Parameters:
family - The font-family.
Since:
BlackBerry API 7.0.0

getStyle

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

Returns:
Bitfield containing this font's style.
Since:
BlackBerry API 7.0.0

setStyle

public void setStyle(int style)
Sets font style - bold, italic, underline, strikethrough, etc.

Parameters:
style - Font style.
Since:
BlackBerry API 7.0.0

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).

Returns:
The font height in pixels.
Since:
BlackBerry API 7.0.0

setHeight

public void setHeight(int height)
Sets font height.

Use this method to set new font block height. (the drawing area for glyphs plus the leading).

Parameters:
height - Font height in pixels.
Since:
BlackBerry API 7.0.0

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).

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 7.0.0

setHeight

public void setHeight(int height,
                      int units)
Sets font height.

Use this method to set new font block height. (the drawing area for glyphs plus the leading).

Parameters:
height - Font height.
units - The units for the font height argument; must be one of Ui.UNITS_*.
Since:
BlackBerry API 7.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