Пример #1
0
            public void Read(TTFReader r, bool readFormat)
            {
                if (readFormat == true)
                {
                    r.ReadInt(out this.substFormat);
                }

                r.ReadInt(out this.coverageOffset);
                r.ReadInt(out this.backtrackGlyphCount);

                this.backtrackCoverageOffsets = new List <ushort>();
                for (int i = 0; i < this.backtrackGlyphCount; ++i)
                {
                    this.backtrackCoverageOffsets.Add(r.ReadUInt16());
                }

                r.ReadInt(out this.lookaheadGlyphCount);
                r.ReadInt(out this.glyphCount);

                this.substituteGlyphIDs = new List <ushort>();
                for (int i = 0; i < this.glyphCount; ++i)
                {
                    this.substituteGlyphIDs.Add(r.ReadUInt16());
                }
            }
Пример #2
0
            public List <uint>   idRangeOffsets; // Offsets into glyphIdArray or 0

            //public List<ushort> glyphIdArray;   // Glyph index array (arbitrary length)

            public void Read(TTFReader r, bool readformat = false)
            {
                if (readformat == true)
                {
                    r.ReadInt(out this.format);
                }
                else
                {
                    this.format = 4;
                }

                r.ReadInt(out this.length);
                r.ReadInt(out this.language);
                r.ReadInt(out this.segCountX2);
                r.ReadInt(out this.searchRange);
                r.ReadInt(out this.entrySelector);
                r.ReadInt(out this.rangeShift);

                uint segCt = (uint)this.segCountX2 / 2;

                this.endCode = new List <ushort>();
                for (int i = 0; i < segCt; ++i)
                {
                    this.endCode.Add(r.ReadUInt16());
                }

                r.ReadInt(out this.reservePad);

                this.startCode = new List <ushort>();
                for (int i = 0; i < segCt; ++i)
                {
                    this.startCode.Add(r.ReadUInt16());
                }

                this.idDelta = new List <short>();
                for (int i = 0; i < segCt; ++i)
                {
                    this.idDelta.Add(r.ReadInt16());
                }

                this.idRangeOffsets = new List <uint>();
                for (int i = 0; i < segCt; ++i)
                {
                    uint ro = r.ReadUInt16();

                    if (ro != 0)
                    {
                        // glyphId = *(idRangeOffset[i] / 2
                        //              + (c - startCode[i])
                        //              + &idRangeOffset[i])
                        uint addr = (uint)r.GetPosition() - 2;
                        ro = addr + ro;
                    }
                    this.idRangeOffsets.Add(ro);
                }
            }
Пример #3
0
            public List <ushort>    glyphIdArray;  // Variable-length array containing subarrays used for mapping the low byte of 2-byte characters.

            public void Read(TTFReader r, bool readformat = false)
            {
                if (readformat == true)
                {
                    r.ReadInt(out this.format);
                }
                else
                {
                    this.format = 2;
                }

                r.ReadInt(out this.length);
                r.ReadInt(out this.language);

                this.subHeaderKeys = new List <ushort>();
                for (int i = 0; i < 256; ++i)
                {
                    this.subHeaderKeys.Add(r.ReadUInt16());
                }

                // !NOTE: This parser is unfinished - don't feel like decrypting the documentation
                // on how to get the sizes for this.
                // this.subHeaders = new List<SubHeader>();
                //
                // this.glyphIdArray = new List<ushort>();
            }
Пример #4
0
            public void Read(TTFReader r, bool readformat = false)
            {
                if (readformat == true)
                {
                    r.ReadInt(out this.format);
                }
                else
                {
                    this.format = 6;
                }

                r.ReadInt(out this.length);
                r.ReadInt(out this.firstCode);
                r.ReadInt(out this.entryCount);

                const int knownTableSz =
                    2 + // format
                    2 + // length
                    2 + // language
                    2 + // firstCode
                    2;  // entryCount

                int glyphsCt = (length - knownTableSz) / 2;

                this.glyphIdArray = new List <ushort>();
                for (int i = 0; i < glyphsCt; ++i)
                {
                    this.glyphIdArray.Add(r.ReadUInt16());
                }
            }
Пример #5
0
 public void Read(TTFReader r, int markClassCount)
 {
     this.ligatureAnchorOffsets = new List <ushort>();
     for (int i = 0; i < markClassCount; ++i)
     {
         this.ligatureAnchorOffsets.Add(r.ReadUInt16());
     }
 }
