java.awt
Class FontMetrics
java.lang.Object
|
+--java.awt.FontMetrics
All Implemented Interfaces:
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:
- getAscent
- getDescent
- getLeading()
- getMaxAdvance()
- charWidth(char)
- charsWidth(char[], int, int)
Author:- Aaron M. Renn (arenn@urbanophile.com)
font
protected Font font
This is the font for which metrics will be returned.
FontMetrics
protected FontMetrics(java.awt.Font font)
Initializes a new instance of FontMetrics
for the
specified font.
Parameters:
bytesWidth
public int bytesWidth(byte[] buf, int offset, int len)
Returns the total width of the specified byte array.
Parameters:
Returns:
- The width of the requested characters.
charWidth
public int charWidth(char ch)
Returns the width of the specified character.
Parameters:
Returns:
- The width of the specified character.
charWidth
public int charWidth(int ch)
Returns the width of the specified character.
Parameters:
Returns:
- The width of the specified character.
charsWidth
public int charsWidth(char[] buf, int offset, int len)
Returns the total width of the specified character array.
Parameters:
Returns:
- The width of the requested characters.
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:
- The font for this object.
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:
- The width of the widest character in the font.
getMaxAscent
public int getMaxAscent()
Returns the maximum ascent value. This is the maximum distance any
character in the font rised above the baseline.
Returns:
- The maximum ascent for this font.
getMaxDecent
public int getMaxDecent()
Returns the maximum descent value. This is the maximum distance any
character in the font extends below the baseline.
Returns:
- The maximum descent for this font.
getMaxDescent
public int getMaxDescent()
Returns the maximum descent value. This is the maximum distance any
character in the font extends below the baseline.
Returns:
- The maximum descent for this font.
getWidths
public int[] getWidths()
Returns the widths of the first 256 characters in the font.
Returns:
- The widths of the first 256 characters in the font.
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:
- A string representation of this object.