The GlyphMetrics class represents infomation for a
single glyph. A glyph is the visual representation of one or more
characters. Many different glyphs can be used to represent a single
character or combination of characters. GlyphMetrics
instances are produced by Font and are applicable
to a specific glyph in a particular Font.
Glyphs are either STANDARD, LIGATURE, COMBINING, or COMPONENT.
STANDARD glyphs are commonly used to represent single characters.
LIGATURE glyphs are used to represent sequences of characters.
COMPONENT glyphs in a GlyphVector 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 GlyphVector,
the distance from a glyph to its following glyph might not be the
glyph's advance.
The bounds is the smallest rectangle that 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 can be directly
constructed, they are almost always obtained from a
GlyphVector. Once constructed, GlyphMetrics
objects are immutable.
Example:
Querying a Font for glyph information
Font font = ...;
int glyphIndex = ...;
GlyphMetrics metrics = GlyphVector.getGlyphMetrics(glyphIndex);
int isStandard = metrics.isStandard();
float glyphAdvance = metrics.getAdvance();
Indicates a glyph that represents a single standard
character.
LIGATURE
public static final byte LIGATURE
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
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
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.
WHITESPACE
public static final byte WHITESPACE
Indicates a glyph with no visual representation. It can
be added to the other code values to indicate an invisible glyph.
Constructor Detail
GlyphMetrics
public GlyphMetrics(float advance,
Rectangle2D bounds,
byte glyphType)
Constructs a GlyphMetrics object.
Parameters:
advance - the advance width or height 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.
Returns:
the left side bearing of the glyph.
getRSB
public float getRSB()
Returns 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.
Returns:
the right side bearing of the glyph.
getType
public int getType()
Returns the raw glyph type code.
Returns:
the raw glyph type code.
isStandard
public boolean isStandard()
Returns true if this is a standard glyph.
Returns:
true if this is a standard glyph;
false otherwise.
isLigature
public boolean isLigature()
Returns true if this is a ligature glyph.
Returns:
true if this is a ligature glyph;
false otherwise.
isCombining
public boolean isCombining()
Returns true if this is a combining glyph.
Returns:
true if this is a combining glyph;
false otherwise.
isComponent
public boolean isComponent()
Returns true if this is a component glyph.
Returns:
true if this is a component glyph;
false otherwise.
isWhitespace
public boolean isWhitespace()
Returns true if this is a whitespace glyph.
Returns:
true if this is a whitespace glyph;
false otherwise.
Submit a bug or feature For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road Palo Alto, California, 94303, U.S.A. All Rights Reserved.