final boolean embed = globalEmbed || layoutContext.getBooleanStyleProperty(TextStyleKeys.EMBEDDED_FONT);
final boolean bold = layoutContext.getBooleanStyleProperty(TextStyleKeys.BOLD);
final boolean italics = layoutContext.getBooleanStyleProperty(TextStyleKeys.ITALIC);
final BaseFontFontMetrics fontMetrics = getMetaData().getBaseFontFontMetrics
(fontName, fontSize, bold, italics, encoding, embed, false);
final PdfGraphics2D g2 = (PdfGraphics2D) getGraphics();
final Color cssColor = (Color) layoutContext.getStyleProperty(ElementStyleKeys.PAINT);
g2.setPaint(cssColor);
g2.setFillPaint();
g2.setStrokePaint();
//final float translateY = (float) affineTransform.getTranslateY();
cb = g2.getRawContentByte();
textSpec = new PdfTextSpec(layoutContext, getMetaData(), g2, fontMetrics, cb);
setTextSpec(textSpec);
cb.beginText();
cb.setFontAndSize(fontMetrics.getBaseFont(), fontSize);
}
else
{
cb = textSpec.getContentByte();
}
final BaseFontFontMetrics baseFontRecord = textSpec.getFontMetrics();
final BaseFont baseFont = baseFontRecord.getBaseFont();
final float ascent = baseFont.getFontDescriptor(BaseFont.BBOXURY, textSpec.getFontSize());
final float y2 = (float) (StrictGeomUtility.toExternalValue(posY) + ascent);
final float y = globalHeight - y2;
final AffineTransform affineTransform = textSpec.getGraphics().getTransform();
final float translateX = (float) affineTransform.getTranslateX();
final FontNativeContext nativeContext = baseFontRecord.getNativeContext();
if (baseFontRecord.isTrueTypeFont() && textSpec.isBold() && nativeContext.isNativeBold() == false)
{
final float strokeWidth = textSpec.getFontSize() / 30.0f; // right from iText ...
if (strokeWidth == 1)
{
cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
}
else
{
cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE);
cb.setLineWidth(strokeWidth);
}
}
else
{
cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
}
// if the font does not declare to be italics already, emulate it ..
if (baseFontRecord.isTrueTypeFont() && textSpec.isItalics() && nativeContext.isNativeItalics() == false)
{
final float italicAngle =
baseFont.getFontDescriptor(BaseFont.ITALICANGLE, textSpec.getFontSize());
if (italicAngle == 0)
{