* to be crap, there is nothing we can do about it.
*/
public void drawText(int x, int y, String text) {
int unreadableCharAt = -1;
char[] chars = text.toCharArray();
PText pt = new PText(text);
pt.setTextPaint(currentPenColor);
pt.setFont(currentFont);
// Check to see if every character can be displayed by the current font.
for (int i = 0; i < chars.length; i++) {
if (!currentFont.canDisplay(chars[i])) {
// Set to the first not displayable character.
unreadableCharAt = i;
break;
}
}
// Have to find some working font and use it for this text entry.
if (unreadableCharAt != -1) {
Font[] allfonts =
GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (int j = 0; j < allfonts.length; j++) {
if (allfonts[j].canDisplay(chars[unreadableCharAt])) {
Font tempFont =
new Font(allfonts[j].getFontName(), currentFont.getStyle(),
currentFont.getSize());
pt.setFont(tempFont);
break;
}
}
}
pt.setX(x);
pt.setY(y);
layer.addChild(pt);
}