public static FeatureList CreateFrom(BinaryReader reader, long beginAt) { //https://www.microsoft.com/typography/otspec/chapter2.htm //FeatureList table //Type Name Description //USHORT FeatureCount Number of FeatureRecords in this table //struct FeatureRecord[FeatureCount] Array of FeatureRecords-zero-based (first feature has FeatureIndex = 0)-listed alphabetically by FeatureTag //FeatureRecord //Type Name Description //Tag FeatureTag 4-byte feature identification tag //Offset Feature Offset to Feature table-from beginning of FeatureList reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); // FeatureList featureList = new FeatureList(); ushort featureCount = reader.ReadUInt16(); FeatureRecord[] featureRecords = new FeatureRecord[featureCount]; for (int i = 0; i < featureCount; ++i) { //read script record featureRecords[i] = new FeatureRecord( reader.ReadUInt32(), //feature tag reader.ReadInt16()); //offset } //read each feature table FeatureTable[] featureTables = featureList.featureTables = new FeatureTable[featureCount]; for (int i = 0; i < featureCount; ++i) { FeatureRecord frecord = featureRecords[i]; (featureTables[i] = FeatureTable.CreateFrom(reader, beginAt + frecord.offset)).FeatureTag = frecord.featureTag; } return(featureList); }
public static FeatureList CreateFrom(BinaryReader reader, long beginAt) { //https://www.microsoft.com/typography/otspec/chapter2.htm //FeatureList table //Type Name Description //USHORT FeatureCount Number of FeatureRecords in this table //struct FeatureRecord[FeatureCount] Array of FeatureRecords-zero-based (first feature has FeatureIndex = 0)-listed alphabetically by FeatureTag //FeatureRecord //Type Name Description //Tag FeatureTag 4-byte feature identification tag //Offset Feature Offset to Feature table-from beginning of FeatureList reader.BaseStream.Seek(beginAt, SeekOrigin.Begin); // FeatureList featureList = new FeatureList(); ushort featureCount = reader.ReadUInt16(); FeatureRecord[] featureRecords = new FeatureRecord[featureCount]; for (int i = 0; i < featureCount; ++i) { //read script record featureRecords[i] = new FeatureRecord( reader.ReadUInt32(), //feature tag reader.ReadInt16()); //offset } //read each feature table FeatureTable[] featureTables = featureList.featureTables = new FeatureTable[featureCount]; for (int i = 0; i < featureCount; ++i) { FeatureRecord frecord = featureRecords[i]; (featureTables[i] = FeatureTable.CreateFrom(reader, beginAt + frecord.offset)).FeatureTag = frecord.featureTag; } return featureList; }
public FeatureRecord GetFeatureRecord(uint i) { FeatureRecord fr = null; if (i < FeatureCount) { uint offset = m_offsetFeatureListTable + (uint)FieldOffsets.FeatureRecordArray + i * 6; if (offset + 6 <= m_bufTable.GetLength()) { fr = new FeatureRecord(); fr.FeatureTag = m_bufTable.GetTag(offset); fr.FeatureTableOffset = m_bufTable.GetUshort(offset + 4); } } return(fr); }
private void PopulateGsubData(Dictionary <string, Dictionary <List <int>, int> > gsubData, FeatureRecord featureRecord, LookupListTable lookupListTable) { LookupTable[] lookups = lookupListTable.Lookups; Dictionary <List <int>, int> glyphSubstitutionMap = new Dictionary <List <int>, int>(); foreach (int lookupIndex in featureRecord.FeatureTable.LookupListIndices) { if (lookupIndex < lookups.Length) { ExtractData(glyphSubstitutionMap, lookups[lookupIndex]); } } Debug.WriteLine("debug: *********** extracting GSUB data for the feature: " + featureRecord.FeatureTag + ", glyphSubstitutionMap: " + glyphSubstitutionMap); gsubData[featureRecord.FeatureTag] = glyphSubstitutionMap; }
public FeatureTable_val GetFeatureTable_val(FeatureRecord fr) { return new FeatureTable_val((ushort)(m_offsetFeatureListTable + fr.FeatureTableOffset), m_bufTable); }
public FeatureTable_val GetFeatureTable_val(FeatureRecord fr) { return(new FeatureTable_val((ushort)(m_offsetFeatureListTable + fr.FeatureTableOffset), m_bufTable)); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bool bFeatureListOk = true; // check the FeatureRecord array length if (m_offsetFeatureListTable + (uint)FieldOffsets.FeatureRecordArray + FeatureCount * 6 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_FeatureListTable_E_FeatureRecordArray_pastEOT, table.m_tag, sIdentity); bFeatureListOk = false; bRet = false; } // check that the FeatureRecord array is sorted alphabetically if (FeatureCount > 1) { for (uint i = 0; i < FeatureCount - 1; i++) { FeatureRecord frCurr = GetFeatureRecord(i); FeatureRecord frNext = GetFeatureRecord(i + 1); if (frCurr.FeatureTag > frNext.FeatureTag) { v.Error(T.T_NULL, E._OTL_FeatureListTable_E_FeatureRecordArray_order, table.m_tag, sIdentity); bFeatureListOk = false; bRet = false; break; } } } // check each FeatureRecord for (uint i = 0; i < FeatureCount; i++) { FeatureRecord fr = GetFeatureRecord(i); if (fr != null) { // check tag if (!fr.FeatureTag.IsValid()) { v.Error(T.T_NULL, E._OTL_FeatureListTable_E_FeatureRecord_tag, table.m_tag, sIdentity + ", FeatureRecord[" + i + "]"); bFeatureListOk = false; bRet = false; } else if (!IsKnownFeatureTag(fr.FeatureTag)) { v.Warning(T.T_NULL, W._OTL_FeatureListTable_W_FeatureRecord_tag, table.m_tag, sIdentity + ", FeatureRecord[" + i + "], tag = '" + fr.FeatureTag + "'"); } // check offset if (m_offsetFeatureListTable + fr.FeatureTableOffset > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_FeatureListTable_E_FeatureRecord_offset, table.m_tag, sIdentity + ", FeatureRecord[" + i + "]"); bFeatureListOk = false; bRet = false; } else { // validate the feature table FeatureTable_val ft = GetFeatureTable_val(fr); bRet &= ft.Validate(v, sIdentity + ", FeatureRecord[" + i + "]" + "(" + (string)fr.FeatureTag + ")" + ", FeatureTable", table); } } else { bFeatureListOk = false; bRet = false; } } if (bFeatureListOk) { v.Pass(T.T_NULL, P._OTL_FeatureListTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
public bool Add(FeatureRecord t) { throw new System.NotImplementedException(); }
public virtual FeatureTable GetFeatureTable(FeatureRecord fr) { return new FeatureTable((ushort)(m_offsetFeatureListTable + fr.FeatureTableOffset), m_bufTable); }
public FeatureRecord GetFeatureRecord(uint i) { FeatureRecord fr = null; if (i < FeatureCount) { uint offset = m_offsetFeatureListTable + (uint)FieldOffsets.FeatureRecordArray + i*6; if (offset+6 <= m_bufTable.GetLength()) { fr = new FeatureRecord(); fr.FeatureTag = m_bufTable.GetTag(offset); fr.FeatureTableOffset = m_bufTable.GetUshort(offset + 4); } } return fr; }
public virtual FeatureTable GetFeatureTable(FeatureRecord fr) { return(new FeatureTable((ushort)(m_offsetFeatureListTable + fr.FeatureTableOffset), m_bufTable)); }