Пример #6
0
 public void Read(TTFReader r, int offsets)
 {
     this.mark2AnchorOffsets = new List <ushort>();
     for (int i = 0; i < offsets; ++i)
     {
         mark2AnchorOffsets.Add(r.ReadUInt16());
     }
 }
Пример #7
0
            public List <ushort> ligatureAttachOffsets; // Array of offsets to LigatureAttach tables. Offsets are from beginning of LigatureArray table, ordered by ligatureCoverage index.

            public void Read(TTFReader r)
            {
                r.ReadInt(out this.ligatureCount);
                this.ligatureAttachOffsets = new List <ushort>();
                for (int i = 0; i < this.ligatureCount; ++i)
                {
                    this.ligatureAttachOffsets.Add(r.ReadUInt16());
                }
            }
Пример #8
0
            public List <ushort> alternateGlyphIDs; // Array of alternate glyph IDs, in arbitrary order

            public void Read(TTFReader r)
            {
                r.ReadInt(out this.glyphCount);
                this.alternateGlyphIDs = new List <ushort>();
                for (int i = 0; i < this.glyphCount; ++i)
                {
                    this.alternateGlyphIDs.Add(r.ReadUInt16());
                }
            }
Пример #9
0
            public List <ushort> pointIndices;      // Array of contour point indices -in increasing numerical order

            public void Read(TTFReader r)
            {
                r.ReadInt(out this.pointCount);

                this.pointIndices = new List <ushort>();
                for (int i = 0; i < this.pointCount; ++i)
                {
                    this.pointIndices.Add(r.ReadUInt16());
                }
            }
Пример #10
0
            public List <ushort> attachPointOffsets;    // Array of offsets to AttachPoint tables-from beginning of AttachList table-in Coverage Index order

            public void Read(TTFReader r)
            {
                r.ReadInt(out this.coverageOffset);
                r.ReadInt(out this.glyphCount);

                this.attachPointOffsets = new List <ushort>();
                for (int i = 0; i < this.glyphCount; ++i)
                {
                    this.attachPointOffsets.Add(r.ReadUInt16());
                }
            }
Пример #11
0
            public List <ushort> componentGlyphIDs; // Array of component glyph IDs — start with the second component, ordered in writing direction

            public void Read(TTFReader r)
            {
                r.ReadInt(out this.ligatureGlyph);
                r.ReadInt(out this.componentCount);

                this.componentGlyphIDs = new List <ushort>();
                for (int i = 0; i < this.componentCount; ++i)
                {
                    this.componentGlyphIDs.Add(r.ReadUInt16());
                }
            }
Пример #12
0
            public List <ushort> ligatureSetOffset; // Array of offsets to LigatureSet tables. Offsets are from beginning of substitution subtable, ordered by Coverage index

            public void Read(TTFReader r, bool readFormat)
            {
                if (readFormat == true)
                {
                    r.ReadInt(out this.substFormat);
                }

                r.ReadInt(out this.coverageOffset);
                r.ReadInt(out this.ligatureSetCount);

                this.ligatureSetCount = new ushort();
                for (int i = 0; i < this.ligatureSetCount; ++i)
                {
                    this.ligatureSetOffset.Add(r.ReadUInt16());
                }
            }
Пример #13
0
            public void Read(TTFReader r, bool readFormat)
            {
                if (readFormat == true)
                {
                    r.ReadInt(out this.substrFormat);
                }

                r.ReadInt(out this.coverageOffset);
                r.ReadInt(out this.alternateSetCount);

                this.alternateSetOffsets = new List <ushort>();
                for (int i = 0; i < this.alternateSetCount; ++i)
                {
                    this.alternateSetOffsets.Add(r.ReadUInt16());
                }
            }
Пример #14
0
            public List <ushort> pairSetOffsets; // Array of offsets to PairSet tables. Offsets are from beginning of PairPos subtable, ordered by Coverage Index.

            public void Read(TTFReader r, bool readFormat)
            {
                if (readFormat == true)
                {
                    r.ReadInt(out this.posFormat);
                }

                r.ReadInt(out this.coverageOffset);
                r.ReadInt(out this.valueFormat1);
                r.ReadInt(out this.valueFormat2);
                r.ReadInt(out this.pairSetCount);

                this.pairSetOffsets = new List <ushort>();
                for (int i = 0; i < this.pairSetCount; ++i)
                {
                    this.pairSetOffsets.Add(r.ReadUInt16());
                }
            }
