Class FontMetrics
All Packages Class Hierarchy This Package Previous Next Index
Class FontMetrics
public class netscape.application.FontMetrics
extends java.lang.Object
{
/* Constructors
*/
public FontMetrics();
public FontMetrics(Font);
/* Methods
*/
public int ascent();
public int bytesWidth(byte[], int, int);
public int charHeight();
public int charWidth(int);
public int charWidth(char);
public int charsWidth(char[], int, int);
public int descent();
public Font font();
public int height();
public int leading();
public int maxAdvance();
public int maxAscent();
public int maxDescent();
public int stringHeight();
public Size stringSize(String);
public int stringWidth(String);
public String toString();
public int[] widthsArray();
public int widthsArrayBase();
}
Object subclass that manages a Font instance's metrics.
Note: FontMetrics are currently retrieve using the
default java.awt.Toolkit, so they contain screen metric information
only..
Constructors
.FontMetrics
public FontMetrics()
- Constructs a FontMetrics not associated with a Font. This method
is only useful when decoding.
.FontMetrics
public FontMetrics(Font aFont)
- Creates a FontMetrics associated with aFont.
Methods
public Font font()
- Returns the Font associated with this FontMetrics.
public int leading()
- Returns the standard leading (line spacing) for the Font, the logical
amount of space to be reserved between the descent of one line of
text and the ascent of the next line. The height metric is calculated
to include this extra space.
public int ascent()
- Returns the Font's ascent, the distance from the baseline to the
top of the characters.
public int descent()
- Returns the Font's descent, the distance from the baseline to the
bottom of the characters.
public int height()
- Returns the Font's total height, the distance between the baseline
of adjacent lines of text (leading + ascent + descent).
public int charHeight()
- Returns the Font's total character height, the distance from the
bottom of the descent to the top of the ascent.
public int maxAscent()
- Returns the maximum ascent of all characters in this Font. No
character extends further above the baseline than this metric.
public int maxDescent()
- Returns the maximum descent of all characters in this Font. No
character descends futher below the baseline than this metric.
public int maxAdvance()
- Returns the maximum advance width of any character in this Font,
or -1 if unknown.
public int charWidth(int aChar)
- Returns aChar's width in the FontMetric's Font.
public int charWidth(char aChar)
- Returns aChar's width in the FontMetric's Font.
public int stringWidth(String aString)
- Returns aString's width in the FontMetric's Font.
public int stringHeight()
- Returns the height of all strings in the FontMetric's Font.
Equivalent to the following code:
ascent() + descent();
public Size stringSize(String aString)
- Returns aString's size in the FontMetric's Font.
Equivalent to the following code:
new Size(stringWidth(aString), stringHeight());
public int charsWidth(char data[],
int offset,
int length)
- Returns the width of length characters of the array
data in the FontMetric's Font, starting at offset within
the array.
public int bytesWidth(byte data[],
int offset,
int length)
- Returns the width of length bytes of the array data
in the FontMetric's Font, starting at offset within the array.
public int[] widthsArray()
- Returns the widths of the first 256 characters in the FontMetric's
Font.
public int widthsArrayBase()
- Returns the index of the first glyph in a downloaded Font.
public String toString()
- Returns the FontMetric's string representation.
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index
Copyright © 1997 Netscape Communications Corporation. All rights reserved
Please send any comments or corrections to ifcfeedback@netscape.com
HTML generated on 21 Oct 1997