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);
try {
dataStream.createText(textDataInfo, textLetterSpaceAdjust, textWordSpaceAdjust, fnt, charSet);
} catch (UnsupportedEncodingException e) {
AFPEventProducer eventProducer
= AFPEventProducer.Provider.get(userAgent.getEventBroadcaster());
eventProducer.characterSetEncodingError(this, charSet.getName(), encoding);
}
// word.getOffset() = only height of text itself
// currentBlockIPPosition: 0 for beginning of line; nonzero
// where previous line area failed to take up entire allocated space