/** * Returns the metrics of the glyph at the specified index into this * GVTGlyphVector. */ public GVTGlyphMetrics getGlyphMetrics(int glyphIndex) { if (glyphMetrics[glyphIndex] != null) return glyphMetrics[glyphIndex]; // -- start glyph cache code -- Point2D glyphPos = defaultGlyphPositions[glyphIndex]; char c = ci.setIndex(ci.getBeginIndex()+glyphIndex); ci.setIndex(ci.getBeginIndex()); AWTGlyphGeometryCache.Value v = AWTGVTFont.getGlyphGeometry (gvtFont, c, awtGlyphVector, glyphIndex, glyphPos); Rectangle2D gmB = v.getBounds2D(); // -- end glyph cache code -- Rectangle2D bounds = new Rectangle2D.Double (gmB.getX() * scaleFactor, gmB.getY() * scaleFactor, gmB.getWidth() * scaleFactor, gmB.getHeight() * scaleFactor); // defaultGlyphPositions has one more entry than glyphs // the last entry stores the total advance for the // glyphVector. float adv = (float)(defaultGlyphPositions[glyphIndex+1].getX()- defaultGlyphPositions[glyphIndex] .getX()); glyphMetrics[glyphIndex] = new GVTGlyphMetrics ((float)(adv*scaleFactor), (ascent+descent), bounds, GlyphMetrics.STANDARD); return glyphMetrics[glyphIndex]; }
/** * Returns the metrics of the glyph at the specified index into this * GVTGlyphVector. */ public GVTGlyphMetrics getGlyphMetrics(int glyphIndex) { if (glyphMetrics[glyphIndex] != null) return glyphMetrics[glyphIndex]; // -- start glyph cache code -- Point2D glyphPos = defaultGlyphPositions[glyphIndex]; char c = ci.setIndex(ci.getBeginIndex()+glyphIndex); ci.setIndex(ci.getBeginIndex()); AWTGlyphGeometryCache.Value v = AWTGVTFont.getGlyphGeometry (gvtFont, c, awtGlyphVector, glyphIndex, glyphPos); Rectangle2D gmB = v.getBounds2D(); // -- end glyph cache code -- Rectangle2D bounds = new Rectangle2D.Double (gmB.getX() * scaleFactor, gmB.getY() * scaleFactor, gmB.getWidth() * scaleFactor, gmB.getHeight() * scaleFactor); // defaultGlyphPositions has one more entry than glyphs // the last entry stores the total advance for the // glyphVector. float adv = (float)(defaultGlyphPositions[glyphIndex+1].getX()- defaultGlyphPositions[glyphIndex] .getX()); glyphMetrics[glyphIndex] = new GVTGlyphMetrics ((float)(adv*scaleFactor), (ascent+descent), bounds, GlyphMetrics.STANDARD); return glyphMetrics[glyphIndex]; }
/** * Returns the metrics of the glyph at the specified index into this * GVTGlyphVector. */ public GVTGlyphMetrics getGlyphMetrics(int glyphIndex) { if (glyphMetrics[glyphIndex] != null) return glyphMetrics[glyphIndex]; // -- start glyph cache code -- Point2D glyphPos = defaultGlyphPositions[glyphIndex]; char c = ci.setIndex(ci.getBeginIndex()+glyphIndex); ci.setIndex(ci.getBeginIndex()); AWTGlyphGeometryCache.Value v = AWTGVTFont.getGlyphGeometry (gvtFont, c, awtGlyphVector, glyphIndex, glyphPos); Rectangle2D gmB = v.getBounds2D(); // -- end glyph cache code -- Rectangle2D bounds = new Rectangle2D.Double (gmB.getX() * scaleFactor, gmB.getY() * scaleFactor, gmB.getWidth() * scaleFactor, gmB.getHeight() * scaleFactor); // defaultGlyphPositions has one more entry than glyphs // the last entry stores the total advance for the // glyphVector. float adv = (float)(defaultGlyphPositions[glyphIndex+1].getX()- defaultGlyphPositions[glyphIndex] .getX()); glyphMetrics[glyphIndex] = new GVTGlyphMetrics ((float)(adv*scaleFactor), (ascent+descent), bounds, GlyphMetrics.STANDARD); return glyphMetrics[glyphIndex]; }