java.awt
public abstract class FontMetrics extends Object implements Serializable
Field Summary | |
---|---|
protected Font | font
This is the font for which metrics will be returned. |
Constructor Summary | |
---|---|
protected | FontMetrics(Font font)
Initializes a new instance of FontMetrics for the
specified font.
|
Method Summary | |
---|---|
int | bytesWidth(byte[] buf, int offset, int len)
Returns the total width of the specified byte array.
|
int | charsWidth(char[] buf, int offset, int len)
Returns the total width of the specified character array.
|
int | charWidth(int ch)
Returns the width of the specified character.
|
int | charWidth(char ch)
Returns the width of the specified character.
|
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. |
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. |
Font | getFont()
Returns the font that this object is creating metric information fo.
|
int | getHeight()
Returns the height of a line in this font. |
int | getLeading()
Returns the leading, or spacing between lines, for this font.
|
LineMetrics | getLineMetrics(String text, Graphics g)
Returns a {@link LineMetrics} object constructed with the
specified text and the {@link FontRenderContext} of the Graphics
object when it is an instance of Graphics2D or a generic
FontRenderContext with a null transform, not anti-aliased and not
using fractional metrics.
|
LineMetrics | getLineMetrics(String text, int begin, int limit, Graphics g)
Returns a {@link LineMetrics} object constructed with the
specified text and the {@link FontRenderContext} of the Graphics
object when it is an instance of Graphics2D or a generic
FontRenderContext with a null transform, not anti-aliased and not
using fractional metrics.
|
LineMetrics | getLineMetrics(char[] chars, int begin, int limit, Graphics g)
Returns a {@link LineMetrics} object constructed with the
specified text and the {@link FontRenderContext} of the Graphics
object when it is an instance of Graphics2D or a generic
FontRenderContext with a null transform, not anti-aliased and not
using fractional metrics.
|
LineMetrics | getLineMetrics(CharacterIterator ci, int begin, int limit, Graphics g)
Returns a {@link LineMetrics} object constructed with the
specified text and the {@link FontRenderContext} of the Graphics
object when it is an instance of Graphics2D or a generic
FontRenderContext with a null transform, not anti-aliased and not
using fractional metrics.
|
int | getMaxAdvance()
Returns the width of the widest character in the font.
|
int | getMaxAscent()
Returns the maximum ascent value. |
Rectangle2D | getMaxCharBounds(Graphics context)
Returns the bounds of the largest character in a Graphics context. |
int | getMaxDecent()
Returns the maximum descent value. |
int | getMaxDescent()
Returns the maximum descent value. |
Rectangle2D | getStringBounds(String str, Graphics context) |
Rectangle2D | getStringBounds(String str, int beginIndex, int limit, Graphics context) |
Rectangle2D | getStringBounds(char[] chars, int beginIndex, int limit, Graphics context) |
Rectangle2D | getStringBounds(CharacterIterator ci, int beginIndex, int limit, Graphics context) |
int[] | getWidths()
Returns the widths of the first 256 characters in the font.
|
boolean | hasUniformLineMetrics()
Returns if the font has uniform line metrics. |
int | stringWidth(String str)
Returns the total width of the specified string
|
String | toString()
Returns a string representation of this object.
|
FontMetrics
for the
specified font.
Parameters: font The font to return metric information for.
Parameters: buf The byte array containing the data. offset The offset into the array to start calculating from. len The total number of bytes to process.
Returns: The width of the requested characters.
Parameters: buf The character array containing the data. offset The offset into the array to start calculating from. len The total number of bytes to process.
Returns: The width of the requested characters.
Parameters: ch The character to return the width of.
Returns: The width of the specified character.
Parameters: ch The character to return the width of.
Returns: The width of the specified character.
Returns: The font ascent.
Returns: The font descent.
Returns: The font for this object.
Returns: The height of the font.
Returns: The font leading.
Parameters: text The string to calculate metrics from. g The Graphics object that will be used.
Returns: A new {@link LineMetrics} object.
Parameters: text The string to calculate metrics from. begin Index of first character in text
to measure. limit Index of last character in text
to measure. g The Graphics object that will be used.
Returns: A new {@link LineMetrics} object.
Throws: IndexOutOfBoundsException if the range [begin, limit] is
invalid in text
.
Parameters: chars The string to calculate metrics from. begin Index of first character in text
to measure. limit Index of last character in text
to measure. g The Graphics object that will be used.
Returns: A new {@link LineMetrics} object.
Throws: IndexOutOfBoundsException if the range [begin, limit] is
invalid in text
.
Parameters: ci An iterator over the string to calculate metrics from. begin Index of first character in text
to measure. limit Index of last character in text
to measure. g The Graphics object that will be used.
Returns: A new {@link LineMetrics} object.
Throws: IndexOutOfBoundsException if the range [begin, limit] is
invalid in text
.
Returns: The width of the widest character in the font.
Returns: The maximum ascent for this font.
Parameters: context the Graphics context object.
Returns: a Rectangle2D
representing the bounds
Deprecated: This method is deprecated in favor of
getMaxDescent()
.
Returns: The maximum descent for this font.
Returns: The maximum descent for this font.
Returns: The widths of the first 256 characters in the font.
See Also: hasUniformLineMetrics
Parameters: str The string to return the width of.
Returns: The width of the string.
Returns: A string representation of this object.