public ScriptRecord GetScriptRecord(uint i) { ScriptRecord sr = null; if (i < ScriptCount) { uint offset = m_offsetScriptListTable + (uint)FieldOffsets.ScriptRecords + i*6; sr = new ScriptRecord(); sr.ScriptTag = m_bufTable.GetTag(offset); sr.ScriptTableOffset = m_bufTable.GetUshort(offset+4); } return sr; }
public ScriptRecord GetScriptRecord(uint i) { ScriptRecord sr = null; if (i < ScriptCount) { uint offset = m_offsetScriptListTable + (uint)FieldOffsets.ScriptRecords + i * 6; sr = new ScriptRecord(); sr.ScriptTag = m_bufTable.GetTag(offset); sr.ScriptTableOffset = m_bufTable.GetUshort(offset + 4); } return(sr); }
public static ScriptList CreateFrom(BinaryReader reader, long beginAt) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //https://www.microsoft.com/typography/otspec/chapter2.htm //ScriptList table //Type Name Description //USHORT ScriptCount Number of ScriptRecords //struct ScriptRecord //[ScriptCount] Array of ScriptRecords //-listed alphabetically by ScriptTag //ScriptRecord //Type Name Description //Tag ScriptTag 4-byte ScriptTag identifier //Offset Script Offset to Script table-from beginning of ScriptList ScriptList scriptList = new ScriptList(); ushort scriptCount = reader.ReadUInt16(); ScriptRecord[] scRecords = scriptList.scriptRecords = new ScriptRecord[scriptCount]; for (int i = 0; i < scriptCount; ++i) { //read script record scRecords[i] = new ScriptRecord( reader.ReadUInt32(), //tag reader.ReadInt16());//offset } //------------- ScriptTable[] scriptTables = scriptList.scriptTables = new ScriptTable[scriptCount]; //then read each for (int i = 0; i < scriptCount; ++i) { ScriptRecord scriptRecord = scRecords[i]; //move to ScriptTable scriptTable = ScriptTable.CreateFrom(reader, beginAt + scriptRecord.offset); scriptTable.scriptTag = scriptRecord.scriptTag; scriptTables[i] = scriptTable; } return scriptList; }
public static ScriptList CreateFrom(BinaryReader reader, long beginAt) { reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); //https://www.microsoft.com/typography/otspec/chapter2.htm //ScriptList table //Type Name Description //USHORT ScriptCount Number of ScriptRecords //struct ScriptRecord //[ScriptCount] Array of ScriptRecords //-listed alphabetically by ScriptTag //ScriptRecord //Type Name Description //Tag ScriptTag 4-byte ScriptTag identifier //Offset Script Offset to Script table-from beginning of ScriptList ScriptList scriptList = new ScriptList(); ushort scriptCount = reader.ReadUInt16(); ScriptRecord[] scRecords = new ScriptRecord[scriptCount]; for (int i = 0; i < scriptCount; ++i) { //read script record scRecords[i] = new ScriptRecord( reader.ReadUInt32(), //tag reader.ReadInt16()); //offset } //------------- ScriptTable[] scriptTables = scriptList.scriptTables = new ScriptTable[scriptCount]; //then read each for (int i = 0; i < scriptCount; ++i) { ScriptRecord scriptRecord = scRecords[i]; //move to ScriptTable scriptTable = ScriptTable.CreateFrom(reader, beginAt + scriptRecord.offset); scriptTable.scriptTag = scriptRecord.scriptTag; scriptTables[i] = scriptTable; } return(scriptList); }
public ScriptTable_val GetScriptTable_val(ScriptRecord sr) { return new ScriptTable_val((ushort)(m_offsetScriptListTable + sr.ScriptTableOffset), m_bufTable); }
public ScriptTable_val GetScriptTable_val(ScriptRecord sr) { return(new ScriptTable_val((ushort)(m_offsetScriptListTable + sr.ScriptTableOffset), m_bufTable)); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bool bScriptListOk = true; // check that ScriptRecord array doesn't extend past end of table if (m_offsetScriptListTable + (uint)FieldOffsets.ScriptRecords + 6 * ScriptCount > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ScriptListTable_E_ScriptRecordArray_pastEOT, table.m_tag, sIdentity); bScriptListOk = false; bRet = false; } // check that ScriptRecord array is in alphabetical order if (ScriptCount > 1) { for (uint i = 0; i < ScriptCount - 1; i++) { ScriptRecord srCurr = GetScriptRecord(i); ScriptRecord srNext = GetScriptRecord(i + 1); if (srCurr.ScriptTag >= srNext.ScriptTag) { v.Error(T.T_NULL, E._OTL_ScriptListTable_E_ScriptRecordArray_order, table.m_tag, sIdentity); bScriptListOk = false; bRet = false; } } } // check each ScriptRecord for (uint i = 0; i < ScriptCount; i++) { // check the tag ScriptRecord sr = GetScriptRecord(i); if (!sr.ScriptTag.IsValid()) { v.Error(T.T_NULL, E._OTL_ScriptListTable_E_ScriptRecord_tag, table.m_tag, sIdentity + ", ScriptRecord[" + i + "]"); bScriptListOk = false; bRet = false; } // check the offset if (m_offsetScriptListTable + sr.ScriptTableOffset > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ScriptListTable_E_ScriptRecord_offset, table.m_tag, sIdentity + ", ScriptRecord[" + i + "]"); bScriptListOk = false; bRet = false; } // validate the ScriptTable ScriptTable_val st = GetScriptTable_val(sr); bRet &= st.Validate(v, sIdentity + ", ScriptRecord[" + i + "](" + sr.ScriptTag + "), ScriptTable", table); } if (bScriptListOk) { v.Pass(T.T_NULL, P._OTL_ScriptListTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
public void Script(byte[] script) { Write((seq, opt) => ScriptRecord.Write(seq, opt, script)); }
public virtual ScriptTable GetScriptTable(ScriptRecord sr) { return new ScriptTable((ushort)(m_offsetScriptListTable + sr.ScriptTableOffset), m_bufTable); }
public virtual ScriptTable GetScriptTable(ScriptRecord sr) { return(new ScriptTable((ushort)(m_offsetScriptListTable + sr.ScriptTableOffset), m_bufTable)); }