Beispiel #1
0
        protected override void ReadContentFrom(BinaryReader reader)
        {
            uint           tableOffset = this.Header.Offset;
            GlyphLocations locations   = this.GlyphLocations;
            int            glyphCount  = locations.GlyphCount;

            _glyphs = new TtfGlyph[glyphCount];

            List <int> compositeGlyphs = new List <int>();

            for (int i = 0; i < glyphCount; i++)
            {
                reader.BaseStream.Seek(tableOffset + locations.Offsets[i], SeekOrigin.Begin);//reset
                uint length = locations.Offsets[i + 1] - locations.Offsets[i];
                if (length > 0)
                {
                    //https://www.microsoft.com/typography/OTSPEC/glyf.htm
                    //header,
                    //Type  Name    Description
                    //SHORT     numberOfContours    If the number of contours is greater than or equal to zero, this is a single glyph; if negative, this is a composite glyph.
                    //SHORT     xMin    Minimum x for coordinate data.
                    //SHORT     yMin    Minimum y for coordinate data.
                    //SHORT     xMax    Maximum x for coordinate data.
                    //SHORT     yMax    Maximum y for coordinate data.
                    short contoursCount = reader.ReadInt16();
                    if (contoursCount >= 0)
                    {
                        Bounds bounds = Utils.ReadBounds(reader);
                        _glyphs[i] = ReadSimpleGlyph(reader, contoursCount, bounds);
                    }
                    else
                    {
                        //skip composite glyph,
                        //resolve later
                        compositeGlyphs.Add(i);
                    }
                }
                else
                {
                    _glyphs[i] = TtfGlyph.Empty;
                }
            }

            //--------------------------------
            //resolve composte glyphs
            //--------------------------------
            foreach (int glyphIndex in compositeGlyphs)
            {
#if DEBUG
                if (glyphIndex == 7)
                {
                }
#endif
                _glyphs[glyphIndex] = ReadCompositeGlyph(_glyphs, reader, tableOffset, glyphIndex);
            }
        }
Beispiel #2
0
 public Glyf(GlyphLocations glyphLocations)
 {
     _glyphLocations = glyphLocations;
 }
Beispiel #3
0
 public Glyf(GlyphLocations glyphLocations)
 {
     this.GlyphLocations = glyphLocations;
 }