Esempio n. 1
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseScriptTable, CalcLength(), v, sIdentity, table.GetTag());

                // check the BaseValuesOffset
                if (BaseValuesOffset == 0)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseValuesOffset_null, table.m_tag, sIdentity);
                }
                else if (BaseValuesOffset + m_offsetBaseScriptTable > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.BASE_E_BaseValuesOffset, table.m_tag, sIdentity);
                }
                else
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseValuesOffset, table.m_tag, sIdentity);
                }

                // check the DefaultMinMaxOffset
                if (DefaultMinMaxOffset == 0)
                {
                    v.Pass(T.T_NULL, P.BASE_P_DefaultMinMaxOffset_null, table.m_tag, sIdentity);
                }
                else if (DefaultMinMaxOffset + m_offsetBaseScriptTable > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.BASE_E_DefaultMinMaxOffset, table.m_tag, sIdentity);
                }
                else
                {
                    v.Pass(T.T_NULL, P.BASE_P_DefaultMinMaxOffset, table.m_tag, sIdentity);
                }

                // check the BaseLangSysRecord order
                bool bOrderOk = true;

                if (BaseLangSysCount > 1)
                {
                    for (uint i = 0; i < BaseLangSysCount - 1; i++)
                    {
                        BaseLangSysRecord ThisBlsr = GetBaseLangSysRecord(i);
                        BaseLangSysRecord NextBlsr = GetBaseLangSysRecord(i + 1);
                        if (ThisBlsr.BaseLangSysTag >= NextBlsr.BaseLangSysTag)
                        {
                            v.Error(T.T_NULL, E.BASE_E_BaseLangSysRecord_order, table.m_tag, sIdentity);
                            bOrderOk = false;
                            bRet     = false;
                        }
                    }
                }
                if (bOrderOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseLangSysRecord_order, table.m_tag, sIdentity);
                }

                // check the BaseLangSysRecord MinMaxOffsets
                bool bOffsetsOk = true;

                for (uint i = 0; i < BaseLangSysCount; i++)
                {
                    BaseLangSysRecord bslr = GetBaseLangSysRecord(i);
                    if (bslr.MinMaxOffset == 0)
                    {
                        v.Error(T.T_NULL, E.BASE_E_BaseLangSysRecord_offset0, table.m_tag, sIdentity + ", BaseLangSysRecord index = " + i);
                        bOffsetsOk = false;
                        bRet       = false;
                    }
                    else if (bslr.MinMaxOffset + m_offsetBaseScriptTable > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.BASE_E_BaseLangSysRecord_offset, table.m_tag, sIdentity + ", BaseLangSysRecord index = " + i);
                        bOffsetsOk = false;
                        bRet       = false;
                    }
                }
                if (bOffsetsOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseLangSysRecord_offsets, table.m_tag, sIdentity);
                }

                // check the BaseValuesTable
                if (BaseValuesOffset != 0)
                {
                    BaseValuesTable_val bvt = GetBaseValuesTable_val();
                    bvt.Validate(v, sIdentity, table);
                }

                // check the Default MinMaxTable
                if (DefaultMinMaxOffset != 0)
                {
                    MinMaxTable_val mmt = GetDefaultMinMaxTable_val();
                    mmt.Validate(v, sIdentity + ", default MinMax", table);
                }

                // check the BaseLangSysRecord MinMaxTables
                for (uint i = 0; i < BaseLangSysCount; i++)
                {
                    BaseLangSysRecord blsr = GetBaseLangSysRecord(i);
                    MinMaxTable_val   mmt  = GetMinMaxTable_val(blsr);
                    mmt.Validate(v, sIdentity + ", BaseLangSysRecord[" + i + "]", table);
                }

                return(bRet);
            }
