paintingState.setFontSize(fontSize);
// register font as necessary
String internalFontName = getInternalFontNameForArea(text);
Map/*<String,FontMetrics>*/ fontMetricMap = fontInfo.getFonts();
AFPFont font = (AFPFont)fontMetricMap.get(internalFontName);
AFPPageFonts pageFonts = paintingState.getPageFonts();
AFPFontAttributes fontAttributes = pageFonts.registerFont(internalFontName, font, fontSize);
Font fnt = getFontFromArea(text);
if (font.isEmbeddable()) {
CharacterSet charSet = font.getCharacterSet(fontSize);
try {
this.resourceManager.embedFont(font, charSet);
} catch (IOException ioe) {
AFPEventProducer eventProducer
= AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
eventProducer.resourceEmbeddingError(this, charSet.getName(), ioe);
}
}
// create text data info
AFPTextDataInfo textDataInfo = new AFPTextDataInfo();
int fontReference = fontAttributes.getFontReference();
textDataInfo.setFontReference(fontReference);
int x = (currentIPPosition + text.getBorderAndPaddingWidthStart());
int y = (currentBPPosition + text.getOffset() + text.getBaselineOffset());
int[] coords = unitConv.mpts2units(new float[] {x, y} );
textDataInfo.setX(coords[X]);
textDataInfo.setY(coords[Y]);
Color color = (Color) text.getTrait(Trait.COLOR);
textDataInfo.setColor(color);
int textWordSpaceAdjust = text.getTextWordSpaceAdjust();
int textLetterSpaceAdjust = text.getTextLetterSpaceAdjust();
int textWidth = font.getWidth(' ', fontSize) / 1000;
textWidth = 0; //JM, the above is strange
int variableSpaceCharacterIncrement
= textWidth + textWordSpaceAdjust + textLetterSpaceAdjust;
variableSpaceCharacterIncrement
= Math.round(unitConv.mpt2units(variableSpaceCharacterIncrement));
textDataInfo.setVariableSpaceCharacterIncrement(variableSpaceCharacterIncrement);
int interCharacterAdjustment
= Math.round(unitConv.mpt2units(textLetterSpaceAdjust));
textDataInfo.setInterCharacterAdjustment(interCharacterAdjustment);
CharacterSet charSet = font.getCharacterSet(fontSize);
String encoding = charSet.getEncoding();
textDataInfo.setEncoding(encoding);
String textString = text.getText();
textDataInfo.setString(textString);