public static ScriptList CreateFrom(BinaryReader reader, long beginAt) { // https://www.microsoft.com/typography/otspec/chapter2.htm // // ScriptList table // Type Name Description // uint16 ScriptCount Number of ScriptRecords // struct ScriptRecord[ScriptCount] Array of ScriptRecords // -listed alphabetically by ScriptTag // ScriptRecord // Type Name Description // Tag ScriptTag 4-byte ScriptTag identifier // Offset16 Script Offset to Script table-from beginning of ScriptList reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); ushort scriptCount = reader.ReadUInt16(); ScriptList scriptList = new ScriptList(); // Read records (tags and table offsets) uint[] scriptTags = new uint[scriptCount]; ushort[] scriptOffsets = new ushort[scriptCount]; for (int i = 0; i < scriptCount; ++i) { scriptTags[i] = reader.ReadUInt32(); scriptOffsets[i] = reader.ReadUInt16(); } // Read each table and add it to the dictionary for (int i = 0; i < scriptCount; ++i) { ScriptTable scriptTable = ScriptTable.CreateFrom(reader, beginAt + scriptOffsets[i]); scriptTable.scriptTag = scriptTags[i]; scriptList.Add(Utils.TagToString(scriptTags[i]), scriptTable); } return(scriptList); }
public static ScriptList CreateFrom(BinaryReader reader, long beginAt) { // ScriptList table // Type Name Description // uint16 scriptCount Number of ScriptRecords // ScriptRecord scriptRecords[scriptCount] Array of ScriptRecords,listed alphabetically by ScriptTag // // ScriptRecord // Type Name Description // Tag scriptTag 4-byte ScriptTag identifier // Offset16 scriptOffset Offset to Script table-from beginning of ScriptList reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); ushort scriptCount = reader.ReadUInt16(); ScriptList scriptList = new ScriptList(); // Read records (tags and table offsets) uint[] scriptTags = new uint[scriptCount]; ushort[] scriptOffsets = new ushort[scriptCount]; for (int i = 0; i < scriptCount; ++i) { scriptTags[i] = reader.ReadUInt32(); scriptOffsets[i] = reader.ReadUInt16(); } // Read each table and add it to the dictionary for (int i = 0; i < scriptCount; ++i) { ScriptTable scriptTable = ScriptTable.CreateFrom(reader, beginAt + scriptOffsets[i]); scriptTable.scriptTag = scriptTags[i]; scriptList.Add(scriptTags[i], scriptTable); } return(scriptList); }