예제 #1
0
        public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf)
        {
            OTTable table = null;

            string sName = GetUnaliasedTableName(tag);

            switch (sName)
            {
            case "BASE": table = new Table_BASE(tag, buf); break;

            case "CFF ": table = new Table_CFF(tag, buf); break;

            case "cmap": table = new Table_cmap(tag, buf); break;

            case "cvt ": table = new Table_cvt(tag, buf); break;

            case "DSIG": table = new Table_DSIG(tag, buf); break;

            case "EBDT": table = new Table_EBDT(tag, buf); break;

            case "EBLC": table = new Table_EBLC(tag, buf); break;

            case "EBSC": table = new Table_EBSC(tag, buf); break;

            case "fpgm": table = new Table_fpgm(tag, buf); break;

            case "gasp": table = new Table_gasp(tag, buf); break;

            case "GDEF": table = new Table_GDEF(tag, buf); break;

            case "glyf": table = new Table_glyf(tag, buf); break;

            case "GPOS": table = new Table_GPOS(tag, buf); break;

            case "GSUB": table = new Table_GSUB(tag, buf); break;

            case "hdmx": table = new Table_hdmx(tag, buf); break;

            case "head": table = new Table_head(tag, buf); break;

            case "hhea": table = new Table_hhea(tag, buf); break;

            case "hmtx": table = new Table_hmtx(tag, buf); break;

            case "JSTF": table = new Table_JSTF(tag, buf); break;

            case "kern": table = new Table_kern(tag, buf); break;

            case "loca": table = new Table_loca(tag, buf); break;

            case "LTSH": table = new Table_LTSH(tag, buf); break;

            case "maxp": table = new Table_maxp(tag, buf); break;

            case "name": table = new Table_name(tag, buf); break;

            case "OS/2": table = new Table_OS2(tag, buf); break;

            case "PCLT": table = new Table_PCLT(tag, buf); break;

            case "post": table = new Table_post(tag, buf); break;

            case "prep": table = new Table_prep(tag, buf); break;

            case "VDMX": table = new Table_VDMX(tag, buf); break;

            case "vhea": table = new Table_vhea(tag, buf); break;

            case "vmtx": table = new Table_vmtx(tag, buf); break;

            case "VORG": table = new Table_VORG(tag, buf); break;

            //case "Zapf": table = new Table_Zapf(tag, buf); break;
            default: table = new Table__Unknown(tag, buf); break;
            }

            return(table);
        }
