bool Validate_indexSubHeader(Validator v, indexSubHeader iSH, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); if (iSH.indexFormat < 1 || iSH.indexFormat > 5) { string sDetails = "invalid indexFormat: " + sID + ", indexFormat = " + iSH.indexFormat; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } if (iSH.imageFormat < 1 || iSH.imageFormat > 9 || iSH.imageFormat == 3) { string sDetails = "invalid imageFormat: " + sID + ", imageFormat = " + iSH.imageFormat; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } bool bInconsistentFormats = false; if (iSH.indexFormat == 1 || iSH.indexFormat == 3 || iSH.indexFormat == 4) { if (iSH.imageFormat == 5) { bInconsistentFormats = true; } } else { if (iSH.imageFormat != 5) { bInconsistentFormats = true; } } if (bInconsistentFormats) { string sDetails = "inconsistent formats: " + sID + ", indexFormat = " + iSH.indexFormat + ", imageFormat = " + iSH.imageFormat; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } if (EBDTTable != null) { if (iSH.imageDataOffset > EBDTTable.GetLength()) { string sDetails = "invalid imageDataOffset: " + sID + ", imageDataOffset = " + iSH.imageDataOffset; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } } return(bOk); }
bool Validate_indexSubTable_format4(Validator v, indexSubTable4 ist4, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate numGlyphs uint nGlyphsInRange = (uint)ista.lastGlyphIndex - ista.firstGlyphIndex + 1; if (ist4.numGlyphs > nGlyphsInRange) { string sDetails = "numGlyphs is invalid: " + sID + ", numGlyphs = " + ist4.numGlyphs + ", indexSubTableArray.firstGlyphIndex = " + ista.firstGlyphIndex + ", indexSubTableArray.lastGlyphIndex = " + ista.lastGlyphIndex; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate code offset pairs uint nEBDTLength = EBDTTable.GetLength(); for (ushort idGlyph = 0; idGlyph < ist4.numGlyphs; idGlyph++) { indexSubTable4.codeOffsetPair cop = ist4.GetCodeOffsetPair(idGlyph); // glyph code if (cop.glyphCode < ista.firstGlyphIndex || cop.glyphCode > ista.lastGlyphIndex) { string sDetails = "glyph code is invalid: " + sID + ", codeOffsetPair[" + idGlyph + "]" + ", indexSubTableArray.firstGlyphIndex = " + ista.firstGlyphIndex + ", indexSubTableArray.lastGlyphIndex = " + ista.lastGlyphIndex; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // offset if (cop.offset > nEBDTLength) { string sDetails = "invalid offset: " + sID + ", codeOffsetPair[" + idGlyph + "].offset = " + cop.offset + ", EBDT length = " + nEBDTLength; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } } return(bOk); }