internal static TableIndex?ReadCodedTableIndex(System.IO.Stream stream, CodedTableIndexKind indexKind, IDictionary <CodedTableIndexKind, Boolean> tRefSizes, Byte[] tmpArray, Boolean throwOnNull = true) { var idx = tRefSizes[indexKind] ? stream.ReadU32(tmpArray) : stream.ReadU16(tmpArray); TableIndex?retVal; if (CheckRowIndex(indexKind, throwOnNull, idx)) { var possibleTables = GetTablesForCodedIndex(indexKind); var rowIdx = (idx >> possibleTables.Item3); if (CheckRowIndex(indexKind, throwOnNull, rowIdx)) { retVal = new TableIndex(possibleTables.Item1[possibleTables.Item2 & idx].Value, (Int32)rowIdx - 1); } else { retVal = null; } } else { retVal = null; } return(retVal); }
// Zero-based internal static TableIndex ReadSimpleTableIndex(System.IO.Stream stream, Tables targetTable, UInt32[] tableSizes, Byte[] tmpArray) { return(new TableIndex(targetTable, ((Int32)(tableSizes[(Int32)targetTable] > UInt16.MaxValue ? stream.ReadU32(tmpArray) : stream.ReadU16(tmpArray))) - 1)); }