< prev index next >
src/java.desktop/share/classes/java/awt/font/GlyphMetrics.java
Print this page
*** 41,56 ****
package java.awt.font;
import java.awt.geom.Rectangle2D;
/**
! * The <code>GlyphMetrics</code> class represents information 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. <code>GlyphMetrics</code>
* instances are produced by {@link java.awt.Font Font} and are applicable
! * to a specific glyph in a particular <code>Font</code>.
* <p>
* Glyphs are either STANDARD, LIGATURE, COMBINING, or COMPONENT.
* <ul>
* <li>STANDARD glyphs are commonly used to represent single characters.
* <li>LIGATURE glyphs are used to represent sequences of characters.
--- 41,56 ----
package java.awt.font;
import java.awt.geom.Rectangle2D;
/**
! * The {@code GlyphMetrics} class represents information 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. {@code GlyphMetrics}
* instances are produced by {@link java.awt.Font Font} and are applicable
! * to a specific glyph in a particular {@code Font}.
* <p>
* Glyphs are either STANDARD, LIGATURE, COMBINING, or COMPONENT.
* <ul>
* <li>STANDARD glyphs are commonly used to represent single characters.
* <li>LIGATURE glyphs are used to represent sequences of characters.
*** 59,80 ****
* added for typographical reasons, such as Arabic justification.
* <li>COMBINING glyphs embellish STANDARD or LIGATURE glyphs, such
* as accent marks. Carets do not appear before COMBINING glyphs.
* </ul>
* <p>
! * Other metrics available through <code>GlyphMetrics</code> are the
* components of the advance, the visual bounds, and the left and right
* side bearings.
* <p>
! * Glyphs for a rotated font, or obtained from a <code>GlyphVector</code>
* which has applied a rotation to the glyph, can have advances that
* contain both X and Y components. Usually the advance only has one
* component.
* <p>
* The advance of a glyph is the distance from the glyph's origin to the
* origin of the next glyph along the baseline, which is either vertical
! * or horizontal. Note that, in a <code>GlyphVector</code>,
* the distance from a glyph to its following glyph might not be the
* glyph's advance, because of kerning or other positioning adjustments.
* <p>
* The bounds is the smallest rectangle that completely contains the
* outline of the glyph. The bounds rectangle is relative to the
--- 59,80 ----
* added for typographical reasons, such as Arabic justification.
* <li>COMBINING glyphs embellish STANDARD or LIGATURE glyphs, such
* as accent marks. Carets do not appear before COMBINING glyphs.
* </ul>
* <p>
! * Other metrics available through {@code GlyphMetrics} are the
* components of the advance, the visual bounds, and the left and right
* side bearings.
* <p>
! * Glyphs for a rotated font, or obtained from a {@code GlyphVector}
* which has applied a rotation to the glyph, can have advances that
* contain both X and Y components. Usually the advance only has one
* component.
* <p>
* The advance of a glyph is the distance from the glyph's origin to the
* origin of the next glyph along the baseline, which is either vertical
! * or horizontal. Note that, in a {@code GlyphVector},
* the distance from a glyph to its following glyph might not be the
* glyph's advance, because of kerning or other positioning adjustments.
* <p>
* The bounds is the smallest rectangle that completely contains the
* outline of the glyph. The bounds rectangle is relative to the
*** 86,102 ****
* negative, part of the glyph is drawn to the right of the next glyph's
* origin. Note that the bounds does not necessarily enclose all the pixels
* affected when rendering the glyph, because of rasterization and pixel
* adjustment effects.
* <p>
! * Although instances of <code>GlyphMetrics</code> can be directly
* constructed, they are almost always obtained from a
! * <code>GlyphVector</code>. Once constructed, <code>GlyphMetrics</code>
* objects are immutable.
* <p>
* <strong>Example</strong>:<p>
! * Querying a <code>Font</code> for glyph information
* <blockquote><pre>
* Font font = ...;
* int glyphIndex = ...;
* GlyphMetrics metrics = GlyphVector.getGlyphMetrics(glyphIndex);
* int isStandard = metrics.isStandard();
--- 86,102 ----
* negative, part of the glyph is drawn to the right of the next glyph's
* origin. Note that the bounds does not necessarily enclose all the pixels
* affected when rendering the glyph, because of rasterization and pixel
* adjustment effects.
* <p>
! * Although instances of {@code GlyphMetrics} can be directly
* constructed, they are almost always obtained from a
! * {@code GlyphVector}. Once constructed, {@code GlyphMetrics}
* objects are immutable.
* <p>
* <strong>Example</strong>:<p>
! * Querying a {@code Font} for glyph information
* <blockquote><pre>
* Font font = ...;
* int glyphIndex = ...;
* GlyphMetrics metrics = GlyphVector.getGlyphMetrics(glyphIndex);
* int isStandard = metrics.isStandard();
*** 169,179 ****
* be added to the other code values to indicate an invisible glyph.
*/
public static final byte WHITESPACE = 4;
/**
! * Constructs a <code>GlyphMetrics</code> object.
* @param advance the advance width of the glyph
* @param bounds the black box bounds of the glyph
* @param glyphType the type of the glyph
*/
public GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType) {
--- 169,179 ----
* be added to the other code values to indicate an invisible glyph.
*/
public static final byte WHITESPACE = 4;
/**
! * Constructs a {@code GlyphMetrics} object.
* @param advance the advance width of the glyph
* @param bounds the black box bounds of the glyph
* @param glyphType the type of the glyph
*/
public GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType) {
*** 184,194 ****
this.bounds.setRect(bounds);
this.glyphType = glyphType;
}
/**
! * Constructs a <code>GlyphMetrics</code> object.
* @param horizontal if true, metrics are for a horizontal baseline,
* otherwise they are for a vertical baseline
* @param advanceX the X-component of the glyph's advance
* @param advanceY the Y-component of the glyph's advance
* @param bounds the visual bounds of the glyph
--- 184,194 ----
this.bounds.setRect(bounds);
this.glyphType = glyphType;
}
/**
! * Constructs a {@code GlyphMetrics} object.
* @param horizontal if true, metrics are for a horizontal baseline,
* otherwise they are for a vertical baseline
* @param advanceX the X-component of the glyph's advance
* @param advanceY the Y-component of the glyph's advance
* @param bounds the visual bounds of the glyph
*** 276,324 ****
public int getType() {
return glyphType;
}
/**
! * Returns <code>true</code> if this is a standard glyph.
! * @return <code>true</code> if this is a standard glyph;
! * <code>false</code> otherwise.
*/
public boolean isStandard() {
return (glyphType & 0x3) == STANDARD;
}
/**
! * Returns <code>true</code> if this is a ligature glyph.
! * @return <code>true</code> if this is a ligature glyph;
! * <code>false</code> otherwise.
*/
public boolean isLigature() {
return (glyphType & 0x3) == LIGATURE;
}
/**
! * Returns <code>true</code> if this is a combining glyph.
! * @return <code>true</code> if this is a combining glyph;
! * <code>false</code> otherwise.
*/
public boolean isCombining() {
return (glyphType & 0x3) == COMBINING;
}
/**
! * Returns <code>true</code> if this is a component glyph.
! * @return <code>true</code> if this is a component glyph;
! * <code>false</code> otherwise.
*/
public boolean isComponent() {
return (glyphType & 0x3) == COMPONENT;
}
/**
! * Returns <code>true</code> if this is a whitespace glyph.
! * @return <code>true</code> if this is a whitespace glyph;
! * <code>false</code> otherwise.
*/
public boolean isWhitespace() {
return (glyphType & 0x4) == WHITESPACE;
}
}
--- 276,324 ----
public int getType() {
return glyphType;
}
/**
! * Returns {@code true} if this is a standard glyph.
! * @return {@code true} if this is a standard glyph;
! * {@code false} otherwise.
*/
public boolean isStandard() {
return (glyphType & 0x3) == STANDARD;
}
/**
! * Returns {@code true} if this is a ligature glyph.
! * @return {@code true} if this is a ligature glyph;
! * {@code false} otherwise.
*/
public boolean isLigature() {
return (glyphType & 0x3) == LIGATURE;
}
/**
! * Returns {@code true} if this is a combining glyph.
! * @return {@code true} if this is a combining glyph;
! * {@code false} otherwise.
*/
public boolean isCombining() {
return (glyphType & 0x3) == COMBINING;
}
/**
! * Returns {@code true} if this is a component glyph.
! * @return {@code true} if this is a component glyph;
! * {@code false} otherwise.
*/
public boolean isComponent() {
return (glyphType & 0x3) == COMPONENT;
}
/**
! * Returns {@code true} if this is a whitespace glyph.
! * @return {@code true} if this is a whitespace glyph;
! * {@code false} otherwise.
*/
public boolean isWhitespace() {
return (glyphType & 0x4) == WHITESPACE;
}
}
< prev index next >