Beispiel #1
0
        static JstfScriptTable ReadJstfScriptTable(BinaryReader reader)
        {
            //A Justification Script(JstfScript) table describes the justification information for a single script.
            //It consists of an offset to a table that defines extender glyphs(extenderGlyphOffset),
            //an offset to a default justification table for the script (defJstfLangSysOffset),
            //and a count of the language systems that define justification data(jstfLangSysCount).

            //If a script uses the same justification information for all language systems,
            //the font developer defines only the default JstfLangSys table and
            //sets the jstfLangSysCount value to zero(0).

            //However, if any language system has unique justification suggestions,
            //jstfLangSysCount will be a positive value,
            //and the JstfScript table must include an array of records(jstfLangSysRecords),
            //one for each language system.Each JstfLangSysRecord contains a language system tag(jstfLangSysTag) and
            //an offset to a justification language system table(jstfLangSysOffset).

            //In the jstfLangSysRecords array, records are ordered alphabetically by jstfLangSysTag.

            //JstfScript table
            //Type              Name                            Description
            //Offset16          extenderGlyphOffset             Offset to ExtenderGlyph table, from beginning of JstfScript table(may be NULL)
            //Offset16          defJstfLangSysOffset            Offset to default JstfLangSys table, from beginning of JstfScript table(may be NULL)
            //uint16            jstfLangSysCount                Number of JstfLangSysRecords in this table - may be zero(0)
            //JstfLangSysRecord jstfLangSysRecords[jstfLangSysCount]    Array of JstfLangSysRecords, in alphabetical order by JstfLangSysTag

            JstfScriptTable jstfScriptTable = new JstfScriptTable();

            long tableStartAt = reader.BaseStream.Position;

            ushort extenderGlyphOffset  = reader.ReadUInt16();
            ushort defJstfLangSysOffset = reader.ReadUInt16();
            ushort jstfLangSysCount     = reader.ReadUInt16();

            if (jstfLangSysCount > 0)
            {
                JstfLangSysRecord[] recs = new JstfLangSysRecord[jstfLangSysCount];
                for (int i = 0; i < jstfLangSysCount; ++i)
                {
                    recs[i] = ReadJstfLangSysRecord(reader);
                }
                jstfScriptTable.other = recs;
            }


            if (extenderGlyphOffset > 0)
            {
                reader.BaseStream.Position     = tableStartAt + extenderGlyphOffset;
                jstfScriptTable.extenderGlyphs = ReadExtenderGlyphTable(reader);
            }

            if (defJstfLangSysOffset > 0)
            {
                reader.BaseStream.Position     = tableStartAt + defJstfLangSysOffset;
                jstfScriptTable.defaultLangSys = ReadJstfLangSysRecord(reader);
            }
            return(jstfScriptTable);
        }
Beispiel #2
0
            public JstfLangSysRecord GetJstfLangSysRecord(uint i)
            {
                JstfLangSysRecord jlsr = null;

                if (i < JstfLangSysCount)
                {
                    uint offset = m_offsetJstfScript + (uint)FieldOffsets.JstfLangSysRecords + i * 6;
                    jlsr = new JstfLangSysRecord((ushort)offset, m_bufTable);
                }

                return(jlsr);
            }
Beispiel #3
0
            public JstfLangSys_val GetJstfLangSysTable_val(JstfLangSysRecord jlsr)
            {
                uint offset = m_offsetJstfScript + (uint)jlsr.JstfLangSysOffset;

                return(new JstfLangSys_val((ushort)offset, m_bufTable));
            }
Beispiel #4
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);
            }
Beispiel #5
0
 public JstfLangSys_val GetJstfLangSysTable_val(JstfLangSysRecord jlsr)
 {
     uint offset = m_offsetJstfScript + (uint)jlsr.JstfLangSysOffset;
     return new JstfLangSys_val((ushort)offset, m_bufTable);
 }
Beispiel #6
0
            public JstfLangSysRecord GetJstfLangSysRecord(uint i)
            {
                JstfLangSysRecord jlsr = null;

                if (i < JstfLangSysCount)
                {
                    uint offset = m_offsetJstfScript + (uint)FieldOffsets.JstfLangSysRecords + i*6;
                    jlsr = new JstfLangSysRecord((ushort)offset, m_bufTable);
                }

                return jlsr;
            }