Пример #15
0
        public void Read(TTFReader r)
        {
            r.ReadInt(out this.minorVersion);
            r.ReadInt(out this.majorVersion);
            this.italicAngle = r.ReadFixed();
            r.ReadInt(out this.underlinePosition);
            r.ReadInt(out this.underlineThickness);
            r.ReadInt(out this.isFixedPitch);
            r.ReadInt(out this.minMemType42);
            r.ReadInt(out this.maxMemType42);
            r.ReadInt(out this.minMemType1);
            r.ReadInt(out this.maxMemType1);

            if (this.majorVersion == 2 && this.minorVersion == 0)
            {
                r.ReadInt(out this.numGlyphs);

                this.glyphNameIndex = new List <ushort>();
                for (int i = 0; i < this.numGlyphs; ++i)
                {
                    this.glyphNameIndex.Add(r.ReadUInt16());
                }

                this.stringData = new List <string>();
                //while(r.GetPosition() < end)
                //    this.stringData.Add(r.ReadPascalString());

                //for(int i = 0; i < )
            }
            else if (this.majorVersion == 2 && this.minorVersion == 5)
            {
                r.ReadInt(out this.numGlyphs);

                this.offset = new List <byte>();
                for (int i = 0; i < this.numGlyphs; ++i)
                {
                    this.offset.Add(r.ReadUInt8());
                }
            }
            else if (this.majorVersion == 3 && this.minorVersion == 0)
            {
            }  // Do nothing
        }
Пример #16
0
        public void Read(TTFReader r)
        {
            r.ReadInt(out this.majorVersion);
            r.ReadInt(out this.minorVersion);
            r.ReadInt(out this.axisCount);
            r.ReadInt(out this.sharedTupleCount);
            r.ReadInt(out this.glyphCount);
            r.ReadInt(out this.flags);
            r.ReadInt(out this.glyphVariationDataArrayOffset);

            this.glyphVariationDataOffsets = new List <uint>();
            if ((this.flags & 0x0001) != 0)
            {
                for (int i = 0; i < this.glyphCount + 1; ++i)
                {
                    this.glyphVariationDataOffsets.Add(r.ReadUInt32());
                }
            }
            else
            {
                for (int i = 0; i < this.glyphCount + 1; ++i)
                {
                    this.glyphVariationDataOffsets.Add((uint)r.ReadUInt16());
                }
            }

            // Shared tuple records
            // This is probably not right - I cant get good documentation
            // that I can understand for this.
            this.sharedTuples = new List <TupleRecord>();
            for (int i = 0; i < this.sharedTupleCount; ++i)
            {
                TupleRecord tr = new TupleRecord();
                r.ReadInt(out tr.flags);
                r.ReadInt(out tr.cx);
                r.ReadInt(out tr.cy);
                this.sharedTuples.Add(tr);
            }

            // Glyph variation data tables
            this.glyphVariationData.Read(r, this.axisCount);
        }
Пример #17
0
        public List <ushort>     vdmxGroupOffsets; // Offset from start of this table to the VDMXGroup table for a corresponding RatioRange record.

        public void Read(TTFReader r)
        {
            r.ReadInt(out this.version);
            r.ReadInt(out this.numRecs);
            r.ReadInt(out this.numRatios);

            this.ratRange = new List <RatioRange>();
            for (int i = 0; i < this.numRatios; ++i)
            {
                RatioRange rr = new RatioRange();
                rr.Read(r);
                this.ratRange.Add(rr);
            }

            this.vdmxGroupOffsets = new List <ushort>();
            for (int i = 0; i < this.numRatios; ++i)
            {
                this.vdmxGroupOffsets.Add(r.ReadUInt16());
            }
        }
Пример #18
0
        public void Read(TTFReader r, int numGlyphs, bool longVer)
        {
            int readCt = numGlyphs + 1;

            this.offset = new List <uint>();

            if (longVer == false)
            {
                for (int i = 0; i < readCt; ++i)
                {
                    this.offset.Add((uint)(r.ReadUInt16() * 2));
                }
            }
            else
            {
                for (int i = 0; i < readCt; ++i)
                {
                    this.offset.Add(r.ReadUInt32());
                }
            }
        }
