bool Validate_indexSubTable_format2(Validator v, indexSubTable2 ist2, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate the image size uint nGlyphsInRange = (uint)ista.lastGlyphIndex - ista.firstGlyphIndex + 1; if (nGlyphsInRange * ist2.imageSize > EBDTTable.GetLength()) { string sDetails = "images extend past end of EBDT table: " + sID + ", imageSize = " + ist2.imageSize + ", EBDT length = " + EBDTTable.GetLength(); v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate the bigGlyphMetrics val_EBDT.bigGlyphMetrics_val bgm = val_EBDT.bigGlyphMetrics_val.CreateFromBigGlyphMetrics(ist2.bigMetrics); bgm.Validate(v, sID, this); return(bOk); }
bool Validate_indexSubTable_format3(Validator v, indexSubTable3 ist3, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate the array of offsets int nArrSize = ista.lastGlyphIndex - ista.firstGlyphIndex + 1; uint nEBDTLength = EBDTTable.GetLength(); for (ushort i = 0; i < nArrSize; i++) { uint offsetImage = ist3.GetOffset(i) + ist3.header.imageDataOffset; if (offsetImage > nEBDTLength) { string sDetails = "invalid offset: " + sID + ", offset[" + i + "] = " + offsetImage + ", EBDT length = " + nEBDTLength; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } } return(bOk); }
bool Validate_indexSubTable_format5(Validator v, indexSubTable5 ist5, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate the image size if (ist5.numGlyphs * ist5.imageSize > EBDTTable.GetLength()) { string sDetails = "images extend past end of EBDT table: " + sID + ", imageSize = " + ist5.imageSize + ", EBDT length = " + EBDTTable.GetLength(); v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate the bigGlyphMetrics val_EBDT.bigGlyphMetrics_val bgm = val_EBDT.bigGlyphMetrics_val.CreateFromBigGlyphMetrics(ist5.bigMetrics); bgm.Validate(v, sID, this); // validate numGlyphs uint nGlyphsInRange = (uint)ista.lastGlyphIndex - ista.firstGlyphIndex + 1; if (ist5.numGlyphs > nGlyphsInRange) { string sDetails = "numGlyphs is invalid: " + sID + ", numGlyphs = " + ist5.numGlyphs + ", indexSubTableArray.firstGlyphIndex = " + ista.firstGlyphIndex + ", indexSubTableArray.lastGlyphIndex = " + ista.lastGlyphIndex; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate glyphCodeArray for (ushort i = 0; i < ist5.numGlyphs; i++) { ushort idGlyph = ist5.GetGlyphCode(i); if (idGlyph < ista.firstGlyphIndex || idGlyph > ista.lastGlyphIndex) { string sDetails = "invalid glyph id: " + sID + ", glyphCodeArray[" + i + "] = " + idGlyph + ", indexSubTableArray.firstGlyphIndex = " + ista.firstGlyphIndex + ", indexSubTableArray.lastGlyphIndex = " + ista.lastGlyphIndex; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } } return(bOk); }
bool Validate_indexSubTable(Validator v, indexSubTable ist, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; if (!Validate_indexSubHeader(v, ist.header, sID, fontOwner)) { bOk = false; } switch (ist.header.indexFormat) { case 1: if (!Validate_indexSubTable_format1(v, (indexSubTable1)ist, ista, sID, fontOwner)) { bOk = false; } break; case 2: if (!Validate_indexSubTable_format2(v, (indexSubTable2)ist, ista, sID, fontOwner)) { bOk = false; } break; case 3: if (!Validate_indexSubTable_format3(v, (indexSubTable3)ist, ista, sID, fontOwner)) { bOk = false; } break; case 4: if (!Validate_indexSubTable_format4(v, (indexSubTable4)ist, ista, sID, fontOwner)) { bOk = false; } break; case 5: if (!Validate_indexSubTable_format5(v, (indexSubTable5)ist, ista, sID, fontOwner)) { bOk = false; } break; default: Debug.Assert(false, "illegal index format", "format = " + ist.header.indexFormat); break; } if (bOk) { v.Pass(T.EBLC_indexSubTables, P.EBLC_P_indexSubTables, m_tag, sID); } 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); }
public indexSubTableArray[] GetIndexSubTableArray(bitmapSizeTable bst) { indexSubTableArray[] ista = null; if (bst.indexSubTableArrayOffset < m_bufTable.GetLength()) { ista = new indexSubTableArray[bst.numberOfIndexSubTables]; for (uint i=0; i<bst.numberOfIndexSubTables; i++) { ista[i] = GetIndexSubTableArray(bst, i); } } return ista; }
public indexSubTableArray GetIndexSubTableArray(bitmapSizeTable bst, uint i) { indexSubTableArray ista = null; if (bst.indexSubTableArrayOffset < m_bufTable.GetLength()) { uint istaOffset = bst.indexSubTableArrayOffset + i*8; if (istaOffset + indexSubTableArray.bufSize <= m_bufTable.GetLength()) { ista = new indexSubTableArray(istaOffset, m_bufTable); } } return ista; }
public indexSubTable5(uint indexSubTableOffset, MBOBuffer EBLCTableBuf, indexSubTableArray ista) : base(indexSubTableOffset, EBLCTableBuf, ista) { }
bool Validate_indexSubTable_format2(Validator v, indexSubTable2 ist2, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate the image size uint nGlyphsInRange = (uint)ista.lastGlyphIndex - ista.firstGlyphIndex + 1; if (nGlyphsInRange*ist2.imageSize > EBDTTable.GetLength()) { string sDetails = "images extend past end of EBDT table: " + sID + ", imageSize = " + ist2.imageSize + ", EBDT length = " + EBDTTable.GetLength(); v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate the bigGlyphMetrics val_EBDT.bigGlyphMetrics_val bgm = val_EBDT.bigGlyphMetrics_val.CreateFromBigGlyphMetrics(ist2.bigMetrics); bgm.Validate(v, sID, this); 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; }
private indexSubTableCache getEBLCIndexSubTable( Table_EBLC OwnerTable, bitmapSizeTable bst, indexSubTableArray ista ) { indexSubTable ist = bst.GetIndexSubTable(ista); Table_EBDT tableEDBT = OwnerTable.getTableEDBT(); indexSubTableCache istc = null; switch( ist.header.indexFormat ) { case 1: { ArrayList cImageCache = new ArrayList(); for( uint i = ista.firstGlyphIndex; i <= ista.lastGlyphIndex; i++ ) { cImageCache.Add( getEBDTImageFormat( tableEDBT, ist, i, ista.firstGlyphIndex )); } istc = new indexSubTableCache1( ist.header.indexFormat, ist.header.imageFormat, cImageCache ); break; } case 2: { ArrayList cImageCache = new ArrayList(); for( uint i = ista.firstGlyphIndex; i <= ista.lastGlyphIndex; i++ ) { cImageCache.Add( getEBDTImageFormat( tableEDBT, ist, i, ista.firstGlyphIndex )); } uint nImageSize = ((indexSubTable2)ist).imageSize; Table_EBDT.bigGlyphMetrics bgm = ((indexSubTable2)ist).bigMetrics; istc = new indexSubTableCache2( ist.header.indexFormat, ist.header.imageFormat, cImageCache, nImageSize, bgm ); break; } case 3: { ArrayList cImageCache = new ArrayList(); for( uint i = ista.firstGlyphIndex; i <= ista.lastGlyphIndex; i++ ) { cImageCache.Add( getEBDTImageFormat( tableEDBT, ist, i, ista.firstGlyphIndex )); } istc = new indexSubTableCache3( ist.header.indexFormat, ist.header.imageFormat, cImageCache ); break; } case 4: { ArrayList cImageCache = new ArrayList(); ArrayList cGlyphCodes = new ArrayList(); for( uint i = 0; i < ((indexSubTable4)ist).numGlyphs; i++ ) { ushort nGlyphCode = ((indexSubTable4)ist).GetCodeOffsetPair( i ).glyphCode; cGlyphCodes.Add( nGlyphCode ); cImageCache.Add( getEBDTImageFormat( tableEDBT, ist, nGlyphCode, ista.firstGlyphIndex )); } istc = new indexSubTableCache4( ist.header.indexFormat, ist.header.imageFormat, cImageCache, cGlyphCodes ); break; } case 5: { ArrayList cImageCache = new ArrayList(); uint nImageSize = ((indexSubTable5)ist).imageSize; Table_EBDT.bigGlyphMetrics bgm = ((indexSubTable5)ist).bigMetrics; ArrayList cGlyphCodes = new ArrayList(); for( uint i = 0; i < ((indexSubTable5)ist).numGlyphs; i++ ) { ushort nGlyphCode = ((indexSubTable5)ist).GetGlyphCode( i ); cGlyphCodes.Add( nGlyphCode ); cImageCache.Add( getEBDTImageFormat( tableEDBT, ist, nGlyphCode, ista.firstGlyphIndex )); } istc = new indexSubTableCache5( ist.header.indexFormat, ist.header.imageFormat, cImageCache, nImageSize, bgm, cGlyphCodes ); break; } default: { Debug.Assert( false, "unsupported index format" ); break; } } return istc; }
// methods public indexSubTableArray FindIndexSubTableArray(ushort idGlyph) { indexSubTableArray ista = null; for (uint i=0; i<numberOfIndexSubTables; i++) { if (indexSubTableArrayOffset < m_bufTable.GetLength()) { uint istaOffset = indexSubTableArrayOffset + i*8; ista = new indexSubTableArray(istaOffset, m_bufTable); if (idGlyph >= ista.firstGlyphIndex && idGlyph <= ista.lastGlyphIndex) { break; } else { ista = null; } } } return ista; }
bool Validate_indexSubTable_format5(Validator v, indexSubTable5 ist5, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate the image size if (ist5.numGlyphs*ist5.imageSize > EBDTTable.GetLength()) { string sDetails = "images extend past end of EBDT table: " + sID + ", imageSize = " + ist5.imageSize + ", EBDT length = " + EBDTTable.GetLength(); v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate the bigGlyphMetrics val_EBDT.bigGlyphMetrics_val bgm = val_EBDT.bigGlyphMetrics_val.CreateFromBigGlyphMetrics(ist5.bigMetrics); bgm.Validate(v, sID, this); // validate numGlyphs uint nGlyphsInRange = (uint)ista.lastGlyphIndex - ista.firstGlyphIndex + 1; if (ist5.numGlyphs > nGlyphsInRange) { string sDetails = "numGlyphs is invalid: " + sID + ", numGlyphs = " + ist5.numGlyphs + ", indexSubTableArray.firstGlyphIndex = " + ista.firstGlyphIndex + ", indexSubTableArray.lastGlyphIndex = " + ista.lastGlyphIndex; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } // validate glyphCodeArray for (ushort i=0; i<ist5.numGlyphs; i++) { ushort idGlyph = ist5.GetGlyphCode(i); if (idGlyph < ista.firstGlyphIndex || idGlyph > ista.lastGlyphIndex) { string sDetails = "invalid glyph id: " + sID + ", glyphCodeArray[" + i + "] = " + idGlyph + ", indexSubTableArray.firstGlyphIndex = " + ista.firstGlyphIndex + ", indexSubTableArray.lastGlyphIndex = " + ista.lastGlyphIndex; 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; }
bool Validate_indexSubTable_format3(Validator v, indexSubTable3 ist3, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT"); // header has already been validated // validate the array of offsets int nArrSize = ista.lastGlyphIndex - ista.firstGlyphIndex + 1; uint nEBDTLength = EBDTTable.GetLength(); for (ushort i=0; i<nArrSize; i++) { uint offsetImage = ist3.GetOffset(i) + ist3.header.imageDataOffset; if (offsetImage > nEBDTLength) { string sDetails = "invalid offset: " + sID + ", offset[" + i + "] = " + offsetImage + ", EBDT length = " + nEBDTLength; v.Error(T.EBLC_indexSubTables, E.EBLC_E_indexSubTables, m_tag, sDetails); bOk = false; } } return bOk; }
public indexSubTable(uint indexSubTableOffset, MBOBuffer EBLCTableBuf, indexSubTableArray ista) { m_indexSubTableOffset = indexSubTableOffset; m_EBLCTableBuf = EBLCTableBuf; header = new indexSubHeader(indexSubTableOffset, EBLCTableBuf); m_ista = ista; }
bool Validate_indexSubTable(Validator v, indexSubTable ist, indexSubTableArray ista, string sID, OTFontVal fontOwner) { bool bOk = true; if (!Validate_indexSubHeader(v, ist.header, sID, fontOwner)) { bOk = false; } switch (ist.header.indexFormat) { case 1: if (!Validate_indexSubTable_format1(v, (indexSubTable1)ist, ista, sID, fontOwner)) { bOk = false; } break; case 2: if (!Validate_indexSubTable_format2(v, (indexSubTable2)ist, ista, sID, fontOwner)) { bOk = false; } break; case 3: if (!Validate_indexSubTable_format3(v, (indexSubTable3)ist, ista, sID, fontOwner)) { bOk = false; } break; case 4: if (!Validate_indexSubTable_format4(v, (indexSubTable4)ist, ista, sID, fontOwner)) { bOk = false; } break; case 5: if (!Validate_indexSubTable_format5(v, (indexSubTable5)ist, ista, sID, fontOwner)) { bOk = false; } break; default: Debug.Assert(false, "illegal index format", "format = " + ist.header.indexFormat); break; } if (bOk) { v.Pass(T.EBLC_indexSubTables, P.EBLC_P_indexSubTables, m_tag, sID); } return bOk; }