dy = (Float) aci.getAttribute(DY);
rotation = (Float) aci.getAttribute(ROTATION);
baseline = aci.getAttribute(BASELINE_SHIFT);
}
GVTGlyphMetrics gm = gv.getGlyphMetrics(i);
if (firstChar) {
if (glyphOrientationAuto) {
if (isLatinChar(ch)) {
// it will be rotated 90
verticalFirstOffset = 0f;
} else {
// it won't be rotated
verticalFirstOffset = (float)gm.getBounds2D().getHeight();
}
} else {
if (glyphOrientationAngle == 0) {
verticalFirstOffset = (float)gm.getBounds2D().getHeight();
} else {
verticalFirstOffset = 0f;
}
}
} else {
if (glyphOrientationAuto && (verticalFirstOffset == 0f)
&& !isLatinChar(ch)) {
verticalFirstOffset = (float)gm.getBounds2D().getHeight();
}
}
// ox and oy are origin adjustments for each glyph,
// computed on the basis of baseline-shifts, etc.
float ox = 0f;
float oy = 0f;
float verticalGlyphRotation = 0f;
float glyphRotation = 0f;
if (ch != CharacterIterator.DONE) {
if (vertical) {
if (glyphOrientationAuto) {
if (isLatinChar(ch)) {
// If character is Latin, then rotate by
// 90 degrees
verticalGlyphRotation = (float) (Math.PI / 2f);
} else {
verticalGlyphRotation = 0f;
}
} else {
verticalGlyphRotation = (float)Math.toRadians(glyphOrientationAngle);
}
if (textPath != null) {
// if vertical and on a path, any x's are ignored
x = null;
}
} else {
if (textPath != null) {
// if horizontal and on a path, any y's are ignored
y = null;
}
}
// calculate the total rotation for this glyph
if (rotation == null || rotation.isNaN()) {
glyphRotation = verticalGlyphRotation;
} else {
glyphRotation = (rotation.floatValue() +
verticalGlyphRotation);
}
if (x!= null && !x.isNaN()) {
if (i==0) {
if (applyOffset) {
curr_x_pos = (float) offset.getX();
} else {
curr_x_pos = x.floatValue();
init_x_pos = curr_x_pos;
}
} else {
curr_x_pos = x.floatValue();
}
} else if (dx != null && !dx.isNaN()) {
curr_x_pos += dx.floatValue();
}
if (y != null && !y.isNaN()) {
if (i==0) {
if (applyOffset) {
curr_y_pos = (float) offset.getY();
} else {
curr_y_pos = y.floatValue();
init_y_pos = curr_y_pos;
}
} else {
curr_y_pos = y.floatValue();
}
} else if (dy != null && !dy.isNaN()) {
curr_y_pos += dy.floatValue();
} else if (i>0) {
curr_y_pos += gp[i*2 + 1]-gp[i*2 - 1];
}
float baselineAdjust = 0f;
if (baseline != null) {
if (baseline instanceof Integer) {
if (baseline==TextAttribute.SUPERSCRIPT_SUPER) {
baselineAdjust = baselineAscent*0.5f;
} else if (baseline==TextAttribute.SUPERSCRIPT_SUB) {
baselineAdjust = -baselineAscent*0.5f;
}
} else if (baseline instanceof Float) {
baselineAdjust = ((Float) baseline).floatValue();
}
if (vertical) {
ox = baselineAdjust;
} else {
oy = -baselineAdjust;
}
}
if (vertical) {
// offset due to rotation of first character
oy += verticalFirstOffset;
if (glyphOrientationAuto) {
if (isLatinChar(ch)) {
ox += metrics.getStrikethroughOffset();
} else {
Rectangle2D glyphBounds = gv.getGlyphVisualBounds(i).getBounds2D();
Point2D glyphPos = gv.getGlyphPosition(i);
ox -= (float)((glyphBounds.getMaxX() - glyphPos.getX()) - glyphBounds.getWidth()/2);
}
} else {
// center the character if it's not auto orient
Rectangle2D glyphBounds = gv.getGlyphVisualBounds(i).getBounds2D();
Point2D glyphPos = gv.getGlyphPosition(i);
if (glyphOrientationAngle == 0) {
ox -= (float)((glyphBounds.getMaxX() - glyphPos.getX()) - glyphBounds.getWidth()/2);
} else if (glyphOrientationAngle == 180) {
ox += (float)((glyphBounds.getMaxX() - glyphPos.getX()) - glyphBounds.getWidth()/2);
} else if (glyphOrientationAngle == 90) {
ox += metrics.getStrikethroughOffset();
} else { // 270
ox -= metrics.getStrikethroughOffset();
}
}
}
}
// set the new glyph position
gv.setGlyphPosition(i, new Point2D.Float(curr_x_pos+ox,curr_y_pos+oy));
// calculte the position of the next glyph
if (!ArabicTextHandler.arabicCharTransparent(ch)) {
// only apply the advance if the current char is not transparen
if (vertical) {
float advanceY = 0;
if (glyphOrientationAuto) {
if (isLatinChar(ch)) {
advanceY = gm.getHorizontalAdvance();
} else {
advanceY = gm.getVerticalAdvance();
}
} else {
if ((glyphOrientationAngle == 0) ||
(glyphOrientationAngle == 180)) {
advanceY = gm.getVerticalAdvance();
} else if (glyphOrientationAngle == 90) {
advanceY = gm.getHorizontalAdvance();
} else { // 270
advanceY = gm.getHorizontalAdvance();
// need to translate so that the spacing
// between chars is correct
gv.setGlyphTransform(i, AffineTransform.getTranslateInstance(0, advanceY));
}
}
curr_y_pos += advanceY;
} else {
curr_x_pos += gm.getHorizontalAdvance();
}
}
// rotate the glyph
if (glyphRotation != 0f) {