|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Font
public class Font
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_DEFAULT
Default anti-aliasing: the anti-alias mode which best suits the font technology. |
|
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. |
|
FontSpec |
getFontSpec()
Returns an instance of the FontSpec class. |
|
int |
getHeight()
Returns the 'em-square' height of the font based on the capital M glyph in the Latin character set. |
|
int |
getHeight(int units)
This method behaves in the same way as Font.getHeight() but allows control over the unit of measurement
for the returned height value. |
|
int |
getLeading()
Returns the font's leading. |
|
void |
getMetrics(FontMetrics aFontMetrics)
Returns the font metrics. |
|
void |
getMetrics(FontMetrics aFontMetrics,
int aScripts)
Gets font metrics for the combination of available fonts supporting the specified scripts, and matching this font as closely as possible. |
|
void |
getMetrics(FontMetrics aFontMetrics,
int aScripts,
int aLocale)
Gets font metrics for the combination of available fonts supporting the specified scripts, and matching this font as closely as possible. |
|
void |
getMetricsForLocale(FontMetrics aFontMetrics,
int aLocale)
Gets font metrics for the combination of available fonts supporting the specified locale, and matching this font as closely as possible. |
|
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. |
|
int |
measureText(char[] aText,
int aOffset,
int aLength,
DrawTextParam aParam,
TextMetrics aMetrics)
Measures some text. |
|
int |
measureText(String aText,
int aOffset,
int aLength,
DrawTextParam aParam,
TextMetrics aMetrics)
Measures some text. |
|
int |
measureText(StringBuffer aText,
int aOffset,
int aLength,
DrawTextParam aParam,
TextMetrics aMetrics)
Measures some text. |
|
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 |
---|
public static final int PLAIN
public static final int BOLD
public static final int ITALIC
public static final int UNDERLINED
public static final int DOTTED_UNDERLINED
public static final int BROKEN_LINE_UNDERLINED
public static final int STRIKE_THROUGH
public static final int EXTRA_BOLD
public static final int WAVY_UNDERLINED
public static final int SERIF_STYLE_MASK
public static final int UNSPECIFIED_SERIF_STYLE
public static final int SANS_SERIF_STYLE
public static final int SERIF_STYLE
public static final int CURSIVE_STYLE
public static final int FANTASY_STYLE
public static final int ANTIALIAS_DEFAULT
public static final int ANTIALIAS_NONE
public static final int ANTIALIAS_STANDARD
public static final int ANTIALIAS_SUBPIXEL
public static final int ANTIALIAS_LOW_RES
public static final long GUID_FONT_CHANGED
public static final int APPLICATION
public static final int LATIN_SCRIPT
public static final int GREEK_SCRIPT
public static final int CYRILLIC_SCRIPT
public static final int ARMENIAN_SCRIPT
public static final int HEBREW_SCRIPT
public static final int ARABIC_SCRIPT
public static final int DEVANAGARI_SCRIPT
public static final int BENGALI_SCRIPT
public static final int GURMUKHI_SCRIPT
public static final int GUJARATI_SCRIPT
public static final int ORIYA_SCRIPT
public static final int TAMIL_SCRIPT
public static final int TELUGU_SCRIPT
public static final int KANNADA_SCRIPT
public static final int MALAYALAM_SCRIPT
public static final int SINHALA_SCRIPT
public static final int THAI_SCRIPT
public static final int LAO_SCRIPT
public static final int TIBETAN_SCRIPT
public static final int MYANMAR_SCRIPT
public static final int GEORGIAN_SCRIPT
public static final int HANGUL_SCRIPT
public static final int ETHIOPIC_SCRIPT
public static final int KHMER_SCRIPT
public static final int MONGOLIAN_SCRIPT
public static final int HIRAGANA_SCRIPT
public static final int KATAKANA_SCRIPT
public static final int CJK_SCRIPT
Method Detail |
---|
public Font derive(int style)
derive(Font.BOLD)
.
style
- The new style.public Font derive(int style, int height)
style
- The new style.height
- The new height in pixels.public Font derive(int style, int height, int units)
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.public Font derive(int style, int height, int units, int aAntialiasMode, int aEffects)
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.
The ANTIALIAS_SUBPIXEL mode is not currently supported by the font engine.aEffects
- Desired glyph effects. See the *_EFFECT constants.public Font derive(int style, int height, int units, int aAntialiasMode, int aEffects, int[] aTransform)
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.
The ANTIALIAS_SUBPIXEL mode is not currently supported by the font engine.aEffects
- Desired glyph effects. See the *_EFFECT constants.aTransform
- The six elements of the affine transform, as described above.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)
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.
The ANTIALIAS_SUBPIXEL mode is not currently supported by the font engine.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.public FontSpec getFontSpec()
FontSpec
class.
public final int getAdvance(String aText)
aText
- The text, which may be null.
public int getAdvance(char aChar)
aChar
- The character.
public int getAdvance(String aText, int aOffset, int aLength) throws IllegalArgumentException
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.
IllegalArgumentException
public int getAdvance(StringBuffer aText, int aOffset, int aLength) throws IllegalArgumentException
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.
IllegalArgumentException
public int getAdvance(char[] aText, int aOffset, int aLength) throws IllegalArgumentException
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.
IllegalArgumentException
public int getAntialiasMode()
public int getAscent()
Use this method to retrieve the height, in pixels, reserved for drawing glyphs above the baseline.
public int getBaseline()
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.
public static Font getDefault()
If the current application doesn't have a default font, it automatically inherits (and this method returns) the current system font.
public int getDescent()
Use this method to retrieve the height, in pixels, reserved for drawing glyphs below the baseline.
public FontFamily getFontFamily()
public int getHeight()
Use this method to retrieve the 'em-square' height value, which is the height of the capital M glyph of the Latin character set based on the current font settings.
This method does not return the actual height of the text. Instead it returns the height of the imaginary rectangle created by the glyph of the capital Latin letter, M.
Refer to measureText
if the actual height of the text is desired.
public int getHeight(int units)
Font.getHeight()
but allows control over the unit of measurement
for the returned height value.
units
- The units in which to return the height; must be one of Ui.UNITS_*
public int getLeading()
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.
public int getStyle()
Font.isBold()
,
Font.isItalic()
,
Font.isPlain()
public boolean isBold()
Font.BOLD
or Font.EXTRA_BOLD
style; otherwise false.public boolean isItalic()
Font.ITALIC
style; otherwise false.public boolean isUnderlined()
Font.UNDERLINED
style; otherwise
false.public boolean isPlain()
public int measureText(String aText, int aOffset, int aLength, DrawTextParam aParam, TextMetrics aMetrics) throws IllegalArgumentException
aText
- The text to measure; may be null only if aLength is 0.aOffset
- Start offset of the substring.aLength
- Length of substring.aParam
- Parameters to control the measurement.aMetrics
- Full text metrics for the given substring.
IllegalArgumentException
public int measureText(StringBuffer aText, int aOffset, int aLength, DrawTextParam aParam, TextMetrics aMetrics) throws IllegalArgumentException
aText
- The text to measure; may be null only if aLength is 0.aOffset
- Start offset of the substring.aLength
- Length of substring.aParam
- Parameters to control the measurement.aMetrics
- Full text metrics for the given substring.
IllegalArgumentException
public int measureText(char[] aText, int aOffset, int aLength, DrawTextParam aParam, TextMetrics aMetrics) throws IllegalArgumentException
aText
- The text to measure; may be null only if aLength is 0.aOffset
- Start offset of the substring.aLength
- Length of substring.aParam
- Parameters to control the measurement.aMetrics
- Full text metrics for the given substring.
IllegalArgumentException
public int getBounds(String aText)
aText
- The text: may be null.
public int getBounds(StringBuffer aText)
aText
- The text: may be null.
public int getBounds(char aChar)
aChar
- The character.
public int getBounds(StringBuffer aText, int aOffset, int aLength) throws IllegalArgumentException
aText
- The text to measure; may be null only if aLength is 0.aOffset
- Start offset of the substring.aLength
- Length of substring.
IllegalArgumentException
public int getBounds(String aText, int aOffset, int aLength) throws IllegalArgumentException
aText
- The text to measure; may be null only if aLength is 0.aOffset
- Start offset of the substring.aLength
- Length of substring.
IllegalArgumentException
public int getBounds(char[] aText, int aOffset, int aLength) throws IllegalArgumentException
aText
- The text to measure; may be null only if aLength is 0.aOffset
- Start offset of the substring.aLength
- Length of substring.
IllegalArgumentException
public void getMetrics(FontMetrics aFontMetrics)
aFontMetrics
- the font metrics to be filled in.
Equivalent to calling the three-parameter version of getMetrics with aScripts = 0 and aLocale = 0.public void getMetrics(FontMetrics aFontMetrics, int aScripts)
aFontMetrics
- the font metrics to be filled in.aScripts
- a bit field representing the required scriptspublic void getMetricsForLocale(FontMetrics aFontMetrics, int aLocale)
aFontMetrics
- the font metrics to be filled in.aLocale
- if non-zero, a locale codepublic void getMetrics(FontMetrics aFontMetrics, int aScripts, int aLocale)
aMetrics.getAscent()
,
aMetrics.getDescent()
, etc.
If aLocale is non-zero, it does two things: (i) it sets the Han style, and (ii) it causes
extra scripts to be examined if necessary. Therefore to get metrics for a given locale
it is adequate to set aLocale to the locale number, while setting aScripts to zero.
The returned metrics are the maximum values found in any of the typefaces examined.
If both aScripts and aLocale are zero the font's own metrics are returned.
aFontMetrics
- the font metrics to be filled in.aScripts
- a bit field representing the required scriptsaLocale
- if non-zero, a locale code specifying further scriptspublic static void setDefaultFont(Font aDefaultFont)
FontManager.setApplicationFont(net.rim.device.api.ui.Font)
.
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.
aDefaultFont
- Font to set as default; if null, application inherits
the default system font.public String toString()
You should not use this method to compare two fonts, particularly because the style value is internationalized and therefore changes from locale to locale.
toString
in class Object
public String getName(int aNameCode)
aNameCode
- the name code as defined for the TrueType and OpenType 'name' table.
|
|||||||||
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