Esempio n. 2
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseValuesTable, CalcLength(), v, sIdentity, table.GetTag());

                // check BaseCoord offsets
                bool bOffsetsOk = true;

                for (uint i = 0; i < BaseCoordCount; i++)
                {
                    ushort bco = GetBaseCoordOffset(i);
                    if (bco == 0)
                    {
                        v.Error(T.T_NULL, E.BASE_E_BaseValuesTable_BCO_0, table.m_tag, sIdentity + ", BaseCoordOffset index = " + i);
                        bOffsetsOk = false;
                        bRet       = false;
                    }
                    else if (bco + m_offsetBaseValuesTable > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.BASE_E_BaseValuesTable_BCO_invalid, table.m_tag, sIdentity + ", BaseCoordOffset index = " + i);
                        bOffsetsOk = false;
                        bRet       = false;
                    }
                }
                if (bOffsetsOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseValuesTable_BCO, table.m_tag, sIdentity);
                }

                // check the BaseCoord tables
                for (uint i = 0; i < BaseCoordCount; i++)
                {
                    BaseCoordTable_val bct = GetBaseCoordTable_val(i);
                    bct.Validate(v, sIdentity, table);
                }

                return(bRet);
            }
Esempio n. 3
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseTagListTable, CalcLength(), v, sIdentity, table.GetTag());

                bool bTagsValid = true;

                for (uint i = 0; i < BaseTagCount; i++)
                {
                    OTTag BaselineTag = GetBaselineTag(i);
                    if (!BaselineTag.IsValid())
                    {
                        v.Error(T.T_NULL, E.BASE_E_BaseTagList_TagValid, table.m_tag, sIdentity + ", tag = 0x" + ((uint)BaselineTag).ToString("x8"));
                        bTagsValid = false;
                        bRet       = false;
                    }
                }
                if (bTagsValid)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseTagList_TagValid, table.m_tag, sIdentity);
                }

                bool bOrderOk = true;

                if (BaseTagCount > 1)
                {
                    for (uint i = 0; i < BaseTagCount - 1; i++)
                    {
                        OTTag ThisTag = GetBaselineTag(i);
                        OTTag NextTag = GetBaselineTag(i + 1);
                        if (ThisTag >= NextTag)
                        {
                            v.Error(T.T_NULL, E.BASE_E_BaseTagList_TagOrder, table.m_tag, sIdentity);
                            bOrderOk = false;
                            bRet     = false;
                            break;
                        }
                    }
                }
                if (bOrderOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseTagList_TagOrder, table.m_tag, sIdentity);
                }

                return(bRet);
            }
Esempio n. 4
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseScriptListTable, CalcLength(), v, sIdentity, table.GetTag());

                bool bOrderOk = true;

                if (BaseScriptCount > 1)
                {
                    for (uint i = 0; i < BaseScriptCount - 1; i++)
                    {
                        BaseScriptRecord ThisBsr = GetBaseScriptRecord(i);
                        BaseScriptRecord NextBsr = GetBaseScriptRecord(i + 1);
                        if (ThisBsr.BaseScriptTag >= NextBsr.BaseScriptTag)
                        {
                            v.Error(T.T_NULL, E.BASE_E_BaseScriptList_Order, table.m_tag, sIdentity);
                            bOrderOk = false;
                            bRet     = false;
                            break;
                        }
                    }
                }
                if (bOrderOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseScriptList_Order, table.m_tag, sIdentity);
                }

                bool bOffsetsOk = true;

                for (uint i = 0; i < BaseScriptCount; i++)
                {
                    BaseScriptRecord bsr = GetBaseScriptRecord(i);
                    if (bsr.BaseScriptOffset + m_offsetBaseScriptListTable > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.BASE_E_BaseScriptList_Offset, table.m_tag, sIdentity + ", index = " + i);
                        bOffsetsOk = false;
                        bRet       = false;
                    }
                }
                if (bOffsetsOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseScriptList_Offset, table.m_tag, sIdentity);
                }

                for (uint i = 0; i < BaseScriptCount; i++)
                {
                    BaseScriptRecord    bsr = GetBaseScriptRecord(i);
                    BaseScriptTable_val bst = GetBaseScriptTable_val(bsr);
                    bst.Validate(v, sIdentity + ", BaseScriptRecord[" + i + "](" + bsr.BaseScriptTag + ")", table);
                }


                return(bRet);
            }
