class TrueTypeFontUnicode {
/**
* Gets the width of a <CODE>String</CODE> in normalized 1000 units.
* @param text the <CODE>String</CODE> to get the width of
* @return the width in normalized 1000 units
*/
@Override
public int getWidth(String text) {
if (vertical)
return text.length() * 1000;
int total = 0;
if (fontSpecific) {
char cc[] = text.toCharArray();
int len = cc.length;
for (int k = 0; k < len; ++k) {
char c = cc[k];
if ((c & 0xff00) == 0 || (c & 0xff00) == 0xf000)
total += getRawWidth(c & 0xff, null);
}
}
else {
int len = text.length();
for (int k = 0; k < len; ++k) {
if (Utilities.isSurrogatePair(text, k)) {
total += getRawWidth(Utilities.convertToUtf32(text, k), encoding);
++k;
}
else
total += getRawWidth(text.charAt(k), encoding);
}
}
return total;
}
}