Example #1
0
        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);
        }
Example #2
0
        /************************
         * public methods
         */


        public bool Validate(Validator v, OTFontVal fontOwner)
        {
            bool bRet          = true;
            bool bNumSizesOkay = true;

            Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT");


            if (v.PerformTest(T.EBLC_version))
            {
                if (version.GetUint() == 0x00020000)
                {
                    v.Pass(T.EBLC_version, P.EBLC_P_version, m_tag);
                }
                else
                {
                    v.Error(T.EBLC_version, E.EBLC_E_version, m_tag, "version = 0x" + version.GetUint().ToString("x8") + ", unable to continue validation");
                    return(false);
                }
            }

            if (v.PerformTest(T.EBLC_numSizes))
            {
                if (numSizes < (m_bufTable.GetLength() / 48))
                {
                    v.Pass(T.EBLC_numSizes, P.EBLC_P_numSizes, m_tag);
                }
                else
                {
                    v.Error(T.EBLC_numSizes, E.EBLC_E_numSizes, m_tag, "0x" + numSizes.ToString("x8"));
                    bNumSizesOkay = false;
                    bRet          = false;
                }
            }

            if (v.PerformTest(T.EBLC_TableDependency))
            {
                if (EBDTTable != null)
                {
                    v.Pass(T.EBLC_TableDependency, P.EBLC_P_TableDependency, m_tag);
                }
                else
                {
                    v.Error(T.EBLC_TableDependency, E.EBLC_E_TableDependency, m_tag);
                    bRet = false;
                }
            }

            if (v.PerformTest(T.EBLC_indexSubTableArrayOffset) && bNumSizesOkay == true)
            {
                bool bOffsetsOk = true;
                bool bIndicesOk = true;

                uint SmallestPossibleOffset = 8 + numSizes * 48; // sizeof header + sizeof bitmapSizeTAbles
                for (uint i = 0; i < numSizes; i++)
                {
                    bitmapSizeTable bst = GetBitmapSizeTable(i);

                    // start must be less than or equal to end
                    if (bst.startGlyphIndex > bst.endGlyphIndex)
                    {
                        string s = "index = " + i + ", start index = " + bst.startGlyphIndex + ", stop index = " + bst.endGlyphIndex;
                        v.Error(T.EBLC_SizeTableIndexOrder, E.EBLC_E_BitmapSizeTableIndexOrder, m_tag, s);
                        bIndicesOk = false;
                        bRet       = false;
                    }

                    if (bst.indexSubTableArrayOffset < SmallestPossibleOffset ||
                        bst.indexSubTableArrayOffset + bst.indexTablesSize > GetLength())
                    {
                        string s = "index = " + i + ", indexSubTableArrayOffset = " + bst.indexSubTableArrayOffset
                                   + ", indexTablesSize = " + bst.indexTablesSize;
                        v.Error(T.EBLC_indexSubTableArrayOffset, E.EBLC_E_indexSubTableArrayOffset, m_tag, s);
                        bOffsetsOk = false;
                        bRet       = false;
                    }
                    else
                    {
                        indexSubTableArray[] ista = GetIndexSubTableArray(bst);

                        for (uint j = 0; j < bst.numberOfIndexSubTables; j++)
                        {
                            // first must be less than or equal to last
                            if (ista[j].firstGlyphIndex > ista[j].lastGlyphIndex)
                            {
                            }

                            // subtable indices must be within size table range
                            if (ista[j].firstGlyphIndex <bst.startGlyphIndex ||
                                                         ista[j].lastGlyphIndex> bst.endGlyphIndex)
                            {
                            }
                        }
                    }
                }

                if (bOffsetsOk)
                {
                    v.Pass(T.EBLC_indexSubTableArrayOffset, P.EBLC_P_indexSubTableArrayOffset, m_tag);
                }

                if (bIndicesOk)
                {
                    v.Pass(T.EBLC_SizeTableIndexOrder, P.EBLC_P_BitmapSizeTableIndexOrder, m_tag);
                }
            }

            if (v.PerformTest(T.EBLC_bitDepth) && bNumSizesOkay == true)
            {
                bool bBitDepthOk = true;

                for (uint i = 0; i < numSizes; i++)
                {
                    bitmapSizeTable bst = GetBitmapSizeTable(i);
                    if (bst.bitDepth != 1 && bst.bitDepth != 2 && bst.bitDepth != 4 && bst.bitDepth != 8)
                    {
                        string s = "index = " + i + ", bitDepth = " + bst.bitDepth;
                        v.Error(T.EBLC_bitDepth, E.EBLC_E_bitDepth, m_tag, s);
                        bBitDepthOk = false;
                        bRet        = false;
                    }
                }

                if (bBitDepthOk)
                {
                    v.Pass(T.EBLC_bitDepth, P.EBLC_P_bitDepth, m_tag);
                }
            }

            if (v.PerformTest(T.EBLC_indexSubTables) && bNumSizesOkay == true)
            {
                for (uint i = 0; i < numSizes; i++)
                {
                    bitmapSizeTable bst   = GetBitmapSizeTable(i);
                    string          sSize = "bitmapsize[" + i + "], ppemX=" + bst.ppemX + ", ppemY=" + bst.ppemY;

                    indexSubTableArray[] ista = GetIndexSubTableArray(bst);

                    for (uint j = 0; j < bst.numberOfIndexSubTables; j++)
                    {
                        indexSubTable ist = bst.GetIndexSubTable(ista[j]);
                        string        sID = sSize + ", indexSubTable[" + j + "](fmt " + ist.header.indexFormat + ")";

                        if (!Validate_indexSubTable(v, ist, ista[j], sID, fontOwner))
                        {
                            bRet = false;
                        }
                    }
                }
            }

            return(bRet);
        }
