use short to save space when storing the set of glyph points

This commit is contained in:
Eliot Jones
2019-12-23 10:12:07 +00:00
parent ba9fe40bc1
commit 4f9eb1a25a
2 changed files with 9 additions and 9 deletions

View File

@@ -107,11 +107,11 @@
{
var point = Points[i];
var scaled = matrix.ScaleAndRotate(point.Point);
var scaled = matrix.ScaleAndRotate(new PdfPoint(point.X, point.Y));
scaled = matrix.Translate(scaled);
newPoints[i] = new GlyphPoint(scaled, point.IsOnCurve);
newPoints[i] = new GlyphPoint((short)scaled.X, (short)scaled.Y, point.IsOnCurve);
}
return new Glyph(IsSimple, Instructions, EndPointsOfContours, newPoints, Bounds);

View File

@@ -1,23 +1,23 @@
namespace UglyToad.PdfPig.Fonts.TrueType.Glyphs
{
using Geometry;
internal struct GlyphPoint
{
public PdfPoint Point { get; }
public short X { get; }
public short Y { get; }
public bool IsOnCurve { get; }
public GlyphPoint(decimal x, decimal y, bool isOnCurve) : this(new PdfPoint(x, y), isOnCurve) { }
public GlyphPoint(PdfPoint point, bool isOnCurve)
public GlyphPoint(short x, short y, bool isOnCurve)
{
Point = point;
X = x;
Y = y;
IsOnCurve = isOnCurve;
}
public override string ToString()
{
return $"{Point} | {IsOnCurve}";
return $"({X}, {Y}) | {IsOnCurve}";
}
}
}