public int ShuffleSubsetNames() {
int total = 0;
for (int k = 1; k < xrefObj.Count; ++k) {
PdfObject obj = GetPdfObjectRelease(k);
if (obj == null || !obj.IsDictionary())
continue;
PdfDictionary dic = (PdfDictionary)obj;
if (!ExistsName(dic, PdfName.TYPE, PdfName.FONT))
continue;
if (ExistsName(dic, PdfName.SUBTYPE, PdfName.TYPE1)
|| ExistsName(dic, PdfName.SUBTYPE, PdfName.MMTYPE1)
|| ExistsName(dic, PdfName.SUBTYPE, PdfName.TRUETYPE)) {
String s = GetSubsetPrefix(dic);
if (s == null)
continue;
String ns = BaseFont.CreateSubsetPrefix() + s.Substring(7);
PdfName newName = new PdfName(ns);
dic.Put(PdfName.BASEFONT, newName);
SetXrefPartialObject(k, dic);
++total;
PdfDictionary fd = dic.GetAsDict(PdfName.FONTDESCRIPTOR);
if (fd == null)
continue;
fd.Put(PdfName.FONTNAME, newName);
}
else if (ExistsName(dic, PdfName.SUBTYPE, PdfName.TYPE0)) {
String s = GetSubsetPrefix(dic);
PdfArray arr = dic.GetAsArray(PdfName.DESCENDANTFONTS);
if (arr == null)
continue;
if (arr.IsEmpty())
continue;
PdfDictionary desc = arr.GetAsDict(0);
String sde = GetSubsetPrefix(desc);
if (sde == null)
continue;
String ns = BaseFont.CreateSubsetPrefix();
if (s != null)
dic.Put(PdfName.BASEFONT, new PdfName(ns + s.Substring(7)));
SetXrefPartialObject(k, dic);
PdfName newName = new PdfName(ns + sde.Substring(7));
desc.Put(PdfName.BASEFONT, newName);
++total;
PdfDictionary fd = desc.GetAsDict(PdfName.FONTDESCRIPTOR);
if (fd == null)
continue;
fd.Put(PdfName.FONTNAME, newName);
}
}
return total;
}