final Font font = getFontFromArea(text);
final int baseline = text.getBaselineOffset();
//for cursive fonts, so the text isn't clipped
int extraWidth = font.getFontSize() / 3;
final FontMetricsMapper mapper = (FontMetricsMapper)fontInfo.getMetricsFor(
font.getFontName());
int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000;
final int additionalBPD = maxAscent - baseline;
Graphics2DAdapter g2a = getGraphics2DAdapter();
final Rectangle paintRect = new Rectangle(
rx, currentBPPosition + text.getOffset() - additionalBPD,
text.getIPD() + extraWidth, text.getBPD() + additionalBPD);
RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
paintRect.width, paintRect.height, null);
Map atts = new java.util.HashMap();
atts.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP);
atts.put(SRC_TRANSPARENCY, "true");
rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
Graphics2DImagePainter painter = new Graphics2DImagePainter() {
public void paint(Graphics2D g2d, Rectangle2D area) {
g2d.setFont(mapper.getFont(font.getFontSize()));
g2d.translate(0, baseline + additionalBPD);
g2d.scale(1000, 1000);
g2d.setColor(col);
Java2DRenderer.renderText(text, g2d, font);
renderTextDecoration(g2d, mapper, fontsize, text, 0, 0);