FontMetrics

Name

FontMetrics

[Graphic: Figure from the text]

Description

The FontMetrics class provides the means to calculate actual width and height of text if drawn on the screen.

Class Definition

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();
}

Variables

font

protected Font font

The Font object whose metrics are represented by this object.

Constructors

FontMetrics

protected FontMetrics (Font font)

Instance Methods

bytesWidth

public int bytesWidth (byte data[], int offset, int length)

charsWidth

public int charsWidth (char data[], int offset, int length)

charWidth

public int charWidth (char character)

public int charWidth (int character)

getAscent

public int getAscent()

getDescent

public int getDescent()

getFont

public Font getFont()

getHeight

public int getHeight()

getLeading

public int getLeading()

getMaxAdvance

public int getMaxAdvance()

getMaxAscent

public int getMaxAscent()

getMaxDecent

public int getMaxDecent()

getMaxDescent

public int getMaxDescent()

getWidths

public int[] getWidths()

stringWidth

public int stringWidth (String string)

toString

public String toString()

See Also

Font, Object, String