Validate() 공개 메소드

public Validate ( ) : bool
리턴 bool
예제 #1
0
        public bool Validate()
        {
            long StartTicks = DateTime.UtcNow.Ticks;
            bool bRet       = true;

            m_Validator.OnFileValidationEvent(this, true);

            for (uint i = 0; i < m_nFonts; i++)
            {
                // check to see if user canceled validation
                if (m_Validator.CancelFlag)
                {
                    bRet = false;
                    break;
                }

                m_Validator.OnFontValidationEvent(i, true);

                OTFontVal f = GetFont(i);

                if (f != null)
                {
                    m_Validator.OnFontParsedEvent(f);

                    if (!f.Validate())
                    {
                        bRet = false;
                    }
                }

                m_Validator.OnFontValidationEvent(i, false);
            }

            // build the elapsed time string
            int nSeconds = (int)((DateTime.UtcNow.Ticks - StartTicks) / (double)10000000);
            int nHours   = nSeconds / 3600;

            nSeconds = nSeconds - nHours * 3600;
            int nMins = nSeconds / 60;

            nSeconds = nSeconds - nMins * 60;
            string sTime = nHours.ToString() + ":" + nMins.ToString("d2") + ":" + nSeconds.ToString("d2");

            m_Validator.Info(T.T_NULL, I._GEN_I_TotalValTime, null, sTime);

            //Let's try to validate the DSIG table in a TTC, if it exists
            if (IsCollection())
            {
                if (m_ttch.version >= 0x00010000 && GetTableManager().GetUnaliasedTableName(m_ttch.DsigTag) == "DSIG")
                {
                    MBOBuffer      buf   = this.ReadPaddedBuffer(m_ttch.DsigOffset, m_ttch.DsigLength);
                    OTTable        table = GetTableManager().CreateTableObject(m_ttch.DsigTag, buf);
                    DirectoryEntry de    = new DirectoryEntry();
                    de.tag    = m_ttch.DsigTag;
                    de.offset = m_ttch.DsigOffset;
                    de.length = m_ttch.DsigLength;

                    OTFontVal fontOwner = new OTFontVal(this);
                    bRet &= ValidateTable(table, m_Validator, de, fontOwner);
                }
                else
                {
                    m_Validator.Warning(T.T_NULL, W._FONT_W_MissingRecommendedTable, null, "DSIG");
                }
                // TODO: check m_ttch.version == 0x00010000/0x00020000
            }

            m_Validator.OnFileValidationEvent(this, false);

            if (m_Validator.CancelFlag)
            {
                m_Validator.ApplicationError(T.T_NULL, E._GEN_E_UserCanceled, null, "");
                bRet = false;
            }

            return(bRet);
        }