Esempio n. 5
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                // check for data overlap
                bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfMax, CalcLength(), v, sIdentity, table.GetTag());

                // check the Lookup array length
                if (m_offsetJstfMax + (uint)FieldOffsets.LookupOffsets + LookupCount * 2 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", Lookup");
                    bRet = false;
                }

                // check each Lookup offset
                for (uint i = 0; i < LookupCount; i++)
                {
                    if (m_offsetJstfMax + GetLookupOffset(i) > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", Lookup[" + i + "]");
                        bRet = false;
                    }
                }

                // check each Lookup table
                for (uint i = 0; i < LookupCount; i++)
                {
                    LookupTable_val lt = GetLookupTable_val(i);
                    bRet &= lt.Validate(v, sIdentity + ", Lookup[" + i + "]", table);
                }

                return(bRet);
            }
Esempio n. 6
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetAxisTable, CalcLength(), v, sIdentity, table.GetTag());


                if (BaseTagListOffset == 0)
                {
                    v.Pass(T.T_NULL, P.BASE_P_AxisTable_BaseTagListOffset_null, table.m_tag, sIdentity);
                }
                else if (BaseTagListOffset + m_offsetAxisTable > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.BASE_E_AxisTable_BaseTagListOffset, table.m_tag, sIdentity);
                    bRet = false;
                }
                else
                {
                    v.Pass(T.T_NULL, P.BASE_P_AxisTable_BaseTagListOffset_valid, table.m_tag, sIdentity);
                    BaseTagListTable_val btlt = GetBaseTagListTable_val();
                    btlt.Validate(v, sIdentity, table);
                }


                if (BaseScriptListOffset == 0)
                {
                    v.Error(T.T_NULL, E.BASE_E_AxisTable_BaseScriptListOffset_null, table.m_tag, sIdentity);
                    bRet = false;
                }
                else if (BaseScriptListOffset + m_offsetAxisTable > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.BASE_E_AxisTable_BaseScriptListOffset, table.m_tag, sIdentity);
                    bRet = false;
                }
                else
                {
                    v.Pass(T.T_NULL, P.BASE_P_AxisTable_BaseScriptListOffset_valid, table.m_tag, sIdentity);
                    BaseScriptListTable_val bslt = GetBaseScriptListTable_val();
                    bslt.Validate(v, sIdentity, table);
                }

                return(bRet);
            }
