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); }
//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; } }