final int TRANSFORM_MASK = AffineTransform.TYPE_GENERAL_ROTATION
| AffineTransform.TYPE_GENERAL_TRANSFORM;
Rectangle2D bounds;
AffineTransform transform = getTransform();
AffineTransform frcTransform = frc.getTransform();
// XXX: for transforms where an angle between basis vectors is not 90
// degrees Rectanlge2D class doesn't fit as Logical bounds.
if ((transform.getType() & TRANSFORM_MASK) == 0) {
int width = 0;
for (int i = start; i < end; i++) {
width += peer.charWidth(chars[i]);
}
LineMetrics nlm = peer.getLineMetrics();
bounds = transform.createTransformedShape(
new Rectangle2D.Float(0, -nlm.getAscent(), width, nlm
.getHeight())).getBounds2D();
} else {
int len = end - start;
char[] subChars = new char[len];
System.arraycopy(chars, start, subChars, 0, len);
bounds = createGlyphVector(frc, subChars).getLogicalBounds();
}
if (!(frcTransform.isIdentity()))
return frcTransform.createTransformedShape(bounds).getBounds2D();
return bounds;
}