|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
waba.lang.Object | +--waba.fx.FontMetrics
FontMetrics computes font metrics including string width and height.
FontMetrics are usually used to obtain information about the widths and heights of characters and strings when drawing text on a surface. A FontMetrics object references a font and surface since fonts may have different metrics on different surfaces.
Here is an example that uses FontMetrics to get the width of a string:
...
Font font = new Font("Helvetica", Font.BOLD, 10);
FontMetrics fm = getFontMetrics();
String s = "This is a line of text.";
int stringWidth = fm.getTextWidth(s);
...
| Constructor Summary | |
FontMetrics(Font font,
ISurface surface)
Constructs a font metrics object referencing the given font and surface. |
|
| Method Summary | |
int |
getAscent()
Returns the ascent of the font. |
int |
getCharWidth(char c)
Returns the width of the given character in pixels. |
int |
getDescent()
Returns the descent of a font. |
int |
getHeight()
Returns the height of the referenced font. |
int |
getLeading()
Returns the external leading which is the space between lines. |
int |
getTextWidth(char[] chars,
int start,
int count)
Returns the width of the given text in pixels. |
int |
getTextWidth(String s)
Returns the width of the given text string in pixels. |
| Methods inherited from class waba.lang.Object |
toString |
| Constructor Detail |
public FontMetrics(Font font,
ISurface surface)
If you are trying to create a font metrics object in a Control subclass, use the getFontMetrics() method in the Control class.
Control.getFontMetrics(waba.fx.Font font)| Method Detail |
public int getAscent()
public int getCharWidth(char c)
public int getDescent()
public int getHeight()
public int getLeading()
public int getTextWidth(String s)
public int getTextWidth(char[] chars,
int start,
int count)
chars - the text character arraystart - the start position in arraycount - the number of characters
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||