Пример #19
0
            Dictionary <uint, uint> CharacterConversionMap.MapCodeToIndex(TTFReader r)
            {
                Dictionary <uint, uint> ret = new Dictionary <uint, uint>();

                uint segCt = (uint)this.segCountX2 / 2;

                for (int i = 0; i < segCt; ++i)
                {
                    // https://gist.github.com/smhanov/f009a02c00eb27d99479a1e37c1b3354

                    int start = this.startCode[i];
                    int end   = this.endCode[i];
                    if (start == 0xffff || end == 0xffff)
                    {
                        break;
                    }

                    uint ro = this.idRangeOffsets[i];

                    if (ro == 0)
                    {
                        for (int j = start; j <= end; ++j)
                        {
                            ret.Add((uint)j, (uint)(j + this.idDelta[i]));
                        }
                    }
                    else
                    {
                        r.SetPosition(ro);
                        for (int j = start; j <= end; ++j)
                        {
                            ret.Add((uint)j, r.ReadUInt16());
                        }
                    }
                }

                return(ret);
            }
Пример #20
0
            public List <ushort> glyphIdArray;  // Array of glyph indices for the character codes covered

            public void Read(TTFReader r, bool readformat = false)
            {
                if (readformat == true)
                {
                    r.ReadInt(out this.format);
                }
                else
                {
                    this.format = 10;
                }

                r.ReadInt(out this.reserved);
                r.ReadInt(out this.length);
                r.ReadInt(out this.language);
                r.ReadInt(out this.startCharCode);
                r.ReadInt(out this.numChars);

                this.glyphIdArray = new List <ushort>();
                for (int i = 0; i < this.numChars; ++i)
                {
                    this.glyphIdArray.Add(r.ReadUInt16());
                }
            }
Пример #21
0
        public void Read(TTFReader r, uint tableStart)
        {
            r.ReadInt(out this.version);
            r.ReadInt(out this.numTables);

            this.encodingRecords = new List <EncodingRecord>();
            for (int i = 0; i < this.numTables; ++i)
            {
                EncodingRecord er = new EncodingRecord();
                er.Read(r);
                this.encodingRecords.Add(er);
            }

            foreach (EncodingRecord rc in this.encodingRecords)
            {
                r.SetPosition(tableStart + rc.subtableOffset);

                ushort format = r.ReadUInt16();

                if (format == 0)
                {
                    if (this.format0 == null)
                    {
                        this.format0 = new List <Format0>();
                    }

                    Format0 f0 = new Format0();
                    f0.Read(r);
                    this.format0.Add(f0);
                }
                else if (format == 2)
                {
                    if (this.format2 == null)
                    {
                        this.format2 = new List <Format2>();
                    }

                    Format2 f2 = new Format2();
                    f2.Read(r);
                    this.format2.Add(f2);
                }
                else if (format == 4)
                {
                    if (this.format4 == null)
                    {
                        this.format4 = new List <Format4>();
                    }

                    Format4 f4 = new Format4();
                    f4.Read(r);
                    this.format4.Add(f4);
                }
                else if (format == 6)
                {
                    if (this.format6 == null)
                    {
                        this.format6 = new List <Format6>();
                    }

                    Format6 f6 = new Format6();
                    f6.Read(r);
                    this.format6.Add(f6);
                }
                else if (format == 8)
                {
                    if (this.format8 == null)
                    {
                        this.format8 = new List <Format8>();
                    }

                    Format8 f8 = new Format8();
                    f8.Read(r);
                    this.format8.Add(f8);
                }
                else if (format == 10)
                {
                    if (this.format10 == null)
                    {
                        this.format10 = new List <Format10>();
                    }

                    Format10 f10 = new Format10();
                    f10.Read(r);
                    this.format10.Add(f10);
                }
                else if (format == 12)
                {
                    if (this.format12 == null)
                    {
                        this.format12 = new List <Format12>();
                    }

                    Format12 f12 = new Format12();
                    f12.Read(r);
                    this.format12.Add(f12);
                }
                else if (format == 13)
                {
                    if (this.format13 == null)
                    {
                        this.format13 = new List <Format13>();
                    }

                    Format13 f13 = new Format13();
                    f13.Read(r);
                    this.format13.Add(f13);
                }
                else if (format == 14)
                {
                    if (this.format14 == null)
                    {
                        this.format14 = new List <Format14>();
                    }

                    Format14 f14 = new Format14();
                    f14.Read(r);
                    this.format14.Add(f14);
                }
            }
        }