Esempio n. 7
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                // check for data overlap
                bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfPriority, CalcLength(), v, sIdentity, table.GetTag());

                // check the ShrinkageEnableGSUB offset
                if (ShrinkageEnableGSUBOffset != 0)
                {
                    if (m_offsetJstfPriority + ShrinkageEnableGSUBOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ShrinkageEnableGSUB");
                        bRet = false;
                    }
                }

                // check the ShrinkageEnableGSUB table
                if (ShrinkageEnableGSUBOffset != 0)
                {
                    JstfGSUBModList_val jgml = GetShrinkageEnableGSUBTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ShrinkageEnableGSUB", table);
                }

                // check the ShrinkageDisableGSUB offset
                if (ShrinkageDisableGSUBOffset != 0)
                {
                    if (m_offsetJstfPriority + ShrinkageDisableGSUBOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ShrinkageDisableGSUB");
                        bRet = false;
                    }
                }

                // check the ShrinkageDisableGSUB table
                if (ShrinkageDisableGSUBOffset != 0)
                {
                    JstfGSUBModList_val jgml = GetShrinkageDisableGSUBTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ShrinkageDisableGSUB", table);
                }

                // check the ShrinkageEnableGPOS offset
                if (ShrinkageEnableGPOSOffset != 0)
                {
                    if (m_offsetJstfPriority + ShrinkageEnableGPOSOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ShrinkageEnableGPOS");
                        bRet = false;
                    }
                }

                // check the ShrinkageEnableGPOS table
                if (ShrinkageEnableGPOSOffset != 0)
                {
                    JstfGPOSModList_val jgml = GetShrinkageEnableGPOSTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ShrinkageEnableGPOS", table);
                }

                // check the ShrinkageDisableGPOS offset
                if (ShrinkageDisableGPOSOffset != 0)
                {
                    if (m_offsetJstfPriority + ShrinkageDisableGPOSOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ShrinkageDisableGPOS");
                        bRet = false;
                    }
                }

                // check the ShrinkageDisableGPOS table
                if (ShrinkageDisableGPOSOffset != 0)
                {
                    JstfGPOSModList_val jgml = GetShrinkageDisableGPOSTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ShrinkageDisableGPOS", table);
                }

                // check the ShrinkageJstfMax offset
                if (ShrinkageJstfMaxOffset != 0)
                {
                    if (m_offsetJstfPriority + ShrinkageJstfMaxOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ShrinkageJstfMax");
                        bRet = false;
                    }
                }

                // check the ShrinkageJstfMax table
                if (ShrinkageJstfMaxOffset != 0)
                {
                    JstfMax_val jm = GetShrinkageJstfMaxTable_val();
                    bRet &= jm.Validate(v, sIdentity + ", ShrinkageJstfMax", table);
                }

                // check the ExtensionEnableGSUB offset
                if (ExtensionEnableGSUBOffset != 0)
                {
                    if (m_offsetJstfPriority + ExtensionEnableGSUBOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtensionEnableGSUB");
                        bRet = false;
                    }
                }

                // check the ExtensionEnableGSUB table
                if (ExtensionEnableGSUBOffset != 0)
                {
                    JstfGSUBModList_val jgml = GetExtensionEnableGSUBTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ExtensionEnableGSUB", table);
                }

                // check the ExtensionDisableGSUB offset
                if (ExtensionDisableGSUBOffset != 0)
                {
                    if (m_offsetJstfPriority + ExtensionDisableGSUBOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtensionDisableGSUB");
                        bRet = false;
                    }
                }

                // check the ExtensionDisableGSUB table
                if (ExtensionDisableGSUBOffset != 0)
                {
                    JstfGSUBModList_val jgml = GetExtensionDisableGSUBTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ExtensionDisableGSUB", table);
                }

                // check the ExtensionEnableGPOS offset
                if (ExtensionEnableGPOSOffset != 0)
                {
                    if (m_offsetJstfPriority + ExtensionEnableGPOSOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtensionEnableGPOS");
                        bRet = false;
                    }
                }

                // check the ExtensionEnableGPOS table
                if (ExtensionEnableGPOSOffset != 0)
                {
                    JstfGPOSModList_val jgml = GetExtensionEnableGPOSTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ExtensionEnableGPOS", table);
                }

                // check the ExtensionDisableGPOS offset
                if (ExtensionDisableGPOSOffset != 0)
                {
                    if (m_offsetJstfPriority + ExtensionDisableGPOSOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtensionDisableGPOS");
                        bRet = false;
                    }
                }

                // check the ExtensionDisableGPOS table
                if (ExtensionDisableGPOSOffset != 0)
                {
                    JstfGPOSModList_val jgml = GetExtensionDisableGPOSTable_val();
                    bRet &= jgml.Validate(v, sIdentity + ", ExtensionDisableGPOS", table);
                }

                // check the ExtensionJstfMax offset
                if (ExtensionJstfMaxOffset != 0)
                {
                    if (m_offsetJstfPriority + ExtensionJstfMaxOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtensionJstfMax");
                        bRet = false;
                    }
                }

                // check the ExtensionJstfMax table
                if (ExtensionJstfMaxOffset != 0)
                {
                    JstfMax_val jm = GetExtensionJstfMaxTable_val();
                    bRet &= jm.Validate(v, sIdentity + ", ExtensionJstfMax", table);
                }

                return(bRet);
            }
