Packages
 In this topic

*Constructors

*Methods

*Fields

 

Packages   PreviousThis PackageNext
Package com.ms.fx   Previous This
Package
Next

 


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

Constructors

FxFontMetrics

public FxFontMetrics(Font font);

Calculates the metrics of the given font.

ParameterDescription
font The Font object that the metrics are calculated for.

FxFontMetrics

public FxFontMetrics(Font font, Graphics g);

Calculates the metrics of the given font, based on the Graphics object that is currently using the font.

ParameterDescription
font The font object that the metrics are calculated for.
g The graphics context that the font is associated with.

Methods

canDrawOutline

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.

charsWidth

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.

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

charsWidth

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.

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

getAveCharWidth

public int getAveCharWidth();

Retrieves the average character width for the current font (in pixels).

Return Value:

Returns the average character width.

getFace

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.

getFontMetrics

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.

ParameterDescription
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);

getFontMetrics

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.

ParameterDescription
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);

getMaxAdvance

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.

stringWidth

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.

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

Fields

CHAR_KERNING
The extended width functions use kerning.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.