/** * Returns the metrics of this Glyph with the specified kerning value * applied. * * @param hkern The horizontal kerning value to apply when calculating * the glyph metrics. * @param vkern The horizontal vertical value to apply when calculating * the glyph metrics. * @return The kerned glyph metics */ public GVTGlyphMetrics getGlyphMetrics(float hkern, float vkern) { return new GVTGlyphMetrics(getHorizAdvX() - hkern, getVertAdvY() - vkern, getGeometryBounds(), GlyphMetrics.COMPONENT); }
/** * Returns the metrics of the glyph at the specified index into this * GlyphVector. */ public GVTGlyphMetrics getGlyphMetrics(int idx) { if (idx < 0 || (idx > glyphs.length-1)) throw new IndexOutOfBoundsException ("idx: " + idx + ", is out of bounds. Should be between 0 and " + (glyphs.length-1) + '.' ); // check to see if we should kern this glyph // I return the kerning information in the glyph metrics // as a first pass at implementation (I don't want to // fiddle with layout too much right now). if (idx < glyphs.length - 1) { // check for kerning if (font != null) { float hkern = font.getHKern(glyphs[idx].getGlyphCode(), glyphs[idx+1].getGlyphCode()); float vkern = font.getVKern(glyphs[idx].getGlyphCode(), glyphs[idx+1].getGlyphCode()); return glyphs[idx].getGlyphMetrics(hkern, vkern); } } // get a normal metrics return glyphs[idx].getGlyphMetrics(); }
/** * Returns the visual bounds of the specified glyph within the GlyphVector. */ public Shape getGlyphVisualBounds(int glyphIndex) { if (glyphIndex < 0 || (glyphIndex > glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex: " + glyphIndex + ", is out of bounds. Should be between 0 and " + (glyphs.length-1) + '.' ); } return glyphs[glyphIndex].getOutline(); }
/** * Returns the number of chars represented by the glyphs within the * specified range. * @param startGlyphIndex The index of the first glyph in the range. * @param endGlyphIndex The index of the last glyph in the range. * @return The number of chars. */ public int getCharacterCount(int startGlyphIndex, int endGlyphIndex) { int numChars = 0; if (startGlyphIndex < 0) { startGlyphIndex = 0; } if (endGlyphIndex > glyphs.length-1) { endGlyphIndex = glyphs.length-1; } for (int i = startGlyphIndex; i <= endGlyphIndex; i++) { Glyph glyph = glyphs[i]; if (glyph.getGlyphCode() == -1) { // Missing glyph mapps to just one char... numChars++; } else { String glyphUnicode = glyph.getUnicode(); numChars += glyphUnicode.length(); } } return numChars; }
for (int i = 0; i < glyphs.length; i++) { Glyph g = glyphs[i]; g.setTransform(null); glyphLogicalBounds[i] = null; String uni = g.getUnicode(); if ((uni != null) && (uni.length() != 0) && ArabicTextHandler.arabicCharTransparent(uni.charAt(0))) { int j; for (j=i+1; j<glyphs.length; j++) { uni = glyphs[j].getUnicode(); if ((uni == null) || (uni.length() == 0)) break; char ch = uni.charAt(0); float rEdge = currentX + bg.getHorizAdvX(); for (int k=i; k<j; k++) { g = glyphs[k]; g.setTransform(null); glyphLogicalBounds[i] = null; g.setPosition(new Point2D.Float(rEdge-g.getHorizAdvX(), currentY)); g.setPosition(new Point2D.Float(currentX, currentY)); currentX += g.getHorizAdvX();
/** * Constructs an SVGGVTGlyphVector. * * @param font The font that is creating this glyph vector. * @param glyphs An array containing the glyphs that form the basis for this * glyph vector. * @param frc The current font render context. */ public SVGGVTGlyphVector(GVTFont font, Glyph[] glyphs, FontRenderContext frc) { this.font = font; this.glyphs = glyphs; this.frc = frc; outline = null; bounds2D = null; logicalBounds = null; glyphLogicalBounds = new Shape[glyphs.length]; glyphVisible = new boolean[glyphs.length]; for (int i = 0; i < glyphs.length; i++) { glyphVisible[i] = true; } endPos = glyphs[glyphs.length-1].getPosition(); endPos = new Point2D.Float ((float)(endPos.getX()+glyphs[glyphs.length-1].getHorizAdvX()), (float)endPos.getY()); }
/** * Returns the position of the specified glyph within this GlyphVector. */ public Point2D getGlyphPosition(int glyphIndex) { if (glyphIndex == glyphs.length) return endPos; if (glyphIndex < 0 || (glyphIndex > glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex: " + glyphIndex + ", is out of bounds. Should be between 0 and " + (glyphs.length-1) + '.' ); } return glyphs[glyphIndex].getPosition(); }
/** * Returns the glyphcode of the specified glyph. */ public int getGlyphCode(int glyphIndex) throws IndexOutOfBoundsException { if (glyphIndex < 0 || glyphIndex > (glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex " + glyphIndex + " is out of bounds, should be between 0 and " + (glyphs.length-1)); } return glyphs[glyphIndex].getGlyphCode(); }
/** * Gets the transform of the specified glyph within this GlyphVector. */ public AffineTransform getGlyphTransform(int glyphIndex) { if (glyphIndex < 0 || (glyphIndex > glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex: " + glyphIndex + ", is out of bounds. Should be between 0 and " + (glyphs.length-1) + '.' ); } return glyphs[glyphIndex].getTransform(); }
/** * Draws this glyph vector. */ public void draw(Graphics2D graphics2D, AttributedCharacterIterator aci) { aci.first(); TextPaintInfo tpi = (TextPaintInfo)aci.getAttribute(PAINT_INFO); if (!tpi.visible) return; for (int i = 0; i < glyphs.length; i++) { if (glyphVisible[i]) { glyphs[i].draw(graphics2D); } } } }
/** * Returns a tight bounds on the GylphVector including stroking. */ public Rectangle2D getBounds2D(AttributedCharacterIterator aci) { // System.out.println("GlyphVector.getBounds2D Called: " + this); aci.first(); TextPaintInfo tpi = (TextPaintInfo)aci.getAttribute(PAINT_INFO); if ((bounds2D != null) && TextPaintInfo.equivilent(tpi, cacheTPI)) return bounds2D; Rectangle2D b=null; if (tpi.visible) { for (int i = 0; i < getNumGlyphs(); i++) { if (!glyphVisible[i]) continue; Rectangle2D glyphBounds = glyphs[i].getBounds2D(); // System.out.println("GB["+i+"]: " + glyphBounds); if (glyphBounds == null) continue; if (b == null) b=glyphBounds; //else b = glyphBounds.createUnion(b); else b.add( glyphBounds ); } } bounds2D = b; if ( bounds2D == null ){ bounds2D = new Rectangle2D.Float(); } cacheTPI = new TextPaintInfo(tpi); return bounds2D; }
return new Glyph(unicode, names, orientation, arabicForm, lang, horizOrigin, vertOrigin, horizAdvX, vertAdvY, glyphCode,
for (int i = 0; i < glyphs.length; i++) { Glyph g = glyphs[i]; g.setTransform(null); glyphLogicalBounds[i] = null; String uni = g.getUnicode(); if ((uni != null) && (uni.length() != 0) && ArabicTextHandler.arabicCharTransparent(uni.charAt(0))) { int j; for (j=i+1; j<glyphs.length; j++) { uni = glyphs[j].getUnicode(); if ((uni == null) || (uni.length() == 0)) break; char ch = uni.charAt(0); float rEdge = currentX + bg.getHorizAdvX(); for (int k=i; k<j; k++) { g = glyphs[k]; g.setTransform(null); glyphLogicalBounds[i] = null; g.setPosition(new Point2D.Float(rEdge-g.getHorizAdvX(), currentY)); g.setPosition(new Point2D.Float(currentX, currentY)); currentX += g.getHorizAdvX();
/** * Constructs an SVGGVTGlyphVector. * * @param font The font that is creating this glyph vector. * @param glyphs An array containing the glyphs that form the basis for this * glyph vector. * @param frc The current font render context. */ public SVGGVTGlyphVector(GVTFont font, Glyph[] glyphs, FontRenderContext frc) { this.font = font; this.glyphs = glyphs; this.frc = frc; outline = null; bounds2D = null; logicalBounds = null; glyphLogicalBounds = new Shape[glyphs.length]; glyphVisible = new boolean[glyphs.length]; for (int i = 0; i < glyphs.length; i++) { glyphVisible[i] = true; } endPos = glyphs[glyphs.length-1].getPosition(); endPos = new Point2D.Float ((float)(endPos.getX()+glyphs[glyphs.length-1].getHorizAdvX()), (float)endPos.getY()); }
/** * Returns the number of chars represented by the glyphs within the * specified range. * @param startGlyphIndex The index of the first glyph in the range. * @param endGlyphIndex The index of the last glyph in the range. * @return The number of chars. */ public int getCharacterCount(int startGlyphIndex, int endGlyphIndex) { int numChars = 0; if (startGlyphIndex < 0) { startGlyphIndex = 0; } if (endGlyphIndex > glyphs.length-1) { endGlyphIndex = glyphs.length-1; } for (int i = startGlyphIndex; i <= endGlyphIndex; i++) { Glyph glyph = glyphs[i]; if (glyph.getGlyphCode() == -1) { // Missing glyph mapps to just one char... numChars++; } else { String glyphUnicode = glyph.getUnicode(); numChars += glyphUnicode.length(); } } return numChars; }
/** * Returns the position of the specified glyph within this GlyphVector. */ public Point2D getGlyphPosition(int glyphIndex) { if (glyphIndex == glyphs.length) return endPos; if (glyphIndex < 0 || (glyphIndex > glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex: " + glyphIndex + ", is out of bounds. Should be between 0 and " + (glyphs.length-1) + '.' ); } return glyphs[glyphIndex].getPosition(); }
/** * Returns the glyphcode of the specified glyph. */ public int getGlyphCode(int glyphIndex) throws IndexOutOfBoundsException { if (glyphIndex < 0 || glyphIndex > (glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex " + glyphIndex + " is out of bounds, should be between 0 and " + (glyphs.length-1)); } return glyphs[glyphIndex].getGlyphCode(); }
/** * Gets the transform of the specified glyph within this GlyphVector. */ public AffineTransform getGlyphTransform(int glyphIndex) { if (glyphIndex < 0 || (glyphIndex > glyphs.length-1)) { throw new IndexOutOfBoundsException("glyphIndex: " + glyphIndex + ", is out of bounds. Should be between 0 and " + (glyphs.length-1) + '.' ); } return glyphs[glyphIndex].getTransform(); }
/** * Draws this glyph vector. */ public void draw(Graphics2D graphics2D, AttributedCharacterIterator aci) { aci.first(); TextPaintInfo tpi = (TextPaintInfo)aci.getAttribute(PAINT_INFO); if (!tpi.visible) return; for (int i = 0; i < glyphs.length; i++) { if (glyphVisible[i]) { glyphs[i].draw(graphics2D); } } } }
/** * Returns a tight bounds on the GylphVector including stroking. */ public Rectangle2D getBounds2D(AttributedCharacterIterator aci) { // System.out.println("GlyphVector.getBounds2D Called: " + this); aci.first(); TextPaintInfo tpi = (TextPaintInfo)aci.getAttribute(PAINT_INFO); if ((bounds2D != null) && TextPaintInfo.equivilent(tpi, cacheTPI)) return bounds2D; Rectangle2D b=null; if (tpi.visible) { for (int i = 0; i < getNumGlyphs(); i++) { if (!glyphVisible[i]) continue; Rectangle2D glyphBounds = glyphs[i].getBounds2D(); // System.out.println("GB["+i+"]: " + glyphBounds); if (glyphBounds == null) continue; if (b == null) b=glyphBounds; //else b = glyphBounds.createUnion(b); else b.add( glyphBounds ); } } bounds2D = b; if ( bounds2D == null ){ bounds2D = new Rectangle2D.Float(); } cacheTPI = new TextPaintInfo(tpi); return bounds2D; }