Esempio n. 8
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_GDEF)table).ValidateNoOverlap(m_offsetLigCaretListTable, CalcLength(), v, sIdentity, table.GetTag());

                if (CoverageOffset == 0)
                {
                    v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_CoverageOffset_0, table.m_tag, sIdentity);
                    bRet = false;
                }
                else if (CoverageOffset > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_CoverageOffset_invalid, table.m_tag, sIdentity);
                    bRet = false;
                }
                else
                {
                    v.Pass(T.T_NULL, P.GDEF_P_LigCaretListTable_CoverageOffset, table.m_tag, sIdentity);
                    CoverageTable_val ct = GetCoverageTable_val();
                    ct.Validate(v, sIdentity + ", Coverage", table);
                }



                if (m_offsetLigCaretListTable + (uint)FieldOffsets.LigGlyphOffsets + LigGlyphCount*2 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_LigGlyphArray_PastEOT, table.m_tag, sIdentity);
                    bRet = false;
                }

                bool bOffsetsOk = true;
                for (uint i=0; i<LigGlyphCount; i++)
                {
                    if (m_offsetLigCaretListTable + GetLigGlyphOffset(i) > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.GDEF_E_LigCaretListTable_LigGlyphOffset, table.m_tag, sIdentity + ", index = " + i);
                        bOffsetsOk = false;
                        bRet = false;
                    }
                    else
                    {
                        LigGlyphTable_val lgt = GetLigGlyphTable_val(i);
                        lgt.Validate(v, sIdentity + ", LigGlyph[" + i + "]", table);
                    }
                }
                if (bOffsetsOk)
                {
                    v.Pass(T.T_NULL, P.GDEF_P_LigCaretListTable_LigGlyphArray, table.m_tag, sIdentity);
                }


                return bRet;
            }
Esempio n. 9
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                // check for data overlap
                bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetExtenderGlyph, CalcLength(), v, sIdentity, table.GetTag());

                // check the ExtenderGlyph array length
                if (m_offsetExtenderGlyph + (uint)FieldOffsets.ExtenderGlyphs + GlyphCount * 2 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", ExtenderGlyph array");
                    bRet = false;
                }

                // check that the ExtenderGlyph array is in increasing numerical order
                if (GlyphCount > 1)
                {
                    for (uint i = 0; i < GlyphCount - 1; i++)
                    {
                        if (GetExtenderGlyph(i) >= GetExtenderGlyph(i + 1))
                        {
                            v.Error(T.T_NULL, E.JSTF_E_Array_order, table.m_tag, sIdentity + ", ExtenderGlyph array");
                            bRet = false;
                            break;
                        }
                    }
                }


                return(bRet);
            }
Esempio n. 10
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                // check for data overlap
                bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfLangSys, CalcLength(), v, sIdentity, table.GetTag());

                // check the JstfPriority array length
                if (m_offsetJstfLangSys + (uint)FieldOffsets.JstfPriorityOffsets + JstfPriorityCount * 2 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", JstfPriority array");
                    bRet = false;
                }

                // check each JstfPriority offset
                for (uint i = 0; i < JstfPriorityCount; i++)
                {
                    if (m_offsetJstfLangSys + GetJstfPriorityOffset(i) > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", JstfPriority[" + i + "]");
                        bRet = false;
                    }
                }

                // check each JstfPriority table
                for (uint i = 0; i < JstfPriorityCount; i++)
                {
                    JstfPriority_val jp = GetJstfPriorityTable_val(i);
                    bRet &= jp.Validate(v, sIdentity + ", JstfPriority[" + i + "]", table);
                }

                return(bRet);
            }
