Save This Page
Home » openjdk-7 » sun » font » [javadoc | source]
sun.font
public class: StandardGlyphVector [javadoc | source]
java.lang.Object
   java.awt.font.GlyphVector
      sun.font.StandardGlyphVector

All Implemented Interfaces:
    Cloneable

Standard implementation of GlyphVector used by Font, GlyphList, and SunGraphics2D. The main issues involve the semantics of the various transforms (font, glyph, device) and their effect on rendering and metrics. Very, very unfortunately, the translation component of the font transform affects where the text gets rendered. It offsets the rendering origin. None of the other metrics of the glyphvector are affected, making them inconsistent with the rendering behavior. I think the translation component of the font would be better interpreted as the translation component of a per-glyph transform, but I don't know if this is possible to change. After the font transform is applied, the glyph transform is applied. This makes glyph transforms relative to font transforms, if the font transform changes, the glyph transform will have the same (relative) effect on the outline of the glyph. The outline and logical bounds are passed through the glyph transform before being returned. The glyph metrics ignore the glyph transform, but provide the outline bounds and the advance vector of the glyph (the latter will be rotated if the font is rotated). The default layout places each glyph at the end of the advance vector of the previous glyph, and since the glyph transform translates the advance vector, this means a glyph transform affects the positions of all subsequent glyphs if defaultLayout is called after setting a glyph transform. In the glyph info array, the bounds are the outline bounds including the glyph transform, and the positions are as computed, and the advances are the deltas between the positions. (There's a bug in the logical bounds of a rotated glyph for composite fonts, it's not to spec (in 1.4.0, 1.4.1, 1.4.2). The problem is that the rotated composite doesn't handle the multiple ascents and descents properly in both x and y. You end up with a rotated advance vector but an unrotated ascent and descent.) Finally, the whole thing is transformed by the device transform to position it on the page. Another bug: The glyph outline seems to ignore fractional point size information, but the images (and advances) don't ignore it. Small fonts drawn at large magnification have odd advances when fractional metrics is off-- that's because the advances depend on the frc. When the frc is scaled appropriately, the advances are fine. FM or a large frc (high numbers) make the advances right. The buffer aa flag doesn't affect rendering, the glyph vector renders as AA if aa is set in its frc, and as non-aa if aa is not set in its frc. font rotation, baseline, vertical etc. Font rotation and baseline Line metrics should be measured along a unit vector pi/4 cc from the baseline vector. For 'horizontal' fonts the baseline vector is the x vector passed through the font transform (ignoring translation), for 'vertical' it is the y vector. This definition makes ascent, descent, etc independent of shear, so shearing can be used to simulate italic. This means no fonts have 'negative ascents' or 'zero ascents' etc. Having a coordinate system with orthogonal axes where one is parallel to the baseline means we could use rectangles and interpret them in terms of this coordinate system. Unfortunately there is support for rotated fonts in the jdk already so maintaining the semantics of existing code (getlogical bounds, etc) might be difficult. A font transform transforms both the baseline and all the glyphs in the font, so it does not rotate the glyph w.r.t the baseline. If you do want to rotate individual glyphs, you need to apply a glyph transform. If performDefaultLayout is called after this, the transformed glyph advances will affect the glyph positions. useful additions - select vertical metrics - glyphs are rotated pi/4 cc and vertical metrics are used to align them to the baseline. - define baseline for font (glyph rotation not linked to baseline) - define extra space (delta between each glyph along baseline) - define offset (delta from 'true' baseline, impacts ascent and descent as these are still computed from true basline and pinned to zero, used in superscript).
Nested Class Summary:
static final class  StandardGlyphVector.GlyphTransformInfo   
public static final class  StandardGlyphVector.GlyphStrike   
static class  StandardGlyphVector.ADL   
Field Summary
public static final  int FLAG_USES_VERTICAL_BASELINE    A flag used with getLayoutFlags that indicates whether this GlyphVector uses a vertical baseline. 
public static final  int FLAG_USES_VERTICAL_METRICS    A flag used with getLayoutFlags that indicates whether this GlyphVector uses vertical glyph metrics. A GlyphVector can use vertical metrics on a horizontal line, or vice versa. 
public static final  int FLAG_USES_ALTERNATE_ORIENTATION    A flag used with getLayoutFlags that indicates whether this GlyphVector uses the 'alternate orientation.' Glyphs have a default orientation given a particular baseline and metrics orientation, this is the orientation appropriate for left-to-right text. For example, the letter 'A' can have four orientations, with the point at 12, 3, 6, or 9 'o clock. The following table shows where the point displays for different values of vertical baseline (vb), vertical metrics (vm) and alternate orientation (fo):
vb vm ao -- -- -- -- f f f 12 ^ horizontal metrics on horizontal lines f f t 6 v f t f 9 < vertical metrics on horizontal lines f t t 3 > t f f 3 > horizontal metrics on vertical lines t f t 9 < t t f 12 ^ vertical metrics on vertical lines t t t 6 v
 