예제 #2
0
        /************************
         * public methods
         */


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

            if (fontOwner.GetFile().IsCollection())
            {
                if (fontOwner.GetFontIndexInFile() > 0)
                {
                    // checksum not matching data is covered by check elsewhere. Assume they match.
                    DirectoryEntry de_EBDT = fontOwner.GetDirectoryEntry("EBDT");
                    for (uint i = 0; i < fontOwner.GetFontIndexInFile(); i++)
                    {
                        if (fontOwner.GetFile().GetFont(i).GetDirectoryEntry("EBDT").checkSum
                            == de_EBDT.checkSum)
                        {
                            v.Info(T.T_NULL, I.glyf_I_IDENTICAL_GLYF_TABLES_IN_TTC, m_tag);
                            return(true);
                        }
                    }
                }
            }

            m_nCachedMaxpNumGlyphs = fontOwner.GetMaxpNumGlyphs();


            if (v.PerformTest(T.EBDT_version))
            {
                if (version.GetUint() == 0x00020000 || version.GetUint() == 0x00030000)
                {
                    v.Pass(T.EBDT_version, P.EBDT_P_version, m_tag);
                }
                else
                {
                    v.Error(T.EBDT_version, E.EBDT_E_version, m_tag, "version = 0x" + version.GetUint().ToString("x8") + ", unable to continue validation");
                    return(false);
                }
            }
            //TODO: check tag for EBDT v3, CBDT v2, bdat

            if (v.PerformTest(T.EBDT_TableDependency))
            {
                Table_EBLC EBLCTable = (Table_EBLC)fontOwner.GetTable("EBLC");
                if (EBLCTable != null)
                {
                    v.Pass(T.EBDT_TableDependency, P.EBDT_P_TableDependency, m_tag);
                }
                else
                {
                    v.Error(T.EBDT_TableDependency, E.EBDT_E_TableDependency, m_tag);
                    bRet = false;
                }
            }

            // T.EBDT_GlyphImageData depends on T.EBDT_TableDependency passing.
            if (v.PerformTest(T.EBDT_GlyphImageData))
            {
                bool bGlyphImageDataOk = true;

                Table_EBLC EBLCTable = (Table_EBLC)fontOwner.GetTable("EBLC");
                if (EBLCTable == null)
                {
                    return(bRet); //failed the last test, not going on.
                }
                // for each bitmap size
                for (uint i = 0; i < EBLCTable.numSizes; i++)
                {
                    Table_EBLC.bitmapSizeTable bst = EBLCTable.GetBitmapSizeTable(i);
                    string sSize = "bitmapsize[" + i + "], ppemX=" + bst.ppemX + ", ppemY=" + bst.ppemY;

                    if (true)
                    {
                        for (uint j = 0; j < bst.numberOfIndexSubTables; j++)
                        {
                            Table_EBLC.indexSubTable      ist    = null;
                            Table_EBLC.indexSubTableArray ista_j = EBLCTable.GetIndexSubTableArray(bst, j);
                            if (ista_j != null)
                            {
                                ist = bst.GetIndexSubTable(ista_j);
                            }

                            if (ist != null)
                            {
                                string sID = sSize + ", indexSubTable[" + j + "](index fmt " + ist.header.indexFormat +
                                             ", image fmt " + ist.header.imageFormat + ")";

                                switch (ist.header.imageFormat)
                                {
                                case 1:
                                    if (!Validate_Format1(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 2:
                                    if (!Validate_Format2(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 3:
                                    if (!Validate_Format3(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 4:
                                    if (!Validate_Format4(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 5:
                                    if (!Validate_Format5(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 6:
                                    if (!Validate_Format6(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 7:
                                    if (!Validate_Format7(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 8:
                                    if (!Validate_Format8(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 9:
                                    if (!Validate_Format9(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 17:
                                    if (version.GetUint() != 0x00030000)
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    // TODO: adding 3 checks
                                    break;

                                case 18:
                                    if (version.GetUint() != 0x00030000)
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    // TODO: adding 3 checks
                                    break;

                                case 19:
                                    if (version.GetUint() != 0x00030000)
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    // TODO: adding 3 checks
                                    break;

                                default:
                                    // TODO: emit Unknown
                                    break;
                                }
                            }
                        }
                    }
                }

                if (bGlyphImageDataOk)
                {
                    v.Pass(T.EBDT_GlyphImageData, P.EBDT_P_GlyphImageData, m_tag);
                }
            }

            return(bRet);
        }
예제 #3
0
        /************************
         * public methods
         */


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

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

            if (v.PerformTest(T.EBSC_TableLength))
            {
                uint CalcLength = 8 + (numSizes * 28);
                if (CalcLength == GetLength())
                {
                    v.Pass(T.EBSC_TableLength, P.EBSC_P_TableLength, m_tag);
                }
                else
                {
                    string s = "actual length = " + GetLength() + ", calculated = " + CalcLength;
                    v.Error(T.EBSC_TableLength, E.EBSC_E_TableLength, m_tag, s);
                    bRet = false;
                }
            }

            if (v.PerformTest(T.EBSC_TableDependency))
            {
                Table_EBLC EBLCTable = (Table_EBLC)fontOwner.GetTable("EBLC");
                Table_EBDT EBDTTable = (Table_EBDT)fontOwner.GetTable("EBDT");
                if (EBLCTable != null &&
                    EBDTTable != null)
                {
                    v.Pass(T.EBSC_TableDependency, P.EBSC_P_TableDependency, m_tag);
                }
                else
                {
                    string s = "Missing: ";
                    if (EBLCTable == null)
                    {
                        s = s + "EBLC";
                    }
                    if (EBDTTable == null)
                    {
                        if (EBLCTable == null)
                        {
                            s = s + ", EBDT";
                        }
                        else
                        {
                            s = s + "EBDT";
                        }
                    }

                    v.Error(T.EBSC_TableDependency, E.EBSC_E_TableDependency, m_tag, s);
                    bRet = false;
                }
            }

            if (v.PerformTest("EBSC_StrikeSizes"))
            {
                Table_EBLC EBLCTable = (Table_EBLC)fontOwner.GetTable("EBLC");
                if (EBLCTable != null)
                {
                    string s     = "Missing strike: ";
                    bool   bPass = true;

                    for (uint i = 0; i < numSizes; i++)
                    {
                        bitmapScaleTable bitmapScale = GetBitmapScaleTable(i);

                        if (bitmapScale != null)
                        {
                            bool bFound = false;

                            for (uint n = 0; n < EBLCTable.numSizes; n++)
                            {
                                Table_EBLC.bitmapSizeTable bitmapSize = EBLCTable.GetBitmapSizeTable(n);
                                if (bitmapSize != null)
                                {
                                    if (bitmapScale.substitutePpemX == bitmapSize.ppemX &&
                                        bitmapScale.substitutePpemY == bitmapSize.ppemY)
                                    {
                                        bFound = true;
                                        break;
                                    }
                                }
                            }

                            if (!bFound)
                            {
                                string size = "(PpemX:" + bitmapScale.substitutePpemX + ", PpemY:" + bitmapScale.substitutePpemY + ") ";
                                s     = s + size;
                                bPass = false;
                            }
                        }
                    }

                    if (bPass)
                    {
                        v.Pass(T.EBSC_StrikeSizes, P.EBSC_P_StrikeSize, m_tag);
                    }
                    else
                    {
                        v.Error(T.EBSC_StrikeSizes, E.EBSC_E_StrikeSize, m_tag, s);
                    }
                }
                else
                {
                    v.Error(T.EBSC_StrikeSizes, E.EBSC_E_StrikeSizeNoEBLC, m_tag);
                }
            }


            return(bRet);
        }
예제 #4
0
        /************************
         * public methods
         */


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

            m_nCachedMaxpNumGlyphs = fontOwner.GetMaxpNumGlyphs();


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

            if (v.PerformTest(T.EBDT_TableDependency))
            {
                Table_EBLC EBLCTable = (Table_EBLC)fontOwner.GetTable("EBLC");
                if (EBLCTable != null)
                {
                    v.Pass(T.EBDT_TableDependency, P.EBDT_P_TableDependency, m_tag);
                }
                else
                {
                    v.Error(T.EBDT_TableDependency, E.EBDT_E_TableDependency, m_tag);
                    bRet = false;
                }
            }

            if (v.PerformTest(T.EBDT_GlyphImageData))
            {
                bool bGlyphImageDataOk = true;

                Table_EBLC EBLCTable = (Table_EBLC)fontOwner.GetTable("EBLC");

                // for each bitmap size
                for (uint i = 0; i < EBLCTable.numSizes; i++)
                {
                    Table_EBLC.bitmapSizeTable bst = EBLCTable.GetBitmapSizeTable(i);
                    string sSize = "bitmapsize[" + i + "], ppemX=" + bst.ppemX + ", ppemY=" + bst.ppemY;

                    Table_EBLC.indexSubTableArray[] ista = EBLCTable.GetIndexSubTableArray(bst);

                    if (ista != null)
                    {
                        for (uint j = 0; j < bst.numberOfIndexSubTables; j++)
                        {
                            Table_EBLC.indexSubTable ist = null;
                            if (ista[j] != null)
                            {
                                ist = bst.GetIndexSubTable(ista[j]);
                            }

                            if (ist != null)
                            {
                                string sID = sSize + ", indexSubTable[" + j + "](index fmt " + ist.header.indexFormat +
                                             ", image fmt " + ist.header.imageFormat + ")";

                                switch (ist.header.imageFormat)
                                {
                                case 1:
                                    if (!Validate_Format1(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 2:
                                    if (!Validate_Format2(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 3:
                                    if (!Validate_Format3(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 4:
                                    if (!Validate_Format4(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 5:
                                    if (!Validate_Format5(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 6:
                                    if (!Validate_Format6(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 7:
                                    if (!Validate_Format7(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 8:
                                    if (!Validate_Format8(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                case 9:
                                    if (!Validate_Format9(v, sID, ist))
                                    {
                                        bGlyphImageDataOk = false;
                                        bRet = false;
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }

                if (bGlyphImageDataOk)
                {
                    v.Pass(T.EBDT_GlyphImageData, P.EBDT_P_GlyphImageData, m_tag);
                }
            }

            return(bRet);
        }