* @see #setClip
*/
public void drawString(String s, float x, float y) {
preparePainting();
Font fontState;
AffineTransform fontTransform = null;
if (ovFontState == null) {
java.awt.Font gFont = getFont();
fontTransform = gFont.getTransform();
fontState = getInternalFontForAWTFont(gFont);
} else {
fontState = fontInfo.getFontInstance(
ovFontState.getFontTriplet(), ovFontState.getFontSize());
ovFontState = null;
}
updateCurrentFont(fontState);
currentStream.write("q\n");
Color c = getColor();
applyColor(c, true);
applyPaint(getPaint(), true);
applyAlpha(c.getAlpha(), OPAQUE);
Map kerning = fontState.getKerning();
boolean kerningAvailable = (kerning != null && !kerning.isEmpty());
boolean useMultiByte = isMultiByteFont(currentFontName);
// String startText = useMultiByte ? "<FEFF" : "(";
String startText = useMultiByte ? "<" : "(";
String endText = useMultiByte ? "> " : ") ";
AffineTransform trans = getTransform();
//trans.translate(x, y);
double[] vals = new double[6];
trans.getMatrix(vals);
concatMatrix(vals);
Shape imclip = getClip();
writeClip(imclip);
currentStream.write("BT\n");
AffineTransform localTransform = new AffineTransform();
localTransform.translate(x, y);
if (fontTransform != null) {
localTransform.concatenate(fontTransform);
}
localTransform.scale(1, -1);
double[] lt = new double[6];
localTransform.getMatrix(lt);
currentStream.write(PDFNumber.doubleOut(lt[0]) + " "
+ PDFNumber.doubleOut(lt[1]) + " " + PDFNumber.doubleOut(lt[2]) + " "
+ PDFNumber.doubleOut(lt[3]) + " " + PDFNumber.doubleOut(lt[4]) + " "
+ PDFNumber.doubleOut(lt[5]) + " Tm [" + startText);
int l = s.length();
for (int i = 0; i < l; i++) {
char ch = fontState.mapChar(s.charAt(i));
if (!useMultiByte) {
if (ch > 127) {
currentStream.write("\\");
currentStream.write(Integer.toOctalString((int)ch));
} else {
switch (ch) {
case '(':
case ')':
case '\\':
currentStream.write("\\");
break;
default:
}
currentStream.write(ch);
}
} else {
currentStream.write(PDFText.toUnicodeHex(ch));
}
if (kerningAvailable && (i + 1) < l) {
addKerning(currentStream, (new Integer((int)ch)),
(new Integer((int)fontState.mapChar(s.charAt(i + 1)))),
kerning, startText, endText);
}
}
currentStream.write(endText);