Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.font.GlyphMetrics

java.lang.Object
    |
    +----java.awt.font.GlyphMetrics

public final class GlyphMetrics
extends Object
GlyphMetrics represents infomation for a single glyph. GlyphMetrics instances are produced by Font and are applicable to a specific glyph in a particular Font.

Glyphs are either STANDARD, LIGATURE, COMBINING, COMPONENT, or FILLER. They also may be marked as being either WHITESPACE or HANGING_PUNCTUATION. STANDARD glyphs are commonly used to represent single characters. LIGATURE glyphs are always the first glyph in a sequence of glyphs that combine to represent a set of "combining characters," such as the 'fi' ligature found in some fonts. A LIGATURE glyph in a GlyphSet is always followed by one or more FILLER glyphs. The number of LIGATURE and FILLER glyphs is always the same as the number of characters represented by the ligature. COMPONENT glyphs in a GlyphSet do not correspond to a particular character in a text model. Instead, COMPONENT glyphs are added for typographical reasons (such as Arabic justification). COMBINING glyphs embellish STANDARD or LIGATURE glyphs, such as accent marks. Carets do not appear before COMBINING glyphs.

Other metrics available through GlyphMetrics are the advance, bounds, and left and right side bearings. The advance of a glyph is the distance from the glyph's origin to the origin of the next glyph. Note that, in a glyphset, the distance from a glyph to its following glyph may not be the glyph's advance. The bounds is the smallest rectangle which completely contains the visible portion of the glyph. The bounds rectangle is relative to the glyph's origin. The left-side bearing is the distance from the glyph origin to the left of its bounds rectangle. If the left-side bearing is negative, part of the glyph is drawn to the left of its origin. The right-side bearing is the distance from the right side of the bounds rectangle to the next glyph origin (the origin plus the advance). If negative, part of the glyph is drawn to the right of the next glyph's origin.

Although instances of GlyphMetrics may be directly constructed, they are almost always obtained from a Font. Once constructed, GlyphMetrics are immutable.

Example:

Querying a Font for glyph information

 Font font = ...;
 int glyphCode = ...;
 GlyphMetrics metrics = font.getGlyphMetrics(glyphCode);
 int isStandard = metrics.isStandard();
 float glyphAdvance = metrics.getAdvance();
 

See Also:
Font, GlyphSet

Field Summary
static byte  COMBINING
This code indicates a glyph that represents a combining character, such as an umlaut.
static byte  COMPONENT
This code indicates a glyph with no corresponding character in the backing store.
static byte  FILLER
This code indicates a glyph used as a filler for a ligature.
static byte  HANGING_PUNCTUATION
This value is added to the base code to indicate hanging punctuation.
static byte  LIGATURE
This code indicates a glyph that represents multiple characters as a ligature, for example 'fi' or 'ffi'.
static byte  STANDARD
This code indicates a glyph that represents a single standard character.
static byte  WHITESPACE
This value is added to the base code to indicate whitespace.
 

Constructor Summary
 GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType)
Construct a GlyphMetrics.
 

Method Summary
float  getAdvance()
Return the advance width (height) of the glyph.
Rectangle2D  getBounds2D()
Return the black box bounds of the glyph.
float  getLSB()
Return the left (top) side bearing of the glyph.
float  getRSB()
Return the right (bottom) side bearing of the glyph.
byte  getType()
Return the raw glyph type code.
boolean  isCombining()
Return true if this is a combining glyph.
boolean  isComponent()
Return true if this is a component glyph.
boolean  isFiller()
Return true if this is a component glyph.
boolean  isHangingPunctuation()
Return true if this is a hanging punctuation glyph.
boolean  isLigature()
Return true if this is a ligature glyph.
boolean  isStandard()
Return true if this is a standard glyph.
boolean  isWhitespace()
Return true if this is a whitespace glyph.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STANDARD

public static final byte STANDARD
This code indicates a glyph that represents a single standard character.

LIGATURE

public static final byte LIGATURE
This code indicates a glyph that represents multiple characters as a ligature, for example 'fi' or 'ffi'. It is followed by filler glyphs for the remaining characters. Filler and combining glyphs can be intermixed to control positioning of accent marks on the logically preceeding ligature.

COMBINING

public static final byte COMBINING
This code indicates a glyph that represents a combining character, such as an umlaut. There is no caret position between this glyph and the preceeding glyph.

COMPONENT

public static final byte COMPONENT
This code indicates a glyph with no corresponding character in the backing store. The glyph is associated with the character represented by the logicaly preceeding non-component glyph. This is used for kashida justification or other visual modifications to existing glyphs. There is no caret position between this glyph and the preceeding glyph.

FILLER

public static final byte FILLER
This code indicates a glyph used as a filler for a ligature. It has a width that is used to control caret positions within the ligature when carets are allowed in ligatures. It replaces the succeeding logical characters that were used to create the ligature.

HANGING_PUNCTUATION

public static final byte HANGING_PUNCTUATION
This value is added to the base code to indicate hanging punctuation. This information is used in justification.

WHITESPACE

public static final byte WHITESPACE
This value is added to the base code to indicate whitespace. This information is used in justification.
Constructor Detail

GlyphMetrics

public GlyphMetrics(float advance,
                    Rectangle2D bounds,
                    byte glyphType)
Construct a GlyphMetrics.
Parameters:
advance - the advance width (height) of the glyph
bounds - the black box bounds of the glyph.
glyphType - the type of the glyph
Method Detail

getAdvance

public float getAdvance()
Return the advance width (height) of the glyph.

getBounds2D

public Rectangle2D getBounds2D()
Return the black box bounds of the glyph. The returned bounds must not be modified by the caller.

getLSB

public float getLSB()
Return the left (top) side bearing of the glyph. This is the distance from 0, 0 to the left (top) of the glyph bounds. If the bounds of the glyph is to the left of (above) the origin, the LSB is negative.

getRSB

public float getRSB()
Return the right (bottom) side bearing of the glyph. This is the distance from the right (bottom) of the glyph bounds to the advance. If the bounds of the glyph is to the right of (below) the advance, the RSB is negative.

getType

public byte getType()
Return the raw glyph type code.

isStandard

public boolean isStandard()
Return true if this is a standard glyph.

isLigature

public boolean isLigature()
Return true if this is a ligature glyph.

isCombining

public boolean isCombining()
Return true if this is a combining glyph.

isComponent

public boolean isComponent()
Return true if this is a component glyph.

isFiller

public boolean isFiller()
Return true if this is a component glyph.

isWhitespace

public boolean isWhitespace()
Return true if this is a whitespace glyph.

isHangingPunctuation

public boolean isHangingPunctuation()
Return true if this is a hanging punctuation glyph.

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.