public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; if (CoverageFormat == 1) { if (m_offsetCoverageTable + (uint)FieldOffsets1.GlyphArray + F1GlyphCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_CoverageTable_E_GlyphArrayPastEOT, table.m_tag, sIdentity); bRet = false; } } else if (CoverageFormat == 2) { if (m_offsetCoverageTable + (uint)FieldOffsets2.RangeRecordArray + F2RangeCount * 6 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_CoverageTable_E_RangeRecordArrayPastEOT, table.m_tag, sIdentity); bRet = false; } } else { v.Error(T.T_NULL, E._OTL_CoverageTable_E_Format, table.m_tag, sIdentity + ", format = " + CoverageFormat.ToString()); bRet = false; } // way too many coverage tables to justify this pass message //if (bRet) //{ // v.Pass("_OTL_CoverageTable_P_valid", table.m_tag, sIdentity); //} return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check for data overlap bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfMax, CalcLength(), v, sIdentity, table.GetTag()); // check the Lookup array length if (m_offsetJstfMax + (uint)FieldOffsets.LookupOffsets + LookupCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", Lookup"); bRet = false; } // check each Lookup offset for (uint i = 0; i < LookupCount; i++) { if (m_offsetJstfMax + GetLookupOffset(i) > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", Lookup[" + i + "]"); bRet = false; } } // check each Lookup table for (uint i = 0; i < LookupCount; i++) { LookupTable_val lt = GetLookupTable_val(i); bRet &= lt.Validate(v, sIdentity + ", Lookup[" + i + "]", table); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check for data overlap bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfLangSys, CalcLength(), v, sIdentity, table.GetTag()); // check the JstfPriority array length if (m_offsetJstfLangSys + (uint)FieldOffsets.JstfPriorityOffsets + JstfPriorityCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", JstfPriority array"); bRet = false; } // check each JstfPriority offset for (uint i = 0; i < JstfPriorityCount; i++) { if (m_offsetJstfLangSys + GetJstfPriorityOffset(i) > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", JstfPriority[" + i + "]"); bRet = false; } } // check each JstfPriority table for (uint i = 0; i < JstfPriorityCount; i++) { JstfPriority_val jp = GetJstfPriorityTable_val(i); bRet &= jp.Validate(v, sIdentity + ", JstfPriority[" + i + "]", table); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check for data overlap bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfGPOSModList, CalcLength(), v, sIdentity, table.GetTag()); // check GPOSLookupIndex array size if (m_offsetJstfGPOSModList + (uint)FieldOffsets.GPOSLookupIndex + LookupCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", GPOSLookupIndex"); bRet = false; } // check that GPOSLookupIndex is in increasing numerical order if (LookupCount > 1) { for (uint i = 0; i < LookupCount - 1; i++) { if (GetGPOSLookupIndex(i) >= GetGPOSLookupIndex(i + 1)) { v.Error(T.T_NULL, E.JSTF_E_Array_order, table.m_tag, sIdentity + ", GPOSLookupIndex"); bRet = false; break; } } } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check for data overlap bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetExtenderGlyph, CalcLength(), v, sIdentity, table.GetTag()); // check the ExtenderGlyph array length if (m_offsetExtenderGlyph + (uint)FieldOffsets.ExtenderGlyphs + GlyphCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", ExtenderGlyph array"); bRet = false; } // check that the ExtenderGlyph array is in increasing numerical order if (GlyphCount > 1) { for (uint i = 0; i < GlyphCount - 1; i++) { if (GetExtenderGlyph(i) >= GetExtenderGlyph(i + 1)) { v.Error(T.T_NULL, E.JSTF_E_Array_order, table.m_tag, sIdentity + ", ExtenderGlyph array"); bRet = false; break; } } } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_GDEF)table).ValidateNoOverlap(m_offsetMarkGlyphSetsDefTable, CalcLength(), v, sIdentity, table.GetTag()); if (MarkSetTableFormat != 1) { v.Error(T.T_NULL, E.GDEF_E_MarkSetTableFormat, table.m_tag, sIdentity + ": MarkSetTableFormat=" + MarkSetTableFormat.ToString()); bRet = false; } if (m_offsetMarkGlyphSetsDefTable + CalcLength() > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.GDEF_E_MarkGlyphSetsDefTable_PastEOT, table.m_tag, sIdentity); bRet = false; } v.Info(T.T_NULL, I.GDEF_I_MarkSetCount, table.m_tag, sIdentity + ": MarkSetCount=" + MarkSetCount); // TODO: check Coverage [MarkSetCount] array? if (bRet) { v.Pass(T.T_NULL, P.GDEF_P_MarkGlyphSetsDefTable, table.m_tag, sIdentity); } return bRet; }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check that FeatureParams is null if (FeatureParams != 0) { v.Error(T.T_NULL, E._OTL_FeatureTable_E_FeatureParams_nonnull, table.m_tag, sIdentity); bRet = false; } // check LookupListIndex array length if (m_offsetFeatureTable + (uint)FieldOffsets.LookupListIndexArray + LookupCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_FeatureTable_E_LookupListIndexArray_pastEOT, table.m_tag, sIdentity); bRet = false; } if (bRet) { v.Pass(T.T_NULL, P._OTL_FeatureTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; if (ClassFormat == 1) { ClassDefFormat1_val cdf1 = GetClassDefFormat1_val(); bRet &= cdf1.Validate(v, sIdentity + "(Fmt1)", table); } else if (ClassFormat == 2) { ClassDefFormat2_val cdf2 = GetClassDefFormat2_val(); bRet &= cdf2.Validate(v, sIdentity + "(Fmt2)", table); } else { v.Error(T.T_NULL, E._OTL_ClassDefinitionTable_E_Format, table.m_tag, sIdentity + ", format = " + ClassFormat.ToString()); bRet = false; } // way too many ClassDefTables to justify this pass message //if (bRet) //{ // v.Pass("_OTL_ClassDefinitionTable_P_valid", table.m_tag, sIdentity); //} return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check StartSize for unreasonable values if (StartSize > 16384) { v.Warning(T.T_NULL, W._OTL_DeviceTable_W_StartSize, table.m_tag, sIdentity + ", StartSize = " + StartSize); } // check EndSize for unreasonable values if (EndSize > 16384) { v.Warning(T.T_NULL, W._OTL_DeviceTable_W_EndSize, table.m_tag, sIdentity + ", EndSize = " + EndSize); } // check that StartSize <= EndSize if (StartSize > EndSize) { v.Error(T.T_NULL, E._OTL_DeviceTable_E_sizes, table.m_tag, sIdentity); bRet = false; } // check DeltaFormat is 1, 2, 3, or VARIATION_INDEX if ((DeltaFormat < 1 || DeltaFormat > 3) && (DeltaFormat != 0x8000)) { v.Error(T.T_NULL, E._OTL_DeviceTable_E_DeltaFormat, table.m_tag, sIdentity + ", DeltaFormat = " + DeltaFormat); bRet = false; } else { if (DeltaFormat >= 1 || DeltaFormat <= 3) { // check that DeltaValue array doesn't extend past the end of the table int nSizes = EndSize - StartSize + 1; int nValuesPerUint = 16 >> DeltaFormat; int nUints = nSizes / nValuesPerUint; if (nSizes % nValuesPerUint != 0) { nUints++; } if (m_offsetDeviceTable + (uint)FieldOffsets.DeltaValueArray + nUints > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_DeviceTable_E_DeltaValueArray_pastEOT, table.m_tag, sIdentity); bRet = false; } } // TODO: VARIATION_INDEX check } // way too many device tables to justify this pass message //if (bRet) //{ // v.Pass("_OTL_DeviceTable_P_valid", table.m_tag, sIdentity); //} return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable tableOwner) { bool bOk = true; // ??? // ??? are there any values that are invalid ??? // ??? return(bOk); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_GDEF)table).ValidateNoOverlap(m_offsetLigCaretListTable, CalcLength(), v, sIdentity, table.GetTag()); if (CoverageOffset == 0) { v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_CoverageOffset_0, table.m_tag, sIdentity); bRet = false; } else if (CoverageOffset > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_CoverageOffset_invalid, table.m_tag, sIdentity); bRet = false; } else { v.Pass(T.T_NULL, P.GDEF_P_LigCaretListTable_CoverageOffset, table.m_tag, sIdentity); CoverageTable_val ct = GetCoverageTable_val(); ct.Validate(v, sIdentity + ", Coverage", table); } if (m_offsetLigCaretListTable + (uint)FieldOffsets.LigGlyphOffsets + LigGlyphCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_LigGlyphArray_PastEOT, table.m_tag, sIdentity); bRet = false; } bool bOffsetsOk = true; for (uint i = 0; i < LigGlyphCount; i++) { if (m_offsetLigCaretListTable + GetLigGlyphOffset(i) > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_LigGlyphOffset, table.m_tag, sIdentity + ", index = " + i); bOffsetsOk = false; bRet = false; } else { LigGlyphTable_val lgt = GetLigGlyphTable_val(i); lgt.Validate(v, sIdentity + ", LigGlyph[" + i + "]", table); } } if (bOffsetsOk) { v.Pass(T.T_NULL, P.GDEF_P_LigCaretListTable_LigGlyphArray, table.m_tag, sIdentity); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseScriptListTable, CalcLength(), v, sIdentity, table.GetTag()); bool bOrderOk = true; if (BaseScriptCount > 1) { for (uint i = 0; i < BaseScriptCount - 1; i++) { BaseScriptRecord ThisBsr = GetBaseScriptRecord(i); BaseScriptRecord NextBsr = GetBaseScriptRecord(i + 1); if (ThisBsr.BaseScriptTag >= NextBsr.BaseScriptTag) { v.Error(T.T_NULL, E.BASE_E_BaseScriptList_Order, table.m_tag, sIdentity); bOrderOk = false; bRet = false; break; } } } if (bOrderOk) { v.Pass(T.T_NULL, P.BASE_P_BaseScriptList_Order, table.m_tag, sIdentity); } bool bOffsetsOk = true; for (uint i = 0; i < BaseScriptCount; i++) { BaseScriptRecord bsr = GetBaseScriptRecord(i); if (bsr.BaseScriptOffset + m_offsetBaseScriptListTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_BaseScriptList_Offset, table.m_tag, sIdentity + ", index = " + i); bOffsetsOk = false; bRet = false; } } if (bOffsetsOk) { v.Pass(T.T_NULL, P.BASE_P_BaseScriptList_Offset, table.m_tag, sIdentity); } for (uint i = 0; i < BaseScriptCount; i++) { BaseScriptRecord bsr = GetBaseScriptRecord(i); BaseScriptTable_val bst = GetBaseScriptTable_val(bsr); bst.Validate(v, sIdentity + ", BaseScriptRecord[" + i + "](" + bsr.BaseScriptTag + ")", table); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; if (m_offsetClassDefFormat1 + (uint)FieldOffsets.ClassValueArray + GlyphCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ClassDefinitionTable_E_GlyphArrayPastEOT, table.m_tag, sIdentity); bRet = false; } return(bRet); }
public new OTTable GetTable(OTTag tag) { OTTable table = null; // find the directory entry in this font that matches the tag DirectoryEntry de = GetDirectoryEntry(tag); if (de != null) { // get the table from the table manager table = GetFile().GetTableManager().GetTable(this, de); } return(table); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseTagListTable, CalcLength(), v, sIdentity, table.GetTag()); bool bTagsValid = true; for (uint i = 0; i < BaseTagCount; i++) { OTTag BaselineTag = GetBaselineTag(i); if (!BaselineTag.IsValid()) { v.Error(T.T_NULL, E.BASE_E_BaseTagList_TagValid, table.m_tag, sIdentity + ", tag = 0x" + ((uint)BaselineTag).ToString("x8")); bTagsValid = false; bRet = false; } } if (bTagsValid) { v.Pass(T.T_NULL, P.BASE_P_BaseTagList_TagValid, table.m_tag, sIdentity); } bool bOrderOk = true; if (BaseTagCount > 1) { for (uint i = 0; i < BaseTagCount - 1; i++) { OTTag ThisTag = GetBaselineTag(i); OTTag NextTag = GetBaselineTag(i + 1); if (ThisTag >= NextTag) { v.Error(T.T_NULL, E.BASE_E_BaseTagList_TagOrder, table.m_tag, sIdentity); bOrderOk = false; bRet = false; break; } } } if (bOrderOk) { v.Pass(T.T_NULL, P.BASE_P_BaseTagList_TagOrder, table.m_tag, sIdentity); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bool bLookupListOk = true; // check that the Lookup array doesn't extend past end of table if (m_offsetLookupListTable + (uint)FieldOffsets.LookupArray + LookupCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_LookupListTable_E_LookupArray_pastEOT, table.m_tag, sIdentity); bLookupListOk = false; bRet = false; } // check that each offset is within the table for (uint i = 0; i < LookupCount; i++) { if (m_offsetLookupListTable + GetLookupOffset(i) > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_LookupListTable_E_Lookup_offset, table.m_tag, sIdentity + ", Lookup[" + i + "]"); bLookupListOk = false; bRet = false; } } // validate each lookup table for (uint i = 0; i < LookupCount; i++) { LookupTable_val lt = GetLookupTable_val(i); if (lt != null) { bRet &= lt.Validate(v, sIdentity + ", Lookup[" + i + "]", table); } else { bLookupListOk = false; bRet = false; } } if (bLookupListOk) { v.Pass(T.T_NULL, P._OTL_LookupListTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseCoordTable, CalcLength(), v, sIdentity, table.GetTag()); if (BaseCoordFormat == 1 || BaseCoordFormat == 2 || BaseCoordFormat == 3) { v.Pass(T.T_NULL, P.BASE_P_BaseCoordTable_format, table.m_tag, sIdentity); } else { v.Error(T.T_NULL, E.BASE_E_BaseCoordTable_format, table.m_tag, sIdentity + ", format = " + BaseCoordFormat); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetAxisTable, CalcLength(), v, sIdentity, table.GetTag()); if (BaseTagListOffset == 0) { v.Pass(T.T_NULL, P.BASE_P_AxisTable_BaseTagListOffset_null, table.m_tag, sIdentity); } else if (BaseTagListOffset + m_offsetAxisTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_AxisTable_BaseTagListOffset, table.m_tag, sIdentity); bRet = false; } else { v.Pass(T.T_NULL, P.BASE_P_AxisTable_BaseTagListOffset_valid, table.m_tag, sIdentity); BaseTagListTable_val btlt = GetBaseTagListTable_val(); btlt.Validate(v, sIdentity, table); } if (BaseScriptListOffset == 0) { v.Error(T.T_NULL, E.BASE_E_AxisTable_BaseScriptListOffset_null, table.m_tag, sIdentity); bRet = false; } else if (BaseScriptListOffset + m_offsetAxisTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_AxisTable_BaseScriptListOffset, table.m_tag, sIdentity); bRet = false; } else { v.Pass(T.T_NULL, P.BASE_P_AxisTable_BaseScriptListOffset_valid, table.m_tag, sIdentity); BaseScriptListTable_val bslt = GetBaseScriptListTable_val(); bslt.Validate(v, sIdentity, table); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check that ClassRangeRecord array doesn't extend past end of table if (m_offsetClassDefFormat2 + (uint)FieldOffsets.ClassRangeRecordArray + ClassRangeCount * 6 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ClassDefinitionTable_E_RangeRecordArrayPastEOT, table.m_tag, sIdentity); bRet = false; } // check that ClassRangeRecord array is in sorted order if (ClassRangeCount > 1) { for (uint i = 0; i < ClassRangeCount - 1; i++) { ClassRangeRecord ThisCrr = GetClassRangeRecord(i); ClassRangeRecord NextCrr = GetClassRangeRecord(i + 1); if (ThisCrr.Start >= NextCrr.Start) { v.Error(T.T_NULL, E._OTL_ClassDefinitionTable_E_RangeRecordArray_order, table.m_tag, sIdentity); bRet = false; // temporary debug code /* * v.DebugMsg("ClassRangeCount = " + ClassRangeCount, tag); * for (uint j=0; j<ClassRangeCount; j++) * { * ClassRangeRecord crr = GetClassRangeRecord(j); * v.DebugMsg("ClassRangeRecord[" + j + "].Start = " + crr.Start, tag); * } */ break; } } } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_GDEF)table).ValidateNoOverlap(m_offsetLigGlyphTable, CalcLength(), v, sIdentity, table.GetTag()); if (m_offsetLigGlyphTable + (uint)FieldOffsets.CaretValueOffsets + CaretCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.GDEF_E_LigGlyphTable_CaretValueArray_PastEOT, table.m_tag, sIdentity); bRet = false; } bool bOffsetsOk = true; for (uint i = 0; i < CaretCount; i++) { if (m_offsetLigGlyphTable + GetCaretValueOffset(i) > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.GDEF_E_LigGlyphTable_CaretValueOffset, table.m_tag, sIdentity); bOffsetsOk = false; bRet = false; } } if (bOffsetsOk) { v.Pass(T.T_NULL, P.GDEF_P_LigGlyphTable_CaretValueArray, table.m_tag, sIdentity); } for (uint i = 0; i < CaretCount; i++) { CaretValueTable cvt = GetCaretValueTable(i); if (cvt.CaretValueFormat < 1 || cvt.CaretValueFormat > 3) { v.Error(T.T_NULL, E.GDEF_E_CaretValueTable_Format, table.m_tag, sIdentity + ", CaretValue[" + i + "], format = " + cvt.CaretValueFormat); bRet = false; } } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseValuesTable, CalcLength(), v, sIdentity, table.GetTag()); // check BaseCoord offsets bool bOffsetsOk = true; for (uint i = 0; i < BaseCoordCount; i++) { ushort bco = GetBaseCoordOffset(i); if (bco == 0) { v.Error(T.T_NULL, E.BASE_E_BaseValuesTable_BCO_0, table.m_tag, sIdentity + ", BaseCoordOffset index = " + i); bOffsetsOk = false; bRet = false; } else if (bco + m_offsetBaseValuesTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_BaseValuesTable_BCO_invalid, table.m_tag, sIdentity + ", BaseCoordOffset index = " + i); bOffsetsOk = false; bRet = false; } } if (bOffsetsOk) { v.Pass(T.T_NULL, P.BASE_P_BaseValuesTable_BCO, table.m_tag, sIdentity); } // check the BaseCoord tables for (uint i = 0; i < BaseCoordCount; i++) { BaseCoordTable_val bct = GetBaseCoordTable_val(i); bct.Validate(v, sIdentity, table); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; if (sIdentity.EndsWith("(size), FeatureTable") || sIdentity.Contains("(cv") || sIdentity.Contains("(ss0") || // avoid matching "ssty" sIdentity.Contains("(ss1") || sIdentity.Contains("(ss2")) { // The "size", "cvNN" and "ssNN" features are special in having non-null FeatureParams // TODO } else { // check that FeatureParams is null if (FeatureParams != 0) { v.Error(T.T_NULL, E._OTL_FeatureTable_E_FeatureParams_nonnull, table.m_tag, sIdentity); bRet = false; } } // check LookupListIndex array length if (m_offsetFeatureTable + (uint)FieldOffsets.LookupListIndexArray + LookupCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_FeatureTable_E_LookupListIndexArray_pastEOT, table.m_tag, sIdentity); bRet = false; } if (bRet) { v.Pass(T.T_NULL, P._OTL_FeatureTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; if (LookupOrder != 0) { v.Error(T.T_NULL, E._OTL_LangSysTable_E_LookupOrder, table.m_tag, sIdentity); bRet = false; } if (m_offsetLangSysTable + (uint)FieldOffsets.FeatureIndexArray + FeatureCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_LangSysTable_E_FeatureIndexArray_pastEOT, table.m_tag, sIdentity); bRet = false; } if (bRet) { v.Pass(T.T_NULL, P._OTL_LangSysTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseScriptTable, CalcLength(), v, sIdentity, table.GetTag()); // check the BaseValuesOffset if (BaseValuesOffset == 0) { v.Pass(T.T_NULL, P.BASE_P_BaseValuesOffset_null, table.m_tag, sIdentity); } else if (BaseValuesOffset + m_offsetBaseScriptTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_BaseValuesOffset, table.m_tag, sIdentity); } else { v.Pass(T.T_NULL, P.BASE_P_BaseValuesOffset, table.m_tag, sIdentity); } // check the DefaultMinMaxOffset if (DefaultMinMaxOffset == 0) { v.Pass(T.T_NULL, P.BASE_P_DefaultMinMaxOffset_null, table.m_tag, sIdentity); } else if (DefaultMinMaxOffset + m_offsetBaseScriptTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_DefaultMinMaxOffset, table.m_tag, sIdentity); } else { v.Pass(T.T_NULL, P.BASE_P_DefaultMinMaxOffset, table.m_tag, sIdentity); } // check the BaseLangSysRecord order bool bOrderOk = true; if (BaseLangSysCount > 1) { for (uint i = 0; i < BaseLangSysCount - 1; i++) { BaseLangSysRecord ThisBlsr = GetBaseLangSysRecord(i); BaseLangSysRecord NextBlsr = GetBaseLangSysRecord(i + 1); if (ThisBlsr.BaseLangSysTag >= NextBlsr.BaseLangSysTag) { v.Error(T.T_NULL, E.BASE_E_BaseLangSysRecord_order, table.m_tag, sIdentity); bOrderOk = false; bRet = false; } } } if (bOrderOk) { v.Pass(T.T_NULL, P.BASE_P_BaseLangSysRecord_order, table.m_tag, sIdentity); } // check the BaseLangSysRecord MinMaxOffsets bool bOffsetsOk = true; for (uint i = 0; i < BaseLangSysCount; i++) { BaseLangSysRecord bslr = GetBaseLangSysRecord(i); if (bslr.MinMaxOffset == 0) { v.Error(T.T_NULL, E.BASE_E_BaseLangSysRecord_offset0, table.m_tag, sIdentity + ", BaseLangSysRecord index = " + i); bOffsetsOk = false; bRet = false; } else if (bslr.MinMaxOffset + m_offsetBaseScriptTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_BaseLangSysRecord_offset, table.m_tag, sIdentity + ", BaseLangSysRecord index = " + i); bOffsetsOk = false; bRet = false; } } if (bOffsetsOk) { v.Pass(T.T_NULL, P.BASE_P_BaseLangSysRecord_offsets, table.m_tag, sIdentity); } // check the BaseValuesTable if (BaseValuesOffset != 0) { BaseValuesTable_val bvt = GetBaseValuesTable_val(); bvt.Validate(v, sIdentity, table); } // check the Default MinMaxTable if (DefaultMinMaxOffset != 0) { MinMaxTable_val mmt = GetDefaultMinMaxTable_val(); mmt.Validate(v, sIdentity + ", default MinMax", table); } // check the BaseLangSysRecord MinMaxTables for (uint i = 0; i < BaseLangSysCount; i++) { BaseLangSysRecord blsr = GetBaseLangSysRecord(i); MinMaxTable_val mmt = GetMinMaxTable_val(blsr); mmt.Validate(v, sIdentity + ", BaseLangSysRecord[" + i + "]", table); } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; // check the LookupType if (((string)table.m_tag == "GPOS") && LookupType > 9 || ((string)table.m_tag == "GSUB" && LookupType > 8)) { v.Error(T.T_NULL, E._OTL_LookupTable_E_LookupType, table.m_tag, sIdentity + ", LookupType = " + LookupType); bRet = false; } // check LookupFlag reserved bits are clear if ((LookupFlag & 0x00f0) != 0) { v.Error(T.T_NULL, E._OTL_LookupTable_E_LookupFlag_reserved, table.m_tag, sIdentity); bRet = false; } // check Subtable offset array doesn't extend past end of table if (m_offsetLookupTable + (uint)FieldOffsets.SubTableOffsetArray + SubTableCount * 2 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_LookupTable_E_SubtableArray_pastEOT, table.m_tag, sIdentity); bRet = false; } // check Subtable offsets don't point past end of table for (uint i = 0; i < SubTableCount; i++) { // verify that the subtable offset is accessible, if not error was already reported if (m_offsetLookupTable + (uint)FieldOffsets.SubTableOffsetArray + i * 2 + 2 <= m_bufTable.GetLength()) { if (m_offsetLookupTable + GetSubTableOffset(i) > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_LookupTable_E_SubtableArray_offset, table.m_tag, sIdentity + ", SubTable[" + i + "]"); bRet = false; } } } // way too many lookup tables to justify this pass message //if (bRet) //{ // v.Pass("_OTL_LookupTable_P_valid", table.m_tag, sIdentity); //} // validate each subtable for (uint i = 0; i < SubTableCount; i++) { // verify that the subtable offset is accessible, if not error was already reported if (m_offsetLookupTable + (uint)FieldOffsets.SubTableOffsetArray + i * 2 + 2 <= m_bufTable.GetLength()) { // verify subtable offset is valid if (m_offsetLookupTable + GetSubTableOffset(i) <= m_bufTable.GetLength()) { SubTable st = GetSubTable(i); if (st != null) { I_OTLValidate iv = (I_OTLValidate)st; bRet &= iv.Validate(v, sIdentity + ", SubTable[" + i + "]", table); } else { v.Warning(T.T_NULL, W._TEST_W_OtherErrorsInTable, table.m_tag, "unable to validate subtable: " + sIdentity + ", SubTable[" + i + "]"); } } else { v.Warning(T.T_NULL, W._TEST_W_OtherErrorsInTable, table.m_tag, "unable to validate subtable: " + sIdentity + ", SubTable[" + i + "]"); } } } return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bool bScriptTableOk = true; // check the DefaultLangSys offset if (DefaultLangSysOffset != 0) { if (m_offsetScriptTable + DefaultLangSysOffset > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ScriptTable_E_DefaultLangSysOffset, table.m_tag, sIdentity); bScriptTableOk = false; bRet = false; } else { // check the DefaultLangSys table LangSysTable_val lst = GetDefaultLangSysTable_val(); bRet &= lst.Validate(v, sIdentity + ", DefaultLangSysTable", table); } } // check the LansgSysRecord array length if (m_offsetScriptTable + (uint)FieldOffsets.LangSysRecord + LangSysCount * 6 > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecordArray_pastEOT, table.m_tag, sIdentity); bScriptTableOk = false; bRet = false; } // check that the LangSysRecord array is sorted alphabetically if (LangSysCount > 1) { for (uint i = 0; i < LangSysCount - 1; i++) { LangSysRecord ThisLsr = GetLangSysRecord(i); LangSysRecord NextLsr = GetLangSysRecord(i + 1); if (ThisLsr.LangSysTag >= NextLsr.LangSysTag) { v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecordArray_order, table.m_tag, sIdentity); bScriptTableOk = false; bRet = false; } } } // check each LangSysRecord for (uint i = 0; i < LangSysCount; i++) { LangSysRecord lsr = GetLangSysRecord(i); // check the tag if (!lsr.LangSysTag.IsValid()) { v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecord_tag, table.m_tag, sIdentity + ", LangSysRecord[" + i + "]"); bScriptTableOk = false; bRet = false; } // check the offset if (m_offsetScriptTable + lsr.LangSysOffset > m_bufTable.GetLength()) { v.Error(T.T_NULL, E._OTL_ScriptTable_E_LangSysRecord_offset, table.m_tag, sIdentity + ", LangSysRecord[" + i + "]"); bScriptTableOk = false; bRet = false; } // validate the langsys table LangSysTable_val lst = GetLangSysTable_val(lsr); bRet &= lst.Validate(v, sIdentity + ", LangSysRecord[" + i + "], LangSysTable", table); } if (bScriptTableOk) { v.Pass(T.T_NULL, P._OTL_ScriptTable_P_valid, table.m_tag, sIdentity); } return(bRet); }
/***************** * public methods */ public bool Validate() { bool bRet = true; int canrast; Validator v = GetFile().GetValidator(); if (v.PerformTest(T._OFFSET_sfntVersion)) { uint sfnt = m_OffsetTable.sfntVersion.GetUint(); if (!OTFile.IsValidSfntVersion(sfnt)) { v.Error(T._OFFSET_sfntVersion, E._OFFSET_E_InvalidSFNT, null, "0x" + sfnt.ToString("x8")); bRet = false; } } if (v.PerformTest(T._OFFSET_numTables)) { if (m_OffsetTable.numTables == 0) { v.Error(T._OFFSET_numTables, E._OFFSET_E_numTables, null); bRet = false; } else { v.Pass(T._OFFSET_numTables, P._OFFSET_P_numTables, null, m_OffsetTable.numTables.ToString()); } } if (v.PerformTest(T._OFFSET_BinarySearchFields)) { ushort numTables = m_OffsetTable.numTables; ushort CalculatedSearchRange = (ushort)(util.MaxPower2LE(numTables) * 16); ushort CalculatedEntrySelector = util.Log2(util.MaxPower2LE(numTables)); ushort CalculatedRangeShift = (ushort)(numTables * 16 - CalculatedSearchRange); bool bBinaryFieldsOk = true; if (m_OffsetTable.searchRange != CalculatedSearchRange) { v.Error(T._OFFSET_BinarySearchFields, E._OFFSET_E_searchRange, null, m_OffsetTable.searchRange.ToString()); bBinaryFieldsOk = false; bRet = false; } if (m_OffsetTable.entrySelector != CalculatedEntrySelector) { v.Error(T._OFFSET_BinarySearchFields, E._OFFSET_E_entrySelector, null, m_OffsetTable.entrySelector.ToString()); bBinaryFieldsOk = false; bRet = false; } if (m_OffsetTable.rangeShift != CalculatedRangeShift) { v.Error(T._OFFSET_BinarySearchFields, E._OFFSET_E_rangeShift, null, m_OffsetTable.rangeShift.ToString()); bBinaryFieldsOk = false; bRet = false; } if (bBinaryFieldsOk) { v.Pass(T._OFFSET_BinarySearchFields, P._OFFSET_P_BinarySearchTables, null); } } bRet &= CheckDirectoryEntriesNonZero(v); bRet &= CheckTablesInFileAndNotOverlapping(v); bRet &= CheckNoDuplicateTags(v); if (v.PerformTest(T._DE_TagsAscendingOrder)) { bRet &= CheckTagsAscending(v); } if (v.PerformTest(T._DE_TagNames)) { bRet &= CheckTagNames(v); } if (v.PerformTest(T._DE_TableAlignment)) { bRet &= CheckTableAlignment(v); } if (v.PerformTest(T._FONT_RequiredTables)) { bRet &= CheckForRequiredTables(v); } if (v.PerformTest(T._FONT_RecommendedTables)) { bRet &= CheckForRecommendedTables(v); } if (v.PerformTest(T._FONT_UnnecessaryTables)) { bRet &= CheckForNoUnnecessaryTables(v); } if (v.PerformTest(T._FONT_OptimalTableOrder)) { bRet &= CheckForOptimalTableOrder(v); } // Validate each table if (m_OffsetTable != null) { for (int i = 0; i < m_OffsetTable.DirectoryEntries.Count; i++) { // check to see if user canceled validation if (v.CancelFlag) { break; } // get the table DirectoryEntry de = (DirectoryEntry)m_OffsetTable.DirectoryEntries[i]; OTTable table = GetFile().GetTableManager().GetTable(this, de); // Will it really happen? if (GetFile().GetTableManager().GetUnaliasedTableName(de.tag) == "DSIG" && GetFile().IsCollection()) { continue; } if (GetFile().GetTableManager().GetUnaliasedTableName(de.tag) == "glyf" && Is_TTC_LaterIdenticalTable("glyf")) { v.Info(T.T_NULL, I.glyf_I_IDENTICAL_GLYF_TABLES_IN_TTC, de.tag, "glyf"); continue; } if (GetFile().GetTableManager().GetUnaliasedTableName(de.tag) == "EBDT" && Is_TTC_LaterIdenticalTable("EBDT")) { v.Info(T.T_NULL, I.glyf_I_IDENTICAL_GLYF_TABLES_IN_TTC, de.tag, "EBDT"); continue; } // Call the function that validates a single table bRet &= this.GetFile().ValidateTable(table, v, de, this); } } canrast = TestFontRasterization(); ushort numGlyphs = GetMaxpNumGlyphs(); // rasterization test - BW v.OnRastTestValidationEvent_BW(true); if (v.PeformRastTest_BW() && Is_TTC_LaterIdenticalTable("glyf")) { v.Info(T.T_NULL, I.glyf_I_IDENTICAL_GLYF_TABLES_IN_TTC, null, "B/W Rasterization"); } else if (v.PeformRastTest_BW()) { if (canrast > 0) { try { // fetch the rasterizer object and initialize it with this font RasterInterf ri = GetFile().GetRasterizer(); ri.RasterNewSfnt(GetFile().GetFileStream(), GetFontIndexInFile()); // call the rasterizer RasterInterf.UpdateProgressDelegate upg = new RasterInterf.UpdateProgressDelegate(v.OnTableProgress); RasterInterf.RastTestErrorDelegate rted = new RasterInterf.RastTestErrorDelegate(v.OnRastTestError); int x = v.GetRastTestXRes(); int y = v.GetRastTestYRes(); int [] pointsizes = v.GetRastTestPointSizes(); RastTestTransform rtt = v.GetRastTestTransform(); bRet &= ri.RastTest( x, y, pointsizes, rtt.stretchX, rtt.stretchY, rtt.rotation, rtt.skew, rtt.matrix, true, false, false, 0, rted, upg, numGlyphs); if (ri.GetRastErrorCount() == 0) { v.Pass(T.T_NULL, P._rast_P_rasterization, null); } } catch (Exception e) { v.ApplicationError(T.T_NULL, E._rast_A_ExceptionUnhandled, null, e.Message + e.StackTrace); } } else if (canrast == 0) { v.Info(T.T_NULL, I._rast_I_rasterization, null, GetDevMetricsDataError()); } else { v.Error(T.T_NULL, E._rast_E_rasterization, null, GetDevMetricsDataError()); bRet = false; } } else { v.Info(I._TEST_I_RastTestNotSelected, null); } v.OnRastTestValidationEvent_BW(false); // rasterization test - Grayscale v.OnRastTestValidationEvent_Grayscale(true); if (v.PeformRastTest_Grayscale() && Is_TTC_LaterIdenticalTable("glyf")) { v.Info(T.T_NULL, I.glyf_I_IDENTICAL_GLYF_TABLES_IN_TTC, null, "Grayscale Rasterization"); } else if (v.PeformRastTest_Grayscale()) { if (canrast > 0) { try { // fetch the rasterizer object and initialize it with this font RasterInterf ri = GetFile().GetRasterizer(); ri.RasterNewSfnt(GetFile().GetFileStream(), GetFontIndexInFile()); // call the rasterizer RasterInterf.UpdateProgressDelegate upg = new RasterInterf.UpdateProgressDelegate(v.OnTableProgress); RasterInterf.RastTestErrorDelegate rted = new RasterInterf.RastTestErrorDelegate(v.OnRastTestError); int x = v.GetRastTestXRes(); int y = v.GetRastTestYRes(); int [] pointsizes = v.GetRastTestPointSizes(); RastTestTransform rtt = v.GetRastTestTransform(); bRet &= ri.RastTest( x, y, pointsizes, rtt.stretchX, rtt.stretchY, rtt.rotation, rtt.skew, rtt.matrix, false, true, false, 0, rted, upg, numGlyphs); if (ri.GetRastErrorCount() == 0) { v.Pass(T.T_NULL, P._rast_P_rasterization, null); } } catch (Exception e) { v.ApplicationError(T.T_NULL, E._rast_A_ExceptionUnhandled, null, e.Message + e.StackTrace); } } else if (canrast == 0) { v.Info(T.T_NULL, I._rast_I_rasterization, null, GetDevMetricsDataError()); } else { v.Error(T.T_NULL, E._rast_E_rasterization, null, GetDevMetricsDataError()); bRet = false; } } else { v.Info(I._TEST_I_RastTestNotSelected, null); } v.OnRastTestValidationEvent_Grayscale(false); // rasterization test - Cleartype v.OnRastTestValidationEvent_Cleartype(true); if (v.PeformRastTest_Cleartype() && Is_TTC_LaterIdenticalTable("glyf")) { v.Info(T.T_NULL, I.glyf_I_IDENTICAL_GLYF_TABLES_IN_TTC, null, "Cleartype Rasterization"); } else if (v.PeformRastTest_Cleartype()) { if (canrast > 0) { try { uint CTFlags = v.GetCleartypeFlags(); // fetch the rasterizer object and initialize it with this font RasterInterf ri = GetFile().GetRasterizer(); ri.RasterNewSfnt(GetFile().GetFileStream(), GetFontIndexInFile()); // call the rasterizer RasterInterf.UpdateProgressDelegate upg = new RasterInterf.UpdateProgressDelegate(v.OnTableProgress); RasterInterf.RastTestErrorDelegate rted = new RasterInterf.RastTestErrorDelegate(v.OnRastTestError); int x = v.GetRastTestXRes(); int y = v.GetRastTestYRes(); int [] pointsizes = v.GetRastTestPointSizes(); RastTestTransform rtt = v.GetRastTestTransform(); bRet &= ri.RastTest( x, y, pointsizes, rtt.stretchX, rtt.stretchY, rtt.rotation, rtt.skew, rtt.matrix, false, false, true, CTFlags, rted, upg, numGlyphs); if (ri.GetRastErrorCount() == 0) { v.Pass(T.T_NULL, P._rast_P_rasterization, null); } } catch (Exception e) { v.ApplicationError(T.T_NULL, E._rast_A_ExceptionUnhandled, null, e.Message + e.StackTrace); } } else if (canrast == 0) { v.Info(T.T_NULL, I._rast_I_rasterization, null, GetDevMetricsDataError()); } else { v.Error(T.T_NULL, E._rast_E_rasterization, null, GetDevMetricsDataError()); bRet = false; } } else { v.Info(I._TEST_I_RastTestNotSelected, null); } v.OnRastTestValidationEvent_Cleartype(false); return(bRet); }
public bool Validate(Validator v, string sIdentity, OTTable table) { bool bRet = true; bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetMinMaxTable, CalcLength(), v, sIdentity, table.GetTag()); // check the MinCoordOffset if (MinCoordOffset == 0) { v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MinCO_0, table.m_tag, sIdentity); } else if (MinCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_MinMaxTable_MinCO, table.m_tag, sIdentity); bRet = false; } else { v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MinCO, table.m_tag, sIdentity); } // check the MaxCoordOffset if (MaxCoordOffset == 0) { v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MaxCO_0, table.m_tag, sIdentity); } else if (MaxCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_MinMaxTable_MaxCO, table.m_tag, sIdentity); bRet = false; } else { v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MaxCO, table.m_tag, sIdentity); } // check the FeatMinMaxRecords bool bFeatMinMaxRecordsOk = true; for (uint i = 0; i < FeatMinMaxCount; i++) { FeatMinMaxRecord fmmr = GetFeatMinMaxRecord(i); if (fmmr != null) { if (fmmr.MinCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_FeatMinMaxRecords_MinCO_offset, table.m_tag, sIdentity + ", FeatMinMaxRecord[" + i + "]"); bFeatMinMaxRecordsOk = false; bRet = false; } if (fmmr.MaxCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength()) { v.Error(T.T_NULL, E.BASE_E_FeatMinMaxRecords_MaxCO_offset, table.m_tag, sIdentity + ", FeatMinMaxRecord[" + i + "]"); bFeatMinMaxRecordsOk = false; bRet = false; } } else { bFeatMinMaxRecordsOk = false; } } if (bFeatMinMaxRecordsOk) { v.Pass(T.T_NULL, P.BASE_P_FeatMinMaxRecords_offsets, table.m_tag, sIdentity); } // check the BaseCoord Tables BaseCoordTable_val bct = null; bct = GetMinCoordTable_val(); if (bct != null) { bct.Validate(v, sIdentity, table); } bct = GetMaxCoordTable_val(); if (bct != null) { bct.Validate(v, sIdentity, table); } for (uint i = 0; i < FeatMinMaxCount; i++) { FeatMinMaxRecord fmmr = GetFeatMinMaxRecord(i); bct = GetFeatMinCoordTable_val(fmmr); if (bct != null) { bct.Validate(v, sIdentity, table); } bct = GetFeatMaxCoordTable_val(fmmr); if (bct != null) { bct.Validate(v, sIdentity, table); } } return(bRet); }
/************************ * public methods */ public override OTTable CreateTableObject(OTTag tag, MBOBuffer buf) { OTTable table = null; string sName = GetUnaliasedTableName(tag); switch (sName) { case "BASE": table = new val_BASE(tag, buf); break; case "CFF ": table = new val_CFF(tag, buf); break; case "cmap": table = new val_cmap(tag, buf); break; case "cvt ": table = new val_cvt(tag, buf); break; case "DSIG": table = new val_DSIG(tag, buf); break; case "EBDT": table = new val_EBDT(tag, buf); break; case "EBLC": table = new val_EBLC(tag, buf); break; case "EBSC": table = new val_EBSC(tag, buf); break; case "fpgm": table = new val_fpgm(tag, buf); break; case "gasp": table = new val_gasp(tag, buf); break; case "GDEF": table = new val_GDEF(tag, buf); break; case "glyf": table = new val_glyf(tag, buf); break; case "GPOS": table = new val_GPOS(tag, buf); break; case "GSUB": table = new val_GSUB(tag, buf); break; case "hdmx": table = new val_hdmx(tag, buf); break; case "head": table = new val_head(tag, buf); break; case "hhea": table = new val_hhea(tag, buf); break; case "hmtx": table = new val_hmtx(tag, buf); break; case "JSTF": table = new val_JSTF(tag, buf); break; case "kern": table = new val_kern(tag, buf); break; case "loca": table = new val_loca(tag, buf); break; case "LTSH": table = new val_LTSH(tag, buf); break; case "maxp": table = new val_maxp(tag, buf); break; case "name": table = new val_name(tag, buf); break; case "OS/2": table = new val_OS2(tag, buf); break; case "PCLT": table = new val_PCLT(tag, buf); break; case "post": table = new val_post(tag, buf); break; case "prep": table = new val_prep(tag, buf); break; case "VDMX": table = new val_VDMX(tag, buf); break; case "vhea": table = new val_vhea(tag, buf); break; case "vmtx": table = new val_vmtx(tag, buf); break; case "VORG": table = new val_VORG(tag, buf); break; //case "Zapf": table = new val_Zapf(tag, buf); break; default: table = new val__Unknown(tag, buf); break; } return(table); }
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); }