Example #3
0
                private imageCache getEBDTImageFormat( Table_EBDT tableEDBT , indexSubTable ist, uint nGlyphIndex, uint nStartGlyphIndex )
                {                    
                    imageCache ic = null;
                    
            
                    switch( ist.header.imageFormat )
                    {
                        case 1:
                        {
                            Table_EBDT.smallGlyphMetrics sgm = tableEDBT.GetSmallMetrics( ist, nGlyphIndex, nStartGlyphIndex );
                            byte[] bData = tableEDBT.GetImageData( ist, nGlyphIndex, nStartGlyphIndex );
                            ic = new imageCache1( sgm, bData );                            
                            break;
                        }
                        case 2:
                        {
                            Table_EBDT.smallGlyphMetrics sgm = tableEDBT.GetSmallMetrics( ist, nGlyphIndex, nStartGlyphIndex );
                            byte[] bData = tableEDBT.GetImageData( ist, nGlyphIndex, nStartGlyphIndex );
                            ic = new imageCache2( sgm, bData );
                            break;
                        }                        
                        case 5:
                        {
                            byte[] bData = tableEDBT.GetImageData( ist, nGlyphIndex, nStartGlyphIndex );
                            ic = new imageCache5( bData );                            
                            break;
                        }        
                        case 6:
                        {
                            Table_EBDT.bigGlyphMetrics bgm = tableEDBT.GetBigMetrics( ist, nGlyphIndex, nStartGlyphIndex );
                            byte[] bData = tableEDBT.GetImageData( ist, nGlyphIndex, nStartGlyphIndex );
                            ic = new imageCache6( bgm, bData );
                            break;
                        }        
                        case 7:
                        {
                            Table_EBDT.bigGlyphMetrics bgm = tableEDBT.GetBigMetrics( ist, nGlyphIndex, nStartGlyphIndex );
                            byte[] bData = tableEDBT.GetImageData( ist, nGlyphIndex, nStartGlyphIndex );
                            ic = new imageCache7( bgm, bData );                        
                            break;
                        }        
                        case 8:
                        {
                            Table_EBDT.smallGlyphMetrics sgm = tableEDBT.GetSmallMetrics( ist, nGlyphIndex, nStartGlyphIndex );
                            ushort nNumComp = tableEDBT.GetNumComponents( ist, nGlyphIndex, nStartGlyphIndex );
                            ArrayList components = new ArrayList( nNumComp );
                            for( uint i = 0; i < nNumComp; i++ )
                            {
                                components.Add( tableEDBT.GetComponent( ist, nGlyphIndex, nStartGlyphIndex, i ));                                
                            }
                            ic = new imageCache8( sgm, nNumComp, components );                    
                            break;
                        }        
                        case 9:
                        {
                            Table_EBDT.bigGlyphMetrics bgm = tableEDBT.GetBigMetrics( ist, nGlyphIndex, nStartGlyphIndex );
                            ushort nNumComp = tableEDBT.GetNumComponents( ist, nGlyphIndex, nStartGlyphIndex );
                            ArrayList components = new ArrayList( nNumComp );
                            for( uint i = 0; i < nNumComp; i++ )
                            {
                                components.Add( tableEDBT.GetComponent( ist, nGlyphIndex, nStartGlyphIndex, i ));                                
                            }
                            ic = new imageCache9( bgm, nNumComp, components );                        
                            break;
                        }        
                        default:
                            Debug.Assert( false, "unsupported image format" );
                            break;
                        
                    }

                    return ic;
                }                
Example #4
0
        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;
        }