uni2byte.put(kv.getKey().intValue(), kv.getValue().intValue());
}
}
}
catch (Exception ex) {
throw new ExceptionConverter(ex);
}
}
else {
if (enc.isName())
fillEncoding((PdfName)enc);
else if (enc.isDictionary()) {
PdfDictionary encDic = (PdfDictionary)enc;
enc = PdfReader.getPdfObject(encDic.get(PdfName.BASEENCODING));
if (enc == null)
fillEncoding(null);
else
fillEncoding((PdfName)enc);
PdfArray diffs = encDic.getAsArray(PdfName.DIFFERENCES);
if (diffs != null) {
diffmap = new IntHashtable();
int currentNumber = 0;
for (int k = 0; k < diffs.size(); ++k) {
PdfObject obj = diffs.getPdfObject(k);
if (obj.isNumber())
currentNumber = ((PdfNumber)obj).intValue();
else {
int c[] = GlyphList.nameToUnicode(PdfName.decodeName(((PdfName)obj).toString()));
if (c != null && c.length > 0) {
uni2byte.put(c[0], currentNumber);
diffmap.put(c[0], currentNumber);
}
else {
if (toUnicode == null) {
toUnicode = processToUnicode();
if (toUnicode == null) {
toUnicode = new CMapToUnicode();
}
}
final String unicode = toUnicode.lookup(new byte[]{(byte) currentNumber}, 0, 1);
if ((unicode != null) && (unicode.length() == 1)) {
this.uni2byte.put(unicode.charAt(0), currentNumber);
this.diffmap.put(unicode.charAt(0), currentNumber);
}
}
++currentNumber;
}
}
}
}
}
PdfArray newWidths = font.getAsArray(PdfName.WIDTHS);
PdfNumber first = font.getAsNumber(PdfName.FIRSTCHAR);
PdfNumber last = font.getAsNumber(PdfName.LASTCHAR);
if (BuiltinFonts14.containsKey(fontName)) {
BaseFont bf;
try {
bf = BaseFont.createFont(fontName, WINANSI, false);
}
catch (Exception e) {
throw new ExceptionConverter(e);
}
int e[] = uni2byte.toOrderedKeys();
for (int k = 0; k < e.length; ++k) {
int n = uni2byte.get(e[k]);
widths[n] = bf.getRawWidth(n, GlyphList.unicodeToName(e[k]));