|
Java Platform 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.font.GlyphMetrics
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.
GlyphVector
do not correspond to a
particular character in a text model. Instead, COMPONENT glyphs are
added for typographical reasons, such as Arabic justification.
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();
Font
,
GlyphVector
Field Summary | |
static byte |
COMBINING
Indicates a glyph that represents a combining character, such as an umlaut. |
static byte |
COMPONENT
Indicates a glyph with no corresponding character in the backing store. |
static byte |
LIGATURE
Indicates a glyph that represents multiple characters as a ligature, for example 'fi' or 'ffi'. |
static byte |
STANDARD
Indicates a glyph that represents a single standard character. |
static byte |
WHITESPACE
Indicates a glyph with no visual representation. |
Constructor Summary | |
GlyphMetrics(float advance,
Rectangle2D bounds,
byte glyphType)
Constructs a GlyphMetrics object. |
Method Summary | |
float |
getAdvance()
Returns the advance width or height of the glyph. |
Rectangle2D |
getBounds2D()
Returns the black box bounds of the glyph. |
float |
getLSB()
Returns the left (top) side bearing of the glyph. |
float |
getRSB()
Returns the right (bottom) side bearing of the glyph. |
int |
getType()
Returns the raw glyph type code. |
boolean |
isCombining()
Returns true if this is a combining glyph. |
boolean |
isComponent()
Returns true if this is a component glyph. |
boolean |
isLigature()
Returns true if this is a ligature glyph. |
boolean |
isStandard()
Returns true if this is a standard glyph. |
boolean |
isWhitespace()
Returns 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 |
public static final byte STANDARD
public static final byte LIGATURE
public static final byte COMBINING
public static final byte COMPONENT
public static final byte WHITESPACE
Constructor Detail |
public GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType)
GlyphMetrics
object.advance
- the advance width or height of the glyphbounds
- the black box bounds of the glyphglyphType
- the type of the glyphMethod Detail |
public float getAdvance()
public Rectangle2D getBounds2D()
Rectangle2D
that is the bounds of the glyph.public float getLSB()
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.
public float getRSB()
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.
public int getType()
public boolean isStandard()
true
if this is a standard glyph.true
if this is a standard glyph;
false
otherwise.public boolean isLigature()
true
if this is a ligature glyph.true
if this is a ligature glyph;
false
otherwise.public boolean isCombining()
true
if this is a combining glyph.true
if this is a combining glyph;
false
otherwise.public boolean isComponent()
true
if this is a component glyph.true
if this is a component glyph;
false
otherwise.public boolean isWhitespace()
true
if this is a whitespace glyph.true
if this is a whitespace glyph;
false
otherwise.
|
Java Platform 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |