Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class FontMetrics

java.lang.Object
|
+--java.awt.FontMetrics

All Implemented Interfaces:

Serializable


public abstract class FontMetrics

extends Object

implements Serializable

This class returns information about the display characteristics of a font. It is abstract, and concrete subclasses should implement at least the following methods:

Author:

Field Summary

java.awt.Fontfont

This is the font for which metrics will be returned.

Constructor Summary

FontMetrics(java.awt.Font font)

Initializes a new instance of FontMetrics for the specified font.

Method Summary

intbytesWidth(byte[] buf, int offset, int len)

Returns the total width of the specified byte array.
intcharWidth(int ch)

Returns the width of the specified character.
intcharWidth(char ch)

Returns the width of the specified character.
intcharsWidth(char[] buf, int offset, int len)

Returns the total width of the specified character array.
intgetAscent()

Returns the ascent of the font, which is the distance from the base to the top of the majority of characters in the set.
intgetDescent()

Returns the descent of the font, which is the distance from the base to the bottom of the majority of characters in the set.
java.awt.FontgetFont()

Returns the font that this object is creating metric information fo.
intgetHeight()

Returns the height of a line in this font.
intgetLeading()

Returns the leading, or spacing between lines, for this font.
intgetMaxAdvance()

Returns the width of the widest character in the font.
intgetMaxAscent()

Returns the maximum ascent value.
intgetMaxDecent()

Returns the maximum descent value.
intgetMaxDescent()

Returns the maximum descent value.
int[]getWidths()

Returns the widths of the first 256 characters in the font.
intstringWidth(java.lang.String str)

Returns the total width of the specified string
java.lang.StringtoString()

Returns a string representation of this object.

Field Details

font

protected Font font

This is the font for which metrics will be returned.


Constructor Details

FontMetrics

protected FontMetrics(java.awt.Font font)

Initializes a new instance of FontMetrics for the specified font.

Parameters:


Method Details

bytesWidth

public int bytesWidth(byte[] buf, int offset, int len)

Returns the total width of the specified byte array.

Parameters:

Returns:


charWidth

public int charWidth(char ch)

Returns the width of the specified character.

Parameters:

Returns:


charWidth

public int charWidth(int ch)

Returns the width of the specified character.

Parameters:

Returns:


charsWidth

public int charsWidth(char[] buf, int offset, int len)

Returns the total width of the specified character array.

Parameters:

Returns:


getAscent

public int getAscent()

Returns the ascent of the font, which is the distance from the base to the top of the majority of characters in the set. Some characters can exceed this value however.

Returns:


getDescent

public int getDescent()

Returns the descent of the font, which is the distance from the base to the bottom of the majority of characters in the set. Some characters can exceed this value however.

Returns:


getFont

public Font getFont()

Returns the font that this object is creating metric information fo.

Returns:


getHeight

public int getHeight()

Returns the height of a line in this font. This will be the sum of the leading, the ascent, and the descent.

Returns:


getLeading

public int getLeading()

Returns the leading, or spacing between lines, for this font.

Returns:


getMaxAdvance

public int getMaxAdvance()

Returns the width of the widest character in the font.

Returns:


getMaxAscent

public int getMaxAscent()

Returns the maximum ascent value. This is the maximum distance any character in the font rised above the baseline.

Returns:


getMaxDecent

public int getMaxDecent()

Returns the maximum descent value. This is the maximum distance any character in the font extends below the baseline.

Returns:


getMaxDescent

public int getMaxDescent()

Returns the maximum descent value. This is the maximum distance any character in the font extends below the baseline.

Returns:


getWidths

public int[] getWidths()

Returns the widths of the first 256 characters in the font.

Returns:


stringWidth

public int stringWidth(java.lang.String str)

Returns the total width of the specified string

Parameters:

Returns:


toString

public String toString()

Returns a string representation of this object.

Returns: