예제 #1
0
            public MinMaxTable_val GetMinMaxTable_val(BaseLangSysRecord blsr)
            {
                MinMaxTable_val mmt = null;

                if (blsr != null)
                {
                    ushort offset = (ushort)(m_offsetBaseScriptTable + blsr.MinMaxOffset);
                    mmt = new MinMaxTable_val(offset, m_bufTable);
                }

                return(mmt);
            }
예제 #2
0
            public BaseLangSysRecord GetBaseLangSysRecord(uint i)
            {
                BaseLangSysRecord blsr = null;

                if (i < BaseLangSysCount)
                {
                    ushort sizeofBaseLangSysRecord = 6;
                    ushort offset = (ushort)(m_offsetBaseScriptTable + (uint)FieldOffsets.BaseLangSysRecords + sizeofBaseLangSysRecord * i);
                    blsr = new BaseLangSysRecord(offset, m_bufTable);
                }

                return(blsr);
            }
예제 #3
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);
            }
예제 #4
0
        static BaseScript ReadBaseScriptTable(BinaryReader reader)
        {
            //BaseScript Table
            //A BaseScript table organizes and specifies the baseline data and min/max extent data for one script.
            //Within a BaseScript table, the BaseValues table contains baseline information,
            //and one or more MinMax tables contain min/max extent data
            //....

            //A BaseScript table has four components:
            //...

            long baseScriptTableStartAt = reader.BaseStream.Position;

            //BaseScript Table
            //Type                  Name                                    Description
            //Offset16              baseValuesOffset                        Offset to BaseValues table, from beginning of BaseScript table (may be NULL)
            //Offset16              defaultMinMaxOffset                     Offset to MinMax table, from beginning of BaseScript table (may be NULL)
            //uint16                baseLangSysCount                        Number of BaseLangSysRecords defined — may be zero (0)
            //BaseLangSysRecord     baseLangSysRecords[baseLangSysCount]    Array of BaseLangSysRecords, in alphabetical order by BaseLangSysTag

            ushort baseValueOffset     = reader.ReadUInt16();
            ushort defaultMinMaxOffset = reader.ReadUInt16();
            ushort baseLangSysCount    = reader.ReadUInt16();

            BaseLangSysRecord[] baseLangSysRecords = null;

            if (baseLangSysCount > 0)
            {
                baseLangSysRecords = new BaseLangSysRecord[baseLangSysCount];
                for (int i = 0; i < baseLangSysCount; ++i)
                {
                    //BaseLangSysRecord
                    //A BaseLangSysRecord defines min/max extents for a language system or a language-specific feature.
                    //Each record contains an identification tag for the language system (baseLangSysTag) and an offset to a MinMax table (MinMax)
                    //that defines extent coordinate values for the language system and references feature-specific extent data.

                    //BaseLangSysRecord
                    //Type          Name            Description
                    //Tag           baseLangSysTag  4-byte language system identification tag
                    //Offset16      minMaxOffset    Offset to MinMax table, from beginning of BaseScript table
                    baseLangSysRecords[i] = new BaseLangSysRecord(ConvertToTagString(reader.ReadBytes(4)), reader.ReadUInt16());
                }
            }

            BaseScript baseScript = new BaseScript();

            baseScript.baseLangSysRecords = baseLangSysRecords;
            //--------------------
            if (baseValueOffset > 0)
            {
                reader.BaseStream.Position = baseScriptTableStartAt + baseValueOffset;
                baseScript.baseValues      = ReadBaseValues(reader);
            }
            if (defaultMinMaxOffset > 0)
            {
                reader.BaseStream.Position = baseScriptTableStartAt + defaultMinMaxOffset;
                baseScript.MinMax          = ReadMinMaxTable(reader);
            }

            return(baseScript);
        }
예제 #5
0
            public MinMaxTable GetMinMaxTable(BaseLangSysRecord blsr)
            {
                MinMaxTable mmt = null;

                if (blsr != null)
                {
                    ushort offset = (ushort)(m_offsetBaseScriptTable + blsr.MinMaxOffset);
                    mmt = new MinMaxTable(offset, m_bufTable);
                }

                return mmt;
            }
예제 #6
0
            public BaseLangSysRecord GetBaseLangSysRecord(uint i)
            {
                BaseLangSysRecord blsr = null;

                if (i < BaseLangSysCount)
                {
                    ushort sizeofBaseLangSysRecord = 6;
                    ushort offset = (ushort)(m_offsetBaseScriptTable + (uint)FieldOffsets.BaseLangSysRecords + sizeofBaseLangSysRecord*i);
                    blsr = new BaseLangSysRecord(offset, m_bufTable);
                }

                return blsr;
            }