예제 #1
0
        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);
        }
예제 #2
0
            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;
            }
예제 #3
0
        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;
        }