Exemple #1
0
        public JstfScriptRecord GetJstfScriptRecord(uint i)
        {
            JstfScriptRecord jsr = null;

            if (i < JstfScriptCount)
            {
                uint offset = (uint)FieldOffsets.JstfScriptRecords + i * 6;
                jsr = new JstfScriptRecord((ushort)offset, m_bufTable);
            }

            return(jsr);
        }
Exemple #2
0
        public List <JstfScriptRecord> jstfScriptRecords; // Array of JstfScriptRecords, in alphabetical order by jstfScriptTag

        public void Read(TTFReader r)
        {
            r.ReadInt(out this.majorVersion);
            r.ReadInt(out this.minorVersion);
            r.ReadInt(out this.jsftScriptCount);

            this.jstfScriptRecords = new List <JstfScriptRecord>();
            for (int i = 0; i < jsftScriptCount; ++i)
            {
                JstfScriptRecord rec = new JstfScriptRecord();
                rec.Read(r);
                this.jstfScriptRecords.Add(rec);
            }
        }
Exemple #3
0
        //The Justification table(JSTF) provides font developers with additional control over glyph substitution and
        //positioning in justified text.

        //Text-processing clients now have more options to expand or
        //shrink word and glyph spacing so text fills the specified line length.

        protected override void ReadContentFrom(BinaryReader reader)
        {
            //test this with Arial font

            //JSTF header
            //Type              Name                                Description
            //uint16            majorVersion                        Major version of the JSTF table, = 1
            //uint16            minorVersion                        Minor version of the JSTF table, = 0
            //uint16            jstfScriptCount                     Number of JstfScriptRecords in this table
            //JstfScriptRecord  jstfScriptRecords[jstfScriptCount]  Array of JstfScriptRecords, in alphabetical order by jstfScriptTag

            //----------
            //JstfScriptRecord
            //Type              Name                Description
            //Tag               jstfScriptTag       4-byte JstfScript identification
            //Offset16          jstfScriptOffset    Offset to JstfScript table, from beginning of JSTF Header

            long tableStartAt = reader.BaseStream.Position;
            //
            ushort majorVersion    = reader.ReadUInt16();
            ushort minorVersion    = reader.ReadUInt16();
            ushort jstfScriptCount = reader.ReadUInt16();

            JstfScriptRecord[] recs = new JstfScriptRecord[jstfScriptCount];
            for (int i = 0; i < recs.Length; ++i)
            {
                recs[i] = new JstfScriptRecord(
                    Utils.TagToString(reader.ReadUInt32()),
                    reader.ReadUInt16()
                    );
            }

            _jsftScriptTables = new JstfScriptTable[recs.Length];
            for (int i = 0; i < recs.Length; ++i)
            {
                JstfScriptRecord rec = recs[i];
                reader.BaseStream.Position = tableStartAt + rec.jstfScriptOffset;

                JstfScriptTable jstfScriptTable = ReadJstfScriptTable(reader);
                jstfScriptTable.ScriptTag = rec.jstfScriptTag;
                _jsftScriptTables[i]      = jstfScriptTable;
            }
        }
Exemple #4
0
        public bool Validate(Validator v, OTFontVal fontOwner)
        {
            bool bRet = true;


            // check the version
            if (v.PerformTest(T.JSTF_Version))
            {
                if (Version.GetUint() == 0x00010000)
                {
                    v.Pass(T.JSTF_Version, P.JSTF_P_Version, m_tag);
                }
                else
                {
                    v.Error(T.JSTF_Version, E.JSTF_E_Version, m_tag, "0x" + Version.GetUint().ToString("x8"));
                    bRet = false;
                }
            }

            // check the JstfScriptRecord array length
            if (v.PerformTest(T.JSTF_JstfScriptRecord_length))
            {
                if ((uint)FieldOffsets.JstfScriptRecords + JstfScriptCount * 6 > m_bufTable.GetLength())
                {
                    v.Error(T.JSTF_JstfScriptRecord_length, E.JSTF_E_Array_pastEOT, m_tag, "JstfScriptRecord array");
                    bRet = false;
                }
            }

            // check that the JstfScriptRecord array is in alphabetical order
            if (v.PerformTest(T.JSTF_JstfScriptRecord_order))
            {
                if (JstfScriptCount > 1)
                {
                    for (uint i = 0; i < JstfScriptCount - 1; i++)
                    {
                        JstfScriptRecord jsrCurr = GetJstfScriptRecord_val(i);
                        JstfScriptRecord jsrNext = GetJstfScriptRecord_val(i + 1);

                        if (jsrCurr.JstfScriptTag >= jsrNext.JstfScriptTag)
                        {
                            v.Error(T.JSTF_JstfScriptRecord_order, E.JSTF_E_Array_order, m_tag, "JstfScriptRecord array");
                            bRet = false;
                            break;
                        }
                    }
                }
            }

            // check each JstfScriptRecord
            if (v.PerformTest(T.JSTF_JstfScriptRecords))
            {
                for (uint i = 0; i < JstfScriptCount; i++)
                {
                    JstfScriptRecord_val jsr = GetJstfScriptRecord_val(i);

                    // check the tag
                    if (!jsr.JstfScriptTag.IsValid())
                    {
                        v.Error(T.JSTF_JstfScriptRecords, E.JSTF_E_tag, m_tag, "JstfScriptRecord[" + i + "]");
                        bRet = false;
                    }

                    // check the offset
                    if (jsr.JstfScriptOffset > m_bufTable.GetLength())
                    {
                        v.Error(T.JSTF_JstfScriptRecords, E.JSTF_E_Offset_PastEOT, m_tag, "JstfScriptRecord[" + i + "]");
                        bRet = false;
                    }

                    // validate the JstfScript table
                    JstfScript_val js = jsr.GetJstfScriptTable_val();
                    js.Validate(v, "JstfScriptRecord[" + i + "]", this);
                }
            }

            return(bRet);
        }
        public JstfScriptRecord GetJstfScriptRecord(uint i)
        {
            JstfScriptRecord jsr = null;

            if (i < JstfScriptCount)
            {
                uint offset = (uint)FieldOffsets.JstfScriptRecords + i*6;
                jsr = new JstfScriptRecord((ushort)offset, m_bufTable);
            }

            return jsr;
        }