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); }
public indexSubTable GetIndexSubTable(indexSubTableArray ista) { indexSubTable ist = null; uint offset = indexSubTableArrayOffset + ista.additionalOffsetToIndexSubtable; if (offset + (uint)indexSubHeader.FieldOffsets.indexFormat + 2 <= m_bufTable.GetLength()) { ushort indexFormat = m_bufTable.GetUshort(offset + (uint)indexSubHeader.FieldOffsets.indexFormat); switch(indexFormat) { case 1: { indexSubTable1 ist1 = new indexSubTable1(offset, m_bufTable, ista); ist = ist1; break; } case 2: { indexSubTable2 ist2 = new indexSubTable2(offset, m_bufTable, ista); ist = ist2; ist2.bigMetrics = new Table_EBDT.bigGlyphMetrics(); ist2.imageSize = m_bufTable.GetUint(offset + indexSubTable.headerLength); ist2.bigMetrics.height = m_bufTable.GetByte (offset + indexSubTable.headerLength + 4); ist2.bigMetrics.width = m_bufTable.GetByte (offset + indexSubTable.headerLength + 5); ist2.bigMetrics.horiBearingX = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 6); ist2.bigMetrics.horiBearingY = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 7); ist2.bigMetrics.horiAdvance = m_bufTable.GetByte (offset + indexSubTable.headerLength + 8); ist2.bigMetrics.vertBearingX = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 9); ist2.bigMetrics.vertBearingY = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 10); ist2.bigMetrics.vertAdvance = m_bufTable.GetByte (offset + indexSubTable.headerLength + 11); break; } case 3: { indexSubTable3 ist3 = new indexSubTable3(offset, m_bufTable, ista); ist = ist3; break; } case 4: { indexSubTable4 ist4 = new indexSubTable4(offset, m_bufTable, ista); ist = ist4; ist4.numGlyphs = m_bufTable.GetUint(offset + indexSubTable.headerLength); break; } case 5: { indexSubTable5 ist5 = new indexSubTable5(offset, m_bufTable, ista); ist = ist5; ist5.bigMetrics = new Table_EBDT.bigGlyphMetrics(); ist5.imageSize = m_bufTable.GetUint(offset + indexSubTable.headerLength); ist5.bigMetrics.height = m_bufTable.GetByte (offset + indexSubTable.headerLength + 4); ist5.bigMetrics.width = m_bufTable.GetByte (offset + indexSubTable.headerLength + 5); ist5.bigMetrics.horiBearingX = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 6); ist5.bigMetrics.horiBearingY = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 7); ist5.bigMetrics.horiAdvance = m_bufTable.GetByte (offset + indexSubTable.headerLength + 8); ist5.bigMetrics.vertBearingX = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 9); ist5.bigMetrics.vertBearingY = m_bufTable.GetSbyte(offset + indexSubTable.headerLength + 10); ist5.bigMetrics.vertAdvance = m_bufTable.GetByte (offset + indexSubTable.headerLength + 11); ist5.numGlyphs = m_bufTable.GetUint(offset + indexSubTable.headerLength + 12); break; } } } return ist; }
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; }