Esempio n. 11
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                // check for data overlap
                bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfScript, CalcLength(), v, sIdentity, table.GetTag());

                // check the ExtenderGlyph offset
                if (ExtenderGlyphOffset != 0)
                {
                    if (m_offsetJstfScript + ExtenderGlyphOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtenderGlyph");
                        bRet = false;
                    }
                }

                // check the ExtenderGlyph table
                if (ExtenderGlyphOffset != 0)
                {
                    ExtenderGlyph_val eg = GetExtenderGlyphTable_val();
                    bRet &= eg.Validate(v, sIdentity + ", ExtenderGlyph", table);
                }

                // check the DefJstfLangSys offset
                if (DefJstfLangSysOffset != 0)
                {
                    if (m_offsetJstfScript + DefJstfLangSysOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", DefJstfLangSys");
                        bRet = false;
                    }
                }

                // check the DefJstfLangSys table
                if (DefJstfLangSysOffset != 0)
                {
                    JstfLangSys_val jls = GetDefJstfLangSysTable_val();
                    bRet &= jls.Validate(v, sIdentity + ", DefJstfLangSys", table);
                }

                // check the JstfLangSysRecord array length
                if (m_offsetJstfScript + (uint)FieldOffsets.JstfLangSysRecords + JstfLangSysCount * 6 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", JstfLangSysRecord array");
                    bRet = false;
                }

                // check the JstfLangSysRecord array order
                if (JstfLangSysCount > 1)
                {
                    for (uint i = 0; i < JstfLangSysCount - 1; i++)
                    {
                        JstfLangSysRecord jlsrCurr = GetJstfLangSysRecord(i);
                        JstfLangSysRecord jlsrNext = GetJstfLangSysRecord(i);

                        if (jlsrCurr.JstfLangSysTag >= jlsrNext.JstfLangSysTag)
                        {
                            v.Error(T.T_NULL, E.JSTF_E_Array_order, table.m_tag, sIdentity + ", JstfLangSysRecord[" + i + "]");
                            bRet = false;
                            break;
                        }
                    }
                }

                // check each JstfLangSysRecord
                for (uint i = 0; i < JstfLangSysCount; i++)
                {
                    JstfLangSysRecord jlsr = GetJstfLangSysRecord(i);

                    // check the tag
                    if (!jlsr.JstfLangSysTag.IsValid())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_tag, table.m_tag, sIdentity + ", JstfLangSysRecord[" + i + "]");
                        bRet = false;
                    }

                    // check the JstfLangSys offset
                    if (m_offsetJstfScript + jlsr.JstfLangSysOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.JSTF_E_Offset_PastEOT, table.m_tag, sIdentity + ", JstfLangSysRecord[" + i + "]");
                        bRet = false;
                    }

                    // check the JstfLangSys table
                    JstfLangSys_val jls = GetJstfLangSysTable_val(jlsr);
                    bRet &= jls.Validate(v, sIdentity + ", JstfLangSysRecord[" + i + "], JstfLangSys", table);
                }

                return(bRet);
            }
Esempio n. 12
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_GDEF)table).ValidateNoOverlap(m_offsetMarkGlyphSetsDefTable, CalcLength(), v, sIdentity, table.GetTag());

                if (MarkSetTableFormat != 1)
                {
                    v.Error(T.T_NULL, E.GDEF_E_MarkSetTableFormat, table.m_tag,
                            sIdentity + ": MarkSetTableFormat=" + MarkSetTableFormat.ToString());
                    bRet = false;
                }

                if (m_offsetMarkGlyphSetsDefTable + CalcLength() > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.GDEF_E_MarkGlyphSetsDefTable_PastEOT, table.m_tag, sIdentity);
                    bRet = false;
                }

                v.Info(T.T_NULL, I.GDEF_I_MarkSetCount, table.m_tag, sIdentity + ": MarkSetCount=" + MarkSetCount);
                // TODO: check Coverage [MarkSetCount] array?

                if (bRet)
                {
                    v.Pass(T.T_NULL, P.GDEF_P_MarkGlyphSetsDefTable, table.m_tag, sIdentity);
                }

                return bRet;
            }
Esempio n. 13
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_GDEF)table).ValidateNoOverlap(m_offsetLigGlyphTable, CalcLength(), v, sIdentity, table.GetTag());

                if (m_offsetLigGlyphTable + (uint)FieldOffsets.CaretValueOffsets + CaretCount*2 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.GDEF_E_LigGlyphTable_CaretValueArray_PastEOT, table.m_tag, sIdentity);
                    bRet = false;
                }

                bool bOffsetsOk = true;
                for (uint i=0; i<CaretCount; i++)
                {
                    if (m_offsetLigGlyphTable + GetCaretValueOffset(i) > m_bufTable.GetLength())
                    {
                        v.Error(T.T_NULL, E.GDEF_E_LigGlyphTable_CaretValueOffset, table.m_tag, sIdentity);
                        bOffsetsOk = false;
                        bRet = false;
                    }
                }
                if (bOffsetsOk)
                {
                    v.Pass(T.T_NULL, P.GDEF_P_LigGlyphTable_CaretValueArray, table.m_tag, sIdentity);
                }

                for (uint i=0; i<CaretCount; i++)
                {
                    CaretValueTable cvt = GetCaretValueTable(i);
                    if (cvt.CaretValueFormat < 1 || cvt.CaretValueFormat > 3)
                    {
                        v.Error(T.T_NULL, E.GDEF_E_CaretValueTable_Format, table.m_tag, sIdentity + ", CaretValue[" + i + "], format = " + cvt.CaretValueFormat);
                        bRet = false;
                    }
                }

                return bRet;
            }