Fields inherited from java.awt.font.GlyphVector:
FLAG_HAS_TRANSFORMS,  FLAG_HAS_POSITION_ADJUSTMENTS,  FLAG_RUN_RTL,  FLAG_COMPLEX_GLYPHS,  FLAG_MASK
Constructor:
 public StandardGlyphVector(Font font,
    String str,
    FontRenderContext frc) 
 public StandardGlyphVector(Font font,
    char[] text,
    FontRenderContext frc) 
 public StandardGlyphVector(Font font,
    CharacterIterator iter,
    FontRenderContext frc) 
 public StandardGlyphVector(Font font,
    int[] glyphs,
    FontRenderContext frc) 
 public StandardGlyphVector(Font font,
    char[] text,
    int start,
    int count,
    FontRenderContext frc) 
 public StandardGlyphVector(Font font,
    FontRenderContext frc,
    int[] glyphs,
    float[] positions,
    int[] indices,
    int flags) 
Method from sun.font.StandardGlyphVector Summary:
appendString,   clone,   copy,   equals,   equals,   getFont,   getFontRenderContext,   getGlyphCharIndex,   getGlyphCharIndices,   getGlyphCode,   getGlyphCodes,   getGlyphInfo,   getGlyphJustificationInfo,   getGlyphLogicalBounds,   getGlyphMetrics,   getGlyphOutline,   getGlyphOutline,   getGlyphPixelBounds,   getGlyphPosition,   getGlyphPositions,   getGlyphPositions,   getGlyphTransform,   getGlyphTransforms,   getGlyphTransforms,   getGlyphVisualBounds,   getLayoutFlags,   getLogicalBounds,   getNumGlyphs,   getOutline,   getOutline,   getPixelBounds,   getStandardGV,   getValidatedGlyphs,   getVisualBounds,   hashCode,   initGlyphVector,   needsPositions,   performDefaultLayout,   pixellate,   setGlyphPosition,   setGlyphPositions,   setGlyphPositions,   setGlyphTransform,   setGlyphTransforms,   setGlyphTransforms,   setupGlyphImages,   toString
Methods from java.awt.font.GlyphVector:
equals,   getFont,   getFontRenderContext,   getGlyphCharIndex,   getGlyphCharIndices,   getGlyphCode,   getGlyphCodes,   getGlyphJustificationInfo,   getGlyphLogicalBounds,   getGlyphMetrics,   getGlyphOutline,   getGlyphOutline,   getGlyphPixelBounds,   getGlyphPosition,   getGlyphPositions,   getGlyphTransform,   getGlyphVisualBounds,   getLayoutFlags,   getLogicalBounds,   getNumGlyphs,   getOutline,   getOutline,   getPixelBounds,   getVisualBounds,   performDefaultLayout,   setGlyphPosition,   setGlyphTransform
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.font.StandardGlyphVector Detail:
 StringBuffer appendString(StringBuffer buf) 
 public Object clone() 
    As a concrete subclass of GlyphVector, this must implement clone.
 public StandardGlyphVector copy() 
    Sometimes I wish java had covariant return types...
 public boolean equals(GlyphVector rhs) 
 public boolean equals(Object rhs) 
    Since we implement equality comparisons for GlyphVector, we implement the inherited Object.equals(Object) as well. GlyphVector should do this, and define two glyphvectors as not equal if the classes differ.
 public Font getFont() 
 public FontRenderContext getFontRenderContext() 
 public int getGlyphCharIndex(int ix) 
 public int[] getGlyphCharIndices(int start,
    int count,
    int[] result) 
 public int getGlyphCode(int glyphIndex) 
 public int[] getGlyphCodes(int start,
    int count,
    int[] result) 
 public float[] getGlyphInfo() 
    For each glyph return posx, posy, advx, advy, visx, visy, visw, vish.
 public GlyphJustificationInfo getGlyphJustificationInfo(int ix) 
 public Shape getGlyphLogicalBounds(int ix) 
 public GlyphMetrics getGlyphMetrics(int ix) 
 public Shape getGlyphOutline(int ix) 
 public Shape getGlyphOutline(int ix,
    float x,
    float y) 
 public Rectangle getGlyphPixelBounds(int index,
    FontRenderContext renderFRC,
    float x,
    float y) 
 public Point2D getGlyphPosition(int ix) 
 public float[] getGlyphPositions(float[] result) 
    This is a convenience overload that gets all the glyph positions, which is what you usually want to do if you're getting more than one. !!! should I bother taking result parameter?
 public float[] getGlyphPositions(int start,
    int count,
    float[] result) 
 public AffineTransform getGlyphTransform(int ix) 
 public AffineTransform[] getGlyphTransforms() 
    Convenience overload for getGlyphTransforms(int, int, AffineTransform[], int);
 public AffineTransform[] getGlyphTransforms(int start,
    int count,
    AffineTransform[] result) 
    Get transform information for the requested range of glyphs. If no glyphs have a transform, return null. If a glyph has no transform (or is the identity transform) its entry in the result array will be null. If the passed-in result is null an array will be allocated for the caller. Each transform instance in the result array will unique, and independent of the GlyphVector's transform.
 public Shape getGlyphVisualBounds(int ix) 
 public int getLayoutFlags() 
 public Rectangle2D getLogicalBounds() 
 public int getNumGlyphs() 
 public Shape getOutline() 
 public Shape getOutline(float x,
    float y) 
 public Rectangle getPixelBounds(FontRenderContext renderFRC,
    float x,
    float y) 
 public static StandardGlyphVector getStandardGV(GlyphVector gv,
    FontInfo info) 
 int[] getValidatedGlyphs(int[] oglyphs) 
 public Rectangle2D getVisualBounds() 
 public int hashCode() 
    As a concrete subclass of Object that implements equality, this must implement hashCode.
 public  void initGlyphVector(Font font,
    FontRenderContext frc,
    int[] glyphs,
    float[] positions,
    int[] indices,
    int flags) 
 boolean needsPositions(double[] devTX) 
 public  void performDefaultLayout() 
 public  void pixellate(FontRenderContext renderFRC,
    Point2D loc,
    Point pxResult) 
    !!! not used currently, but might be by getPixelbounds?
 public  void setGlyphPosition(int ix,
    Point2D pos) 
 public  void setGlyphPositions(float[] srcPositions) 
    Set all the glyph positions, including the 'after last glyph' position. The srcPositions array must be of length (numGlyphs + 1) * 2.
 public  void setGlyphPositions(float[] srcPositions,
    int srcStart,
    int start,
    int count) 
 public  void setGlyphTransform(int ix,
    AffineTransform newTX) 
 public  void setGlyphTransforms(AffineTransform[] srcTransforms) 
    Convenience overload of setGlyphTransforms(AffineTransform[], int, int, int).
 public  void setGlyphTransforms(AffineTransform[] srcTransforms,
    int srcStart,
    int start,
    int count) 
    Set a number of glyph transforms. Original transforms are unchanged. The array may contain nulls, and also may contain multiple references to the same transform instance.
 Object setupGlyphImages(long[] images,
    float[] positions,
    double[] devTX) 
 public String toString()