FileDocCategorySizeDatePackage
GlyphMetrics.javaAPI DocAndroid 1.5 API7303Wed May 06 22:41:54 BST 2009java.awt.font

GlyphMetrics

public final class GlyphMetrics extends Object
The GlyphMetrics class provides information about the size and shape of a single glyph. Each glyph has information to specify whether its baseline is horizontal or vertical as well as information on how it interacts with other characters in a text, given as one of the following types: STANDARD, LIGATURE, COMBINING, or COMPONENT.
since
Android 1.0

Fields Summary
private float
advanceX
The advance x.
private float
advanceY
The advance y.
private boolean
horizontal
The horizontal.
private byte
glyphType
The glyph type.
private Rectangle2D$Float
bounds
The bounds.
public static final byte
STANDARD
The Constant STANDARD indicates a glyph that represents a single character.
public static final byte
LIGATURE
The Constant LIGATURE indicates a glyph that represents multiple characters as a ligature.
public static final byte
COMBINING
The Constant COMBINING indicates a glyph which has no caret position between glyphs (for example umlaut).
public static final byte
COMPONENT
The Constant COMPONENT indicates a glyph with no corresponding character in the backing store.
public static final byte
WHITESPACE
The Constant WHITESPACE indicates a glyph without visual representation.
Constructors Summary
public GlyphMetrics(boolean horizontal, float advanceX, float advanceY, Rectangle2D bounds, byte glyphType)
Instantiates a new GlyphMetrics object with the specified parameters.

param
horizontal specifies if metrics are for a horizontal baseline (true value), or a vertical baseline (false value).
param
advanceX the X component of the glyph's advance.
param
advanceY the Y component of the glyph's advance.
param
bounds the glyph's bounds.
param
glyphType the glyph's type.


                                                                                                                                   
            
              
        this.horizontal = horizontal;
        this.advanceX = advanceX;
        this.advanceY = advanceY;

        this.bounds = new Rectangle2D.Float();
        this.bounds.setRect(bounds);

        this.glyphType = glyphType;
    
public GlyphMetrics(float advanceX, Rectangle2D bounds, byte glyphType)
Instantiates a new horizontal GlyphMetrics with the specified parameters.

param
advanceX the X component of the glyph's advance.
param
bounds the glyph's bounds.
param
glyphType the glyph's type.

        this.advanceX = advanceX;
        this.advanceY = 0;

        this.horizontal = true;

        this.bounds = new Rectangle2D.Float();
        this.bounds.setRect(bounds);

        this.glyphType = glyphType;
    
Methods Summary
public floatgetAdvance()
Gets the glyph's advance along the baseline.

return
the glyph's advance.

        if (this.horizontal) {
            return this.advanceX;
        }
        return this.advanceY;
    
public floatgetAdvanceX()
Gets the X component of the glyph's advance.

return
the X component of the glyph's advance.

        return this.advanceX;
    
public floatgetAdvanceY()
Gets the Y component of the glyph's advance.

return
the Y component of the glyph's advance.

        return this.advanceY;
    
public java.awt.geom.Rectangle2DgetBounds2D()
Gets the glyph's bounds.

return
glyph's bounds.

        return (Rectangle2D.Float)this.bounds.clone();
    
public floatgetLSB()
Gets the distance from 0, 0 to the left (for horizontal) or top (for vertical) of the glyph bounds.

return
the distance from 0, 0 to the left (for horizontal) or top (for vertical) of the glyph bounds.

        if (this.horizontal) {
            return this.bounds.x;
        }
        return this.bounds.y;
    
public floatgetRSB()
Gets the distance from the right (for horizontal) or bottom (for vertical) of the glyph bounds to the advance.

return
the distance from the right (for horizontal) or bottom (for vertical) of the glyph bounds to the advance.

        if (this.horizontal) {
            return this.advanceX - this.bounds.x - (float)this.bounds.getWidth();
        }
        return this.advanceY - this.bounds.y - (float)this.bounds.getHeight();
    
public intgetType()
Gets the glyph's type.

return
the glyph's type.

        return this.glyphType;
    
public booleanisCombining()
Checks if this glyph is combining or not.

return
true, if this glyph is combining, false otherwise.

        return ((this.glyphType & 3) == COMBINING);
    
public booleanisComponent()
Checks if this glyph is component or not.

return
true, if this glyph is component, false otherwise.

        return ((this.glyphType & 3) == COMPONENT);
    
public booleanisLigature()
Checks if this glyph is ligature or not.

return
true, if this glyph is ligature, false otherwise.

        return ((this.glyphType & 3) == LIGATURE);
    
public booleanisStandard()
Checks if this glyph is standard or not.

return
true, if this glyph is standard, false otherwise.

        return ((this.glyphType & 3) == STANDARD);
    
public booleanisWhitespace()
Checks if this glyph is whitespace or not.

return
true, if this glyph is whitespace, false otherwise.

        return ((this.glyphType & 4) == WHITESPACE);