示例#1
0
                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;
                }
示例#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);
        }
示例#3
0
                public bitmapSizeTableCache( Table_EBLC OwnerTable, bitmapSizeTable bst )
                {
                    m_numberOfIndexSubTables = bst.numberOfIndexSubTables;                    
                    m_indexSubTableArray = new ArrayList( (int)m_numberOfIndexSubTables );
                    indexSubTableArray[] ista = OwnerTable.GetIndexSubTableArray( bst );
                    for( int i = 0; i < m_numberOfIndexSubTables; i++ )
                    {                        
                        indexSubTableCache istc = getEBLCIndexSubTable( OwnerTable, bst, ista[i] );
                        indexSubTableArrayCache istac = new indexSubTableArrayCache( ista[i].firstGlyphIndex, ista[i].lastGlyphIndex, istc );
                        m_indexSubTableArray.Add( istac );

                        indexSubTable ic = bst.GetIndexSubTable(ista[i]);

                        //ista[i].additionalOffsetToIndexSubtable += bst.indexSubTableArrayOffset;                        
                    }

                    m_colorRef = bst.colorRef;
                    hori = sbitLineMetricsCache.FromSbitLineMetrics(bst.hori);
                    vert = sbitLineMetricsCache.FromSbitLineMetrics(bst.vert);
                    m_startGlyphIndex = bst.startGlyphIndex;
                    m_endGlyphIndex = bst.endGlyphIndex;
                    ppemX = bst.ppemX;
                    ppemY = bst.ppemY;
                    bitDepth = bst.bitDepth;
                    flags = bst.flags;        
                }