Exemplo n.º 1
0
            /// <exception cref="System.IO.IOException"/>
            protected internal virtual void ReadFormat(int subTableLocation)
            {
                int coverage     = openReader.rf.ReadUnsignedShort() + subTableLocation;
                int valueFormat1 = openReader.rf.ReadUnsignedShort();
                int valueFormat2 = openReader.rf.ReadUnsignedShort();
                int pairSetCount = openReader.rf.ReadUnsignedShort();

                int[]       locationRule = openReader.ReadUShortArray(pairSetCount, subTableLocation);
                IList <int> coverageList = openReader.ReadCoverageFormat(coverage);

                for (int k = 0; k < pairSetCount; ++k)
                {
                    openReader.rf.Seek(locationRule[k]);
                    IDictionary <int, GposLookupType2.PairValueFormat> pairs = new Dictionary <int, GposLookupType2.PairValueFormat
                                                                                               >();
                    gposMap.Put(coverageList[k], pairs);
                    int pairValueCount = openReader.rf.ReadUnsignedShort();
                    for (int j = 0; j < pairValueCount; ++j)
                    {
                        int glyph2 = openReader.rf.ReadUnsignedShort();
                        GposLookupType2.PairValueFormat pair = new GposLookupType2.PairValueFormat();
                        pair.first  = OtfReadCommon.ReadGposValueRecord(openReader, valueFormat1);
                        pair.second = OtfReadCommon.ReadGposValueRecord(openReader, valueFormat2);
                        pairs.Put(glyph2, pair);
                    }
                }
            }
Exemplo n.º 2
0
            /// <exception cref="System.IO.IOException"/>
            protected internal virtual void ReadFormat(int subTableLocation)
            {
                int coverage       = openReader.rf.ReadUnsignedShort() + subTableLocation;
                int valueFormat1   = openReader.rf.ReadUnsignedShort();
                int valueFormat2   = openReader.rf.ReadUnsignedShort();
                int locationClass1 = openReader.rf.ReadUnsignedShort() + subTableLocation;
                int locationClass2 = openReader.rf.ReadUnsignedShort() + subTableLocation;
                int class1Count    = openReader.rf.ReadUnsignedShort();
                int class2Count    = openReader.rf.ReadUnsignedShort();

                for (int k = 0; k < class1Count; ++k)
                {
                    GposLookupType2.PairValueFormat[] pairs = new GposLookupType2.PairValueFormat[class2Count];
                    posSubs.Put(k, pairs);
                    for (int j = 0; j < class2Count; ++j)
                    {
                        GposLookupType2.PairValueFormat pair = new GposLookupType2.PairValueFormat();
                        pair.first  = OtfReadCommon.ReadGposValueRecord(openReader, valueFormat1);
                        pair.second = OtfReadCommon.ReadGposValueRecord(openReader, valueFormat2);
                        pairs[j]    = pair;
                    }
                }
                coverageSet = new HashSet <int>(openReader.ReadCoverageFormat(coverage));
                classDef1   = openReader.ReadClassDefinition(locationClass1);
                classDef2   = openReader.ReadClassDefinition(locationClass2);
            }
Exemplo n.º 3
0
        /// <exception cref="System.IO.IOException"/>
        protected internal override void ReadSubTable(int subTableLocation)
        {
            openReader.rf.Seek(subTableLocation);
            openReader.rf.ReadUnsignedShort();
            //skip format, always 1
            int                   markCoverageLocation     = openReader.rf.ReadUnsignedShort() + subTableLocation;
            int                   ligatureCoverageLocation = openReader.rf.ReadUnsignedShort() + subTableLocation;
            int                   classCount            = openReader.rf.ReadUnsignedShort();
            int                   markArrayLocation     = openReader.rf.ReadUnsignedShort() + subTableLocation;
            int                   ligatureArrayLocation = openReader.rf.ReadUnsignedShort() + subTableLocation;
            IList <int>           markCoverage          = openReader.ReadCoverageFormat(markCoverageLocation);
            IList <int>           ligatureCoverage      = openReader.ReadCoverageFormat(ligatureCoverageLocation);
            IList <OtfMarkRecord> markRecords           = OtfReadCommon.ReadMarkArray(openReader, markArrayLocation);

            GposLookupType5.MarkToLigature markToLigature = new GposLookupType5.MarkToLigature();
            for (int k = 0; k < markCoverage.Count; ++k)
            {
                markToLigature.marks[markCoverage[k]] = markRecords[k];
            }
            IList <IList <GposAnchor[]> > ligatureArray = OtfReadCommon.ReadLigatureArray(openReader, classCount, ligatureArrayLocation
                                                                                          );

            for (int k_1 = 0; k_1 < ligatureCoverage.Count; ++k_1)
            {
                markToLigature.ligatures[ligatureCoverage[k_1]] = ligatureArray[k_1];
            }
            marksligatures.Add(markToLigature);
        }
