Exemplo n.º 1
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);
            }
Exemplo n.º 2
0
            public BaseScriptTable_val GetBaseScriptTable_val(BaseScriptRecord bsr)
            {
                BaseScriptTable_val bst = null;

                if (bsr != null)
                {
                    ushort offset = (ushort)(m_offsetBaseScriptListTable + bsr.BaseScriptOffset);
                    bst = new BaseScriptTable_val(offset, m_bufTable);
                }
                return(bst);
            }
Exemplo n.º 3
0
            public BaseScriptRecord GetBaseScriptRecord(uint i)
            {
                BaseScriptRecord bsr = null;

                if (i < BaseScriptCount)
                {
                    uint sizeofRecord = 6;
                    uint offsetRecord = m_offsetBaseScriptListTable + (uint)FieldOffsets.BaseScriptRecordArray + i * sizeofRecord;
                    bsr = new BaseScriptRecord((ushort)offsetRecord, m_bufTable);
                }

                return(bsr);
            }
Exemplo n.º 4
0
        static BaseScript[] ReadBaseScriptList(BinaryReader reader)
        {
            //BaseScriptList Table

            //The BaseScriptList table identifies all scripts in the font that are rendered in the same layout direction.
            //If a script is not listed here, then
            //the text-processing client will render the script using the layout information specified for the entire font.

            //For each script listed in the BaseScriptList table,
            //a BaseScriptRecord must be defined that identifies the script and references its layout data.
            //BaseScriptRecords are stored in the baseScriptRecords array, ordered alphabetically by the baseScriptTag in each record.
            //The baseScriptCount specifies the total number of BaseScriptRecords in the array.

            //BaseScriptList table
            //Type              Name                                Description
            //uint16            baseScriptCount                     Number of BaseScriptRecords defined
            //BaseScriptRecord  baseScriptRecords[baseScriptCount]  Array of BaseScriptRecords, in alphabetical order by baseScriptTag

            long   baseScriptListStartAt = reader.BaseStream.Position;
            ushort baseScriptCount       = reader.ReadUInt16();

            BaseScriptRecord[] baseScriptRecord_offsets = new BaseScriptRecord[baseScriptCount];
            for (int i = 0; i < baseScriptCount; ++i)
            {
                //BaseScriptRecord

                //A BaseScriptRecord contains a script identification tag (baseScriptTag),
                //which must be identical to the ScriptTag used to define the script in the ScriptList of a GSUB or GPOS table.
                //Each record also must include an offset to a BaseScript table that defines the baseline and min/max extent data for the script.

                //BaseScriptRecord
                //Type      Name                Description
                //Tag       baseScriptTag       4-byte script identification tag
                //Offset16  baseScriptOffset    Offset to BaseScript table, from beginning of BaseScriptList
                baseScriptRecord_offsets[i] = new BaseScriptRecord(ConvertToTagString(reader.ReadBytes(4)), reader.ReadUInt16());
            }
            BaseScript[] baseScripts = new BaseScript[baseScriptCount];
            for (int i = 0; i < baseScriptCount; ++i)
            {
                BaseScriptRecord baseScriptRecord = baseScriptRecord_offsets[i];
                reader.BaseStream.Position = baseScriptListStartAt + baseScriptRecord.baseScriptOffset;
                //
                BaseScript baseScipt = ReadBaseScriptTable(reader);
                baseScipt.ScriptIdenTag = baseScriptRecord.baseScriptTag;
                baseScripts[i]          = baseScipt;
            }
            return(baseScripts);
        }
Exemplo n.º 5
0
 public BaseScriptTable GetBaseScriptTable(BaseScriptRecord bsr)
 {
     BaseScriptTable bst = null;
     if (bsr != null)
     {
         ushort offset = (ushort)(m_offsetBaseScriptListTable + bsr.BaseScriptOffset);
         bst = new BaseScriptTable(offset, m_bufTable);
     }
     return bst;
 }
Exemplo n.º 6
0
            public BaseScriptRecord GetBaseScriptRecord(uint i)
            {
                BaseScriptRecord bsr = null;

                if (i < BaseScriptCount)
                {
                    uint sizeofRecord = 6;
                    uint offsetRecord = m_offsetBaseScriptListTable + (uint)FieldOffsets.BaseScriptRecordArray + i*sizeofRecord;
                    bsr = new BaseScriptRecord((ushort)offsetRecord, m_bufTable);
                }

                return bsr;
            }