The FontMetrics class provides the means to calculate actual width and height of text if drawn on the screen.
public abstract class java.awt.FontMetrics extends java.lang.Object implements java.io.Serializable { // Variables protected Font font; // Constructors protected FontMetrics (Font font); // Instance Methods public int bytesWidth (byte data[], int offset, int length); public int charsWidth (char data[], int offset, int length); public int charWidth (char character); public int charWidth (int character); public int getAscent(); public int getDescent(); public Font getFont(); public int getHeight(); public int getLeading(); public int getMaxAdvance(); public int getMaxAscent(); public int getMaxDecent(); public int getMaxDescent(); public int[] getWidths(); public int stringWidth (String string); public String toString(); }
The Font object whose metrics are represented by this object.
The Font object whose metrics you want.
Constructs a platform specific FontMetrics object for the given font.
Array of characters to lookup.
Initial character position.
Number of characters to lookup.
Advance width of characters in the array, starting with offset and ending with offset+length, in pixels.
If offset or length is invalid.
Array of characters to lookup.
Initial character position.
Number of characters to lookup.
Advance width of characters in the array, starting with offset and ending with offset+length-1, in pixels.
If offset or length is invalid.
character to lookup
Advanced pixel width of character.
int value of character to lookup
Advanced pixel width of character.
Amount of space above the baseline required for the tallest character in the font.
Amount of space below the baseline required for the lowest descender (e.g., the tail on "p") in the font.
The Font whose metrics are represented by this object.
The sum of getDescent(), getAscent(), and getLeading(); recommended total space between baselines.
Retrieves recommended amount of space between lines of text.
Retrieves advance pixel width of widest character in the font.
Retrieves maximum amount of space above the baseline required for the tallest character within the font's FontMetrics. May differ from getAscent() for characters with diacritical marks.
Retrieves the maximum amount of space below the baseline required for the deepest character for the font.
A misspelling of getMaxDescent().
Retrieves the maximum amount of space below the baseline required for the deepest character for the font.
255 element array of character widths.
Retrieves an integer array of the advance widths of the first 255 characters in the FontMetrics' font.
Character string to lookup.
Advance pixel width of string.
A string representation of the FontMetrics object.
Object.toString()
Font, Object, String
This HTML Help has been published using the chm2web software. |