Class FxFontMetrics
public abstract class FxFontMetrics extends FontMetrics
{
// Fields
public final static int CHAR_KERNING;
// Constructors
public FxFontMetrics(Font font);
public FxFontMetrics(Font font, Graphics g);
// Methods
public boolean canDrawOutline();
public int charsWidth(char data[], int off, int len, int options,
int dx[]);
public void charsWidth(int start, int len, int options, int dx[]);
public int getAveCharWidth();
public String getFace();
public static synchronized FontMetrics getFontMetrics(Font font);
public static synchronized FontMetrics getFontMetrics(Graphics g,
Font font);
public int getMaxAdvance();
public int stringWidth(String str, int options, int dx[]);
}
This class manages extended font metrics objects.
FontMetrics
|
+--FxFontMetrics
public FxFontMetrics(Font font);
Calculates the metrics of the given font.
Parameter | Description |
font
| The Font object that the metrics are calculated for.
|
public FxFontMetrics(Font font, Graphics g);
Calculates the metrics of the given font, based on the Graphics object that is currently using the font.
Parameter | Description |
font
| The font object that the metrics are calculated for.
|
g
| The graphics context that the font is associated with.
|
public boolean canDrawOutline();
Determines whether the font can be drawn in outline mode.
Return Value:
Returns true if the font can be drawn in outline mode; otherwise, returns false.
public int charsWidth(char data[], int off, int len, int options, int dx[]);
Retrieves the widths of characters in the specified character array fragment (in pixels).
Return Value:
Returns the width of the given character array.
Parameter | Description |
data
| The character array to measure.
|
off
| The offset in the array to start measuring from.
|
len
| The number of offsets to measure.
|
options
| Determines if CHAR_KERNING is used.
|
dx
| If dx is non-null, it will be filled in with the widths of the characters, starting from off, not necessarily from zero.
|
Exceptions:
NullPointerException
if the character array is null.
public void charsWidth(int start, int len, int options, int dx[]);
Retrieves the widths of a range of Unicode characters, measured in the current font (in pixels).
Return Value:
No return value.
Parameter | Description |
start
| The offset in the array to start measuring from.
|
len
| The number of offsets to measure.
|
options
| Determines if CHAR_KERNING is used.
|
dx
| If dx is non-null, it will be filled in with the widths of the characters.
|
public int getAveCharWidth();
Retrieves the average character width for the current font (in pixels).
Return Value:
Returns the average character width.
public String getFace();
Retrieves the name of the font face that is indicated by the FxFontMetrics object. If there is no font face that matches the name of the font indicated by the object, the method returns the name of the font face that best fits the other attributes of the object.
Return Value:
Returns the name of the font face indicated by the FxFontMetrics object.
public static synchronized FontMetrics getFontMetrics(Font font);
Retrieves the font metrics for a given font on the current platform.
Return Value:
Returns a FontMetrics object that defines the font metrics.
Parameter | Description |
font
| The font for which the platform-specific metrics are calculated for.
|
Remarks: Use this method to create an FxFontMetrics object as well as a FontMetrics object based on the given parameters. You should not simply derive an FxFontMetrics from a FontMetrics. For example,
FxFontMetrics ffm = (FxFontMetrics)FxFontMetrics.getFontMetrics(myFont);
public static synchronized FontMetrics getFontMetrics(Graphics g,
Font font);
Retrieves the font metrics for a given font, drawn in the given graphics context.
Return Value:
Returns a FontMetrics object that defines the font metrics.
Parameter | Description |
font
| The font that the metrics are calculated for.
|
g
| The graphics object that the font is currently selected into.
|
Remarks: Use this method to create an FxFontMetrics object as well as a FontMetrics object based on the given parameters. You should not simply derive an FxFontMetrics from a FontMetrics. For example,
FxFontMetrics ffm = (FxFontMetrics)FxFontMetrics.getFontMetrics(myFont);
public int getMaxAdvance();
Retrieves the maximum advance width of any character in the current font (in pixels).
Return Value:
Returns the maximum amount that the current point is moved from one character to the next in a line of text. Returns -1 if the max advance is not known.
public int stringWidth(String str, int options, int dx[]);
Retrieves the width of the specified string, measured in the current font.
Return Value:
Returns the width of the given string.
Parameter | Description |
str
| The string to measure.
|
options
| Determines if CHAR_KERNING is used.
|
dx
| If dx is non-null, it will be filled in with the widths of the characters in the string.
|
- CHAR_KERNING
- The extended width functions use kerning.