Esempio n. 14
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetMinMaxTable, CalcLength(), v, sIdentity, table.GetTag());

                // check the MinCoordOffset
                if (MinCoordOffset == 0)
                {
                    v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MinCO_0, table.m_tag, sIdentity);
                }
                else if (MinCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.BASE_E_MinMaxTable_MinCO, table.m_tag, sIdentity);
                    bRet = false;
                }
                else
                {
                    v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MinCO, table.m_tag, sIdentity);
                }

                // check the MaxCoordOffset
                if (MaxCoordOffset == 0)
                {
                    v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MaxCO_0, table.m_tag, sIdentity);
                }
                else if (MaxCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.BASE_E_MinMaxTable_MaxCO, table.m_tag, sIdentity);
                    bRet = false;
                }
                else
                {
                    v.Pass(T.T_NULL, P.BASE_P_MinMaxTable_MaxCO, table.m_tag, sIdentity);
                }

                // check the FeatMinMaxRecords
                bool bFeatMinMaxRecordsOk = true;

                for (uint i = 0; i < FeatMinMaxCount; i++)
                {
                    FeatMinMaxRecord fmmr = GetFeatMinMaxRecord(i);

                    if (fmmr != null)
                    {
                        if (fmmr.MinCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength())
                        {
                            v.Error(T.T_NULL, E.BASE_E_FeatMinMaxRecords_MinCO_offset, table.m_tag, sIdentity + ", FeatMinMaxRecord[" + i + "]");
                            bFeatMinMaxRecordsOk = false;
                            bRet = false;
                        }

                        if (fmmr.MaxCoordOffset + m_offsetMinMaxTable > m_bufTable.GetLength())
                        {
                            v.Error(T.T_NULL, E.BASE_E_FeatMinMaxRecords_MaxCO_offset, table.m_tag, sIdentity + ", FeatMinMaxRecord[" + i + "]");
                            bFeatMinMaxRecordsOk = false;
                            bRet = false;
                        }
                    }
                    else
                    {
                        bFeatMinMaxRecordsOk = false;
                    }
                }
                if (bFeatMinMaxRecordsOk)
                {
                    v.Pass(T.T_NULL, P.BASE_P_FeatMinMaxRecords_offsets, table.m_tag, sIdentity);
                }

                // check the BaseCoord Tables
                BaseCoordTable_val bct = null;

                bct = GetMinCoordTable_val();
                if (bct != null)
                {
                    bct.Validate(v, sIdentity, table);
                }

                bct = GetMaxCoordTable_val();
                if (bct != null)
                {
                    bct.Validate(v, sIdentity, table);
                }
                for (uint i = 0; i < FeatMinMaxCount; i++)
                {
                    FeatMinMaxRecord fmmr = GetFeatMinMaxRecord(i);

                    bct = GetFeatMinCoordTable_val(fmmr);
                    if (bct != null)
                    {
                        bct.Validate(v, sIdentity, table);
                    }

                    bct = GetFeatMaxCoordTable_val(fmmr);
                    if (bct != null)
                    {
                        bct.Validate(v, sIdentity, table);
                    }
                }

                return(bRet);
            }
Esempio n. 15
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                // check for data overlap
                bRet &= ((val_JSTF)table).ValidateNoOverlap(m_offsetJstfGPOSModList, CalcLength(), v, sIdentity, table.GetTag());

                // check GPOSLookupIndex array size
                if (m_offsetJstfGPOSModList + (uint)FieldOffsets.GPOSLookupIndex + LookupCount * 2 > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.JSTF_E_Array_pastEOT, table.m_tag, sIdentity + ", GPOSLookupIndex");
                    bRet = false;
                }

                // check that GPOSLookupIndex is in increasing numerical order
                if (LookupCount > 1)
                {
                    for (uint i = 0; i < LookupCount - 1; i++)
                    {
                        if (GetGPOSLookupIndex(i) >= GetGPOSLookupIndex(i + 1))
                        {
                            v.Error(T.T_NULL, E.JSTF_E_Array_order, table.m_tag, sIdentity + ", GPOSLookupIndex");
                            bRet = false;
                            break;
                        }
                    }
                }

                return(bRet);
            }
