singleByteFont = (SingleByteFont)tf;
}
Font font = getFontInfo().getFontInstance(triplet, sizeMillipoints);
String fontName = font.getFontName();
PDFTextUtil textutil = generator.getTextUtil();
textutil.updateTf(fontKey, fontSize, tf.isMultiByte());
generator.updateCharacterSpacing(letterSpacing / 1000f);
textutil.writeTextMatrix(new AffineTransform(1, 0, 0, -1, x / 1000f, y / 1000f));
int l = text.length();
int dxl = (dx != null ? dx.length : 0);
if (dx != null && dxl > 0 && dx[0] != 0) {
textutil.adjustGlyphTJ(-dx[0] / fontSize);
}
for (int i = 0; i < l; i++) {
char orgChar = text.charAt(i);
char ch;
float glyphAdjust = 0;
if (font.hasChar(orgChar)) {
ch = font.mapChar(orgChar);
if (singleByteFont != null && singleByteFont.hasAdditionalEncodings()) {
int encoding = ch / 256;
if (encoding == 0) {
textutil.updateTf(fontName, fontSize, tf.isMultiByte());
} else {
textutil.updateTf(fontName + "_" + Integer.toString(encoding),
fontSize, tf.isMultiByte());
ch = (char)(ch % 256);
}
}
if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) {
glyphAdjust += wordSpacing;
}
} else {
if (CharUtilities.isFixedWidthSpace(orgChar)) {
//Fixed width space are rendered as spaces so copy/paste works in a reader
ch = font.mapChar(CharUtilities.SPACE);
int spaceDiff = font.getCharWidth(ch) - font.getCharWidth(orgChar);
glyphAdjust = -spaceDiff;
} else {
ch = font.mapChar(orgChar);
if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) {
glyphAdjust += wordSpacing;
}
}
}
textutil.writeTJMappedChar(ch);
if (dx != null && i < dxl - 1) {
glyphAdjust += dx[i + 1];
}
if (glyphAdjust != 0) {
textutil.adjustGlyphTJ(-glyphAdjust / fontSize);
}
}
textutil.writeTJ();
}