/** * Returns an instance of TextSpanLayout suitable for rendering the * AttributedCharacterIterator. * * @param aci The character iterator to be laid out * @param charMap Indicates how chars in aci map to original * text char array. * @param offset The offset position for the text layout. * @param frc The font render context to use when creating the text layout. */ public TextSpanLayout createTextLayout(AttributedCharacterIterator aci, int [] charMap, Point2D offset, FontRenderContext frc) { return new GlyphLayout(aci, charMap, offset, frc); } }
/** * Returns the current text position at the completion * of glyph layout. */ public Point2D getAdvance2D() { adjustTextSpacing(); return advance; }
/** * This method makes certain that the layout has been * completed at this point (much of the layout is done lazily). */ private final void syncLayout() { if (!pathApplied) { doPathLayout(); } }
/** * Returns the position to used when drawing a text run after this one. * It takes into account the text path layout if there is one. */ public Point2D getTextPathAdvance() { syncLayout(); if (textPath != null) { return textPathAdvance; } else { return getAdvance2D(); } }
adjustTextSpacing(); getGlyphAdvances(); boolean horizontal = !isVertical(); boolean glyphOrientationAuto = isGlyphOrientationAuto(); int glyphOrientationAngle = 0; if (!glyphOrientationAuto) { glyphOrientationAngle = getGlyphOrientationAngle();
boolean glyphOrientationAuto = isGlyphOrientationAuto(); int glyphOrientationAngle = 0; if (!glyphOrientationAuto) { glyphOrientationAngle = getGlyphOrientationAngle(); if (isVertical()) { if (glyphOrientationAuto) { if (isLatinChar(ch)) { (verticalFirstOffset == 0f) && !isLatinChar(ch)) { float advY = gm.getVerticalAdvance(); float asc = metrics.getAscent(); if (vertical) { if (glyphOrientationAuto) { if (isLatinChar(ch)) { if (isLatinChar(ch)) { ox += metrics.getStrikethroughOffset(); } else { float advanceY = 0; if (glyphOrientationAuto) { if (isLatinChar(ch)) { advanceY = gm.getHorizontalAdvance(); } else { if (!epsEQ(glyphRotation,0)) { AffineTransform glyphTransform = gv.getGlyphTransform(i);
syncLayout(); int numGlyphs = getGlyphCount(); addPtsToPath(shape, topPts, botPts, ptIdx); ptIdx = 0; shape.append(gbounds, false); currentChar += getCharacterCount(i, i); if (currentChar >= charMap.length) currentChar = charMap.length-1; addPtsToPath(shape, topPts, botPts, ptIdx);
/** * Does any spacing adjustments that may have been specified. */ protected void adjustTextSpacing() { if (spacingApplied) // Nothing to do... return; if (!layoutApplied) // Must have clean layout to do spacing... doExplicitGlyphLayout(); aci.first(); Boolean customSpacing = (Boolean) aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.CUSTOM_SPACING); if ((customSpacing != null) && customSpacing.booleanValue()) { advance = doSpacing ((Float) aci.getAttribute (GVTAttributedCharacterIterator.TextAttribute.KERNING), (Float) aci.getAttribute (GVTAttributedCharacterIterator.TextAttribute.LETTER_SPACING), (Float) aci.getAttribute (GVTAttributedCharacterIterator.TextAttribute.WORD_SPACING)); // Basic layout is now messed up... layoutApplied = false; } // This will clear layoutApplied if it mucks with the current // character positions. applyStretchTransform(!adjSpacing); spacingApplied = true; pathApplied = false; }
while (iter.hasNext()) { GlyphLayout gl = (GlyphLayout)iter.next(); gvl.add(gl.getGlyphVector()); if (((GlyphLayout)layouts.get(0)).isLeftToRight()) { leftMargin += mi.getIndent(); } else {
public float [] getGlyphAdvances() { if (glyphAdvances != null) return glyphAdvances; if (!spacingApplied) // This will layout the text if needed. adjustTextSpacing(); int numGlyphs = gv.getNumGlyphs(); float [] glyphPos = gv.getGlyphPositions(0, numGlyphs+1, null); glyphAdvances = new float[numGlyphs+1]; int off = 0; if (isVertical()) off = 1; float start = glyphPos[off]; for (int i=0; i<numGlyphs+1; i++) { glyphAdvances[i] = glyphPos[2*i+off]-start; } return glyphAdvances; }
while (iter.hasNext()) { GlyphLayout gl = (GlyphLayout)iter.next(); gvl.add(gl.getGlyphVector());
adjustTextSpacing(); getGlyphAdvances(); boolean horizontal = !isVertical(); boolean glyphOrientationAuto = isGlyphOrientationAuto(); int glyphOrientationAngle = 0; if (!glyphOrientationAuto) { glyphOrientationAngle = getGlyphOrientationAngle();
boolean glyphOrientationAuto = isGlyphOrientationAuto(); int glyphOrientationAngle = 0; if (!glyphOrientationAuto) { glyphOrientationAngle = getGlyphOrientationAngle(); if (isVertical()) { if (glyphOrientationAuto) { if (isLatinChar(ch)) { (verticalFirstOffset == 0f) && !isLatinChar(ch)) { float advY = gm.getVerticalAdvance(); float asc = metrics.getAscent(); if (vertical) { if (glyphOrientationAuto) { if (isLatinChar(ch)) { if (isLatinChar(ch)) { ox += metrics.getStrikethroughOffset(); } else { float advanceY = 0; if (glyphOrientationAuto) { if (isLatinChar(ch)) { advanceY = gm.getHorizontalAdvance(); } else { if (!epsEQ(glyphRotation,0)) { AffineTransform glyphTransform = gv.getGlyphTransform(i);
syncLayout(); int numGlyphs = getGlyphCount(); addPtsToPath(shape, topPts, botPts, ptIdx); ptIdx = 0; shape.append(gbounds, false); currentChar += getCharacterCount(i, i); if (currentChar >= charMap.length) currentChar = charMap.length-1; addPtsToPath(shape, topPts, botPts, ptIdx);
/** * Does any spacing adjustments that may have been specified. */ protected void adjustTextSpacing() { if (spacingApplied) // Nothing to do... return; if (!layoutApplied) // Must have clean layout to do spacing... doExplicitGlyphLayout(); aci.first(); Boolean customSpacing = (Boolean) aci.getAttribute( GVTAttributedCharacterIterator.TextAttribute.CUSTOM_SPACING); if ((customSpacing != null) && customSpacing) { advance = doSpacing ((Float) aci.getAttribute (GVTAttributedCharacterIterator.TextAttribute.KERNING), (Float) aci.getAttribute (GVTAttributedCharacterIterator.TextAttribute.LETTER_SPACING), (Float) aci.getAttribute (GVTAttributedCharacterIterator.TextAttribute.WORD_SPACING)); // Basic layout is now messed up... layoutApplied = false; } // This will clear layoutApplied if it mucks with the current // character positions. applyStretchTransform(!adjSpacing); spacingApplied = true; pathApplied = false; }
while (iter.hasNext()) { GlyphLayout gl = (GlyphLayout)iter.next(); gvl.add(gl.getGlyphVector()); if (((GlyphLayout)layouts.get(0)).isLeftToRight()) { leftMargin += mi.getIndent(); } else {
/** * Returns the position to used when drawing a text run after this one. * It takes into account the text path layout if there is one. */ public Point2D getTextPathAdvance() { syncLayout(); if (textPath != null) { return textPathAdvance; } else { return getAdvance2D(); } }
public float [] getGlyphAdvances() { if (glyphAdvances != null) return glyphAdvances; if (!spacingApplied) // This will layout the text if needed. adjustTextSpacing(); int numGlyphs = gv.getNumGlyphs(); float [] glyphPos = gv.getGlyphPositions(0, numGlyphs+1, null); glyphAdvances = new float[numGlyphs+1]; int off = 0; if (isVertical()) off = 1; float start = glyphPos[off]; for (int i=0; i<numGlyphs+1; i++) { glyphAdvances[i] = glyphPos[2*i+off]-start; } return glyphAdvances; }
for (Object layout : layouts) { GlyphLayout gl = (GlyphLayout) layout; gvl.add(gl.getGlyphVector());
adjustTextSpacing(); getGlyphAdvances(); boolean horizontal = !isVertical(); boolean glyphOrientationAuto = isGlyphOrientationAuto(); int glyphOrientationAngle = 0; if (!glyphOrientationAuto) { glyphOrientationAngle = getGlyphOrientationAngle();