Esempio n. 16
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                bRet &= ((val_BASE)table).ValidateNoOverlap(m_offsetBaseCoordTable, CalcLength(), v, sIdentity, table.GetTag());

                if (BaseCoordFormat == 1 || BaseCoordFormat == 2 || BaseCoordFormat == 3)
                {
                    v.Pass(T.T_NULL, P.BASE_P_BaseCoordTable_format, table.m_tag, sIdentity);
                }
                else
                {
                    v.Error(T.T_NULL, E.BASE_E_BaseCoordTable_format, table.m_tag, sIdentity + ", format = " + BaseCoordFormat);
                }

                return(bRet);
            }
Esempio n. 17
0
        static byte[] get_TTF_digest(OTFile f)
        {
            OTFont         fn     = f.GetFont(0);
            Table_DSIG     tDSIG  = (Table_DSIG)fn.GetTable("DSIG");
            DirectoryEntry deDSIG = null;
            // sort table by offset
            Dictionary <uint, int> offsetlookup = new Dictionary <uint, int>();
            var list = new List <uint>();

            for (ushort i = 0; i < fn.GetNumTables(); i++)
            {
                DirectoryEntry de = fn.GetDirectoryEntry(i);
                offsetlookup.Add(de.offset, i);
                list.Add(de.offset);
                if ((string)de.tag == "DSIG")
                {
                    deDSIG = de;
                }
            }
            list.Sort();

            // New offset table
            var         old_ot = fn.GetOffsetTable();
            OffsetTable ot     = new OffsetTable(old_ot.sfntVersion, (ushort)(old_ot.numTables - 1));

            for (ushort i = 0; i < fn.GetNumTables(); i++)
            {
                DirectoryEntry oldde = fn.GetDirectoryEntry(i);
                if ((string)oldde.tag != "DSIG")
                {
                    DirectoryEntry de = new DirectoryEntry(oldde);
                    de.offset -= 16; // one less entry
                    if (de.offset > deDSIG.offset)
                    {
                        de.offset -= tDSIG.GetBuffer().GetPaddedLength();
                    }
                    ot.DirectoryEntries.Add(de);
                }
            }
            hash.TransformBlock(ot.m_buf.GetBuffer(), 0, (int)ot.m_buf.GetLength(), ot.m_buf.GetBuffer(), 0);

            for (int i = 0; i < ot.DirectoryEntries.Count; i++)
            {
                DirectoryEntry de = (DirectoryEntry)ot.DirectoryEntries[i];
                hash.TransformBlock(de.m_buf.GetBuffer(), 0, (int)de.m_buf.GetLength(), de.m_buf.GetBuffer(), 0);
            }

            Table_head headTable = (Table_head)fn.GetTable("head");

            // calculate the checksum
            uint sum = 0;

            sum += ot.CalcOffsetTableChecksum();
            sum += ot.CalcDirectoryEntriesChecksum();
            foreach (var key in list)
            {
                OTTable table = fn.GetTable((ushort)offsetlookup[key]);

                if ((string)table.GetTag() != "DSIG")
                {
                    sum += table.CalcChecksum();
                }
            }

            Table_head.head_cache headCache = (Table_head.head_cache)headTable.GetCache();

            // set the checkSumAdujustment field
            headCache.checkSumAdjustment = 0xb1b0afba - sum;
            Table_head newHead = (Table_head)headCache.GenerateTable();

            foreach (var key in list)
            {
                OTTable table = fn.GetTable((ushort)offsetlookup[key]);

                if ((string)table.GetTag() == "head")
                {
                    table = newHead;
                }

                if ((string)table.GetTag() != "DSIG")
                {
                    hash.TransformBlock(table.m_bufTable.GetBuffer(), 0, (int)table.GetBuffer().GetPaddedLength(),
                                        table.m_bufTable.GetBuffer(), 0);
                }
            }

            byte[] usFlag = { 0, 1 };
            hash.TransformFinalBlock(usFlag, 0, 2);
            return(hash.Hash);
        }