예제 #1
0
        public override SubTable GetSubTable(uint i)
        {
            if (i >= SubTableCount)
            {
                throw new ArgumentOutOfRangeException();
            }

            SubTable st = null;
            uint stOffset = m_offsetLookupTable + (uint)GetSubTableOffset(i);

            if ((string)m_tag == "GPOS")
            {
                switch (LookupType)
                {
                    case 1: st = new val_GPOS.SinglePos_val      (stOffset, m_bufTable); break;
                    case 2: st = new val_GPOS.PairPos_val        (stOffset, m_bufTable); break;
                    case 3: st = new val_GPOS.CursivePos_val     (stOffset, m_bufTable); break;
                    case 4: st = new val_GPOS.MarkBasePos_val    (stOffset, m_bufTable); break;
                    case 5: st = new val_GPOS.MarkLigPos_val     (stOffset, m_bufTable); break;
                    case 6: st = new val_GPOS.MarkMarkPos_val    (stOffset, m_bufTable); break;
                    case 7: st = new val_GPOS.ContextPos_val     (stOffset, m_bufTable); break;
                    case 8: st = new val_GPOS.ChainContextPos_val(stOffset, m_bufTable); break;
                    case 9: st = new val_GPOS.ExtensionPos_val   (stOffset, m_bufTable); break;
                }
            }
            else if ((string)m_tag == "GSUB")
            {
                switch (LookupType)
                {
                    case 1: st = new val_GSUB.SingleSubst_val      (stOffset, m_bufTable); break;
                    case 2: st = new val_GSUB.MultipleSubst_val    (stOffset, m_bufTable); break;
                    case 3: st = new val_GSUB.AlternateSubst_val   (stOffset, m_bufTable); break;
                    case 4: st = new val_GSUB.LigatureSubst_val    (stOffset, m_bufTable); break;
                    case 5: st = new val_GSUB.ContextSubst_val     (stOffset, m_bufTable); break;
                    case 6: st = new val_GSUB.ChainContextSubst_val(stOffset, m_bufTable); break;
                    case 7: st = new val_GSUB.ExtensionSubst_val   (stOffset, m_bufTable); break;
                    case 8: st = new val_GSUB.ReverseChainSubst_val(stOffset, m_bufTable); break;
                }
            }
            else
            {
                throw new InvalidOperationException("unknown table type");
            }

            return st;
        }
예제 #2
0
            public bool Validate(Validator v, string sIdentity, OTTable table)
            {
                bool bRet = true;

                sIdentity += "(ExtensionSubst)";

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

                // check the SubstFormat
                if (SubstFormat != 1)
                {
                    v.Error(T.T_NULL, E.GSUB_E_SubtableFormat, table.m_tag, sIdentity + ", SubstFormat = " + SubstFormat);
                    bRet = false;
                }

                // check the ExtensionLookupType
                if (ExtensionLookupType >= 7)
                {
                    v.Error(T.T_NULL, E.GSUB_E_ExtensionLookupType, table.m_tag, sIdentity + ", ExtensionLookupType = " + ExtensionLookupType);
                    bRet = false;
                }

                // check the ExtensionOffset
                if (m_offsetExtensionSubst + ExtensionOffset > m_bufTable.GetLength())
                {
                    v.Error(T.T_NULL, E.GSUB_E_Offset_PastEOT, table.m_tag, sIdentity + ", ExtensionOffset");
                    bRet = false;
                }

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

                // validate the subtable
                SubTable st = null;
                switch (ExtensionLookupType)
                {
                    case 1: st = new val_GSUB.SingleSubst_val      (m_offsetExtensionSubst + ExtensionOffset, m_bufTable); break;
                    case 2: st = new val_GSUB.MultipleSubst_val    (m_offsetExtensionSubst + ExtensionOffset, m_bufTable); break;
                    case 3: st = new val_GSUB.AlternateSubst_val   (m_offsetExtensionSubst + ExtensionOffset, m_bufTable); break;
                    case 4: st = new val_GSUB.LigatureSubst_val    (m_offsetExtensionSubst + ExtensionOffset, m_bufTable); break;
                    case 5: st = new val_GSUB.ContextSubst_val     (m_offsetExtensionSubst + ExtensionOffset, m_bufTable); break;
                    case 6: st = new val_GSUB.ChainContextSubst_val(m_offsetExtensionSubst + ExtensionOffset, m_bufTable); break;

                }
                if (st != null)
                {
                    I_OTLValidate iv = (I_OTLValidate)st;
                    iv.Validate(v, sIdentity, table);
                }

                return bRet;
            }