internal void Process(byte[] ttfAfm, bool preload)
{
tables = new Dictionary<string,int[]>();
try {
if (ttfAfm == null)
rf = new RandomAccessFileOrArray(fileName, preload);
else
rf = new RandomAccessFileOrArray(ttfAfm);
if (ttcIndex.Length > 0) {
int dirIdx = int.Parse(ttcIndex);
if (dirIdx < 0)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.font.index.for.1.must.be.positive", fileName));
string mainTag = ReadStandardString(4);
if (!mainTag.Equals("ttcf"))
throw new DocumentException(MessageLocalization.GetComposedMessage("1.is.not.a.valid.ttc.file", fileName));
rf.SkipBytes(4);
int dirCount = rf.ReadInt();
if (dirIdx >= dirCount)
throw new DocumentException(MessageLocalization.GetComposedMessage("the.font.index.for.1.must.be.between.0.and.2.it.was.3", fileName, (dirCount - 1), dirIdx));
rf.SkipBytes(dirIdx * 4);
directoryOffset = rf.ReadInt();
}
rf.Seek(directoryOffset);
int ttId = rf.ReadInt();
if (ttId != 0x00010000 && ttId != 0x4F54544F)
throw new DocumentException(MessageLocalization.GetComposedMessage("1.is.not.a.valid.ttf.or.otf.file", fileName));
int num_tables = rf.ReadUnsignedShort();
rf.SkipBytes(6);
for (int k = 0; k < num_tables; ++k) {
string tag = ReadStandardString(4);
rf.SkipBytes(4);
int[] table_location = new int[2];
table_location[0] = rf.ReadInt();
table_location[1] = rf.ReadInt();
tables[tag] = table_location;
}
CheckCff();
fontName = BaseFont;
fullName = GetNames(4); //full name
familyName = GetNames(1); //family name
allNameEntries = GetAllNames();
if (!justNames) {
FillTables();
ReadGlyphWidths();
ReadCMaps();
ReadKerning();
ReadBbox();
GlyphWidths = null;
}
}
finally {
if (rf != null) {
rf.Close();
if (!embedded)
rf = null;
}
}
}