Exemplo n.º 4
0
        /// <exception cref="System.IO.IOException"/>
        protected internal override void ReadSubTable(int subTableLocation)
        {
            openReader.rf.Seek(subTableLocation);
            openReader.rf.ReadUnsignedShort();
            //skip format, always 1
            int                   markCoverageLocation = openReader.rf.ReadUnsignedShort() + subTableLocation;
            int                   baseCoverageLocation = openReader.rf.ReadUnsignedShort() + subTableLocation;
            int                   classCount           = openReader.rf.ReadUnsignedShort();
            int                   markArrayLocation    = openReader.rf.ReadUnsignedShort() + subTableLocation;
            int                   baseArrayLocation    = openReader.rf.ReadUnsignedShort() + subTableLocation;
            IList <int>           markCoverage         = openReader.ReadCoverageFormat(markCoverageLocation);
            IList <int>           baseCoverage         = openReader.ReadCoverageFormat(baseCoverageLocation);
            IList <OtfMarkRecord> markRecords          = OtfReadCommon.ReadMarkArray(openReader, markArrayLocation);

            GposLookupType4.MarkToBase markToBase = new GposLookupType4.MarkToBase();
            for (int k = 0; k < markCoverage.Count; ++k)
            {
                markToBase.marks.Put(markCoverage[k], markRecords[k]);
            }
            IList <GposAnchor[]> baseArray = OtfReadCommon.ReadBaseArray(openReader, classCount, baseArrayLocation);

            for (int k = 0; k < baseCoverage.Count; ++k)
            {
                markToBase.bases.Put(baseCoverage[k], baseArray[k]);
            }
            marksbases.Add(markToBase);
        }
Exemplo n.º 5
0
        public virtual void TestReadCoverageFormat2()
        {
            // Based on Example 6 from the specification
            // https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2
            // 0002 0001 A04E A057 0000
            String path = RESOURCE_FOLDER + "coverage-format-2.bin";
            RandomAccessFileOrArray rf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateBestSource(
                                                                         path));
            IList <int> glyphIds = OtfReadCommon.ReadCoverageFormat(rf, 0);

            NUnit.Framework.Assert.AreEqual(10, glyphIds.Count);
            NUnit.Framework.Assert.AreEqual(0xA04E, (int)glyphIds[0]);
            NUnit.Framework.Assert.AreEqual(0xA057, (int)glyphIds[9]);
        }
Exemplo n.º 6
0
        protected internal override void ReadSubTable(int subTableLocation)
        {
            openReader.rf.Seek(subTableLocation);
            openReader.rf.ReadShort();
            int             coverage         = openReader.rf.ReadUnsignedShort();
            int             valueFormat      = openReader.rf.ReadUnsignedShort();
            GposValueRecord valueRecord      = OtfReadCommon.ReadGposValueRecord(openReader, valueFormat);
            IList <int>     coverageGlyphIds = openReader.ReadCoverageFormat(subTableLocation + coverage);

            foreach (int?glyphId in coverageGlyphIds)
            {
                valueRecordMap.Put((int)glyphId, valueRecord);
            }
        }
Exemplo n.º 7
0
        public virtual void TestReadCoverageFormat1()
        {
            // Based on Example 5 from the specification
            // https://docs.microsoft.com/en-us/typography/opentype/spec/chapter2
            // 0001 0005 0038 003B 0041 1042 A04A
            String path = RESOURCE_FOLDER + "coverage-format-1.bin";
            RandomAccessFileOrArray rf = new RandomAccessFileOrArray(new RandomAccessSourceFactory().CreateBestSource(
                                                                         path));
            IList <int> glyphIds = OtfReadCommon.ReadCoverageFormat(rf, 0);

            NUnit.Framework.Assert.AreEqual(5, glyphIds.Count);
            NUnit.Framework.Assert.AreEqual(0x38, (int)glyphIds[0]);
            NUnit.Framework.Assert.AreEqual(0x3B, (int)glyphIds[1]);
            NUnit.Framework.Assert.AreEqual(0x41, (int)glyphIds[2]);
            NUnit.Framework.Assert.AreEqual(0x1042, (int)glyphIds[3]);
            NUnit.Framework.Assert.AreEqual(0xA04A, (int)glyphIds[4]);
        }
Exemplo n.º 8
0
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual SubstLookupRecord[] ReadSubstLookupRecords(int substCount)
 {
     return(OtfReadCommon.ReadSubstLookupRecords(rf, substCount));
 }
Exemplo n.º 9
0
 /// <exception cref="System.IO.IOException"/>
 protected internal IList <int> ReadCoverageFormat(int coverageLocation)
 {
     return(OtfReadCommon.ReadCoverageFormat(rf, coverageLocation));
 }
Exemplo n.º 10
0
 /// <exception cref="System.IO.IOException"/>
 protected internal virtual void ReadCoverages(int[] locations, IList <ICollection <int> > coverage)
 {
     OtfReadCommon.ReadCoverages(rf, locations, coverage);
 }
Exemplo n.º 11
0
 /// <exception cref="System.IO.IOException"/>
 protected internal int[] ReadUShortArray(int size)
 {
     return(OtfReadCommon.ReadUShortArray(rf, size));
 }
Exemplo n.º 12
0
 /// <exception cref="System.IO.IOException"/>
 protected internal int[] ReadUShortArray(int size, int location)
 {
     return(OtfReadCommon.ReadUShortArray(rf, size, location));
 }