final FontMetrics fm = g2.getFontMetrics();
final Rectangle2D rect = fm.getMaxCharBounds(g2);
final long awtBaseLine = StrictGeomUtility.toInternalValue(-rect.getY());
final GlyphList gs = renderableText.getGlyphs();
if (metaData.isFeatureSupported(OutputProcessorFeature.FAST_FONTRENDERING) &&
isNormalTextSpacing(renderableText))
{
final int maxLength = renderableText.computeMaximumTextSize(contentX2);
final String text = gs.getText(renderableText.getOffset(), maxLength, codePointBuffer);
final float y = (float) StrictGeomUtility.toExternalValue(posY + awtBaseLine);
g2.drawString(text, (float) StrictGeomUtility.toExternalValue(posX), y);
}
else
{
final ExtendedBaselineInfo baselineInfo = renderableText.getBaselineInfo();
final int maxPos = renderableText.getOffset() + renderableText.computeMaximumTextSize(contentX2);
long runningPos = posX;
final long baseline = baselineInfo.getBaseline(baselineInfo.getDominantBaseline());
final long baselineDelta = awtBaseLine - baseline;
final float y = (float) (StrictGeomUtility.toExternalValue
(posY + awtBaseLine + baselineDelta));
for (int i = renderableText.getOffset(); i < maxPos; i++)
{
final Glyph g = gs.getGlyph(i);
g2.drawString(gs.getGlyphAsString(i, codePointBuffer),
(float) StrictGeomUtility.toExternalValue(runningPos), y);
runningPos += RenderableText.convert(g.getWidth()) + g.getSpacing().getMinimum();
}
}
g2.dispose();