public Glyph(PointS[] points, GlyphFlag[] flags, byte[] instructions, ushort[] endPtsOfContours, BoundsS bounds) { Points = points; Flags = flags; Instructions = instructions; EndPtsOfContours = endPtsOfContours; Bounds = bounds; }
private GlyphFlag[] ReadGlyphFlags(BinaryReader reader, int numberOfPoints) { var flags = new GlyphFlag[numberOfPoints]; int i = 0; int repeat = 0; GlyphFlag flag = (GlyphFlag)0; while(i < numberOfPoints) { if(repeat > 0) { repeat--; } else { flag = (GlyphFlag)reader.ReadByte(); if (flag.HasFlag(GlyphFlag.Repeat)) { repeat = reader.ReadByte(); } } flags[i++] = flag; } return flags; }
private short[] ReadGlyphCoordinates(BinaryReader reader, int numberOfPoints, GlyphFlag[] flags, GlyphFlag isByte, GlyphFlag signOrSame) { var coordinates = new short[numberOfPoints]; int x = 0; for (int i = 0; i < numberOfPoints; i++) { int dx; if (flags[i].HasFlag(isByte)) { var b = reader.ReadByte(); dx = flags[i].HasFlag(signOrSame) ? b : -b; } else { if (flags[i].HasFlag(signOrSame)) { dx = 0; } else { dx = reader.ReadInt16(); } } x += dx; coordinates[i] = (short)x; // TODO: overflow? } return coordinates; }