diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/GlyphDataTable.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/GlyphDataTable.cs
index cb9ccd87..e20ead76 100644
--- a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/GlyphDataTable.cs
+++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/GlyphDataTable.cs
@@ -2,6 +2,7 @@
{
using System;
using System.Collections.Generic;
+ using Geometry;
using Parser;
using Util.JetBrains.Annotations;
@@ -55,7 +56,7 @@
var maxX = data.ReadSignedShort();
var maxY = data.ReadSignedShort();
- var bounds = new TrueTypeGlyphBounds(minX, minY, maxX, maxY);
+ var bounds = new PdfRectangle(minX, minY, maxX, maxY);
// If the number of contours is greater than or equal zero it's a simple glyph.
if (contourCount >= 0)
@@ -71,7 +72,7 @@
return new GlyphDataTable(table, glyphs);
}
- private static SimpleGlyphDescription ReadSimpleGlyph(TrueTypeDataBytes data, short contourCount, TrueTypeGlyphBounds bounds)
+ private static SimpleGlyphDescription ReadSimpleGlyph(TrueTypeDataBytes data, short contourCount, PdfRectangle bounds)
{
var endPointsOfContours = data.ReadUnsignedShortArray(contourCount);
@@ -93,7 +94,7 @@
var yCoordinates = ReadCoordinates(data, pointCount, flags, SimpleGlyphFlags.YShortVector,
SimpleGlyphFlags.YSignOrSame);
- return new SimpleGlyphDescription(instructionLength, endPointsOfContours, flags, xCoordinates, yCoordinates);
+ return new SimpleGlyphDescription(instructionLength, endPointsOfContours, flags, xCoordinates, yCoordinates, bounds);
}
private static SimpleGlyphFlags[] ReadFlags(TrueTypeDataBytes data, int pointCount)
@@ -134,7 +135,6 @@
x += dx;
- // TODO: overflow?
xs[i] = (short)x;
}
@@ -142,60 +142,6 @@
}
}
- internal interface IGlyphDescription
- {
- bool IsSimple { get; }
-
- SimpleGlyphDescription SimpleGlyph { get; }
-
- object CompositeGlyph { get; }
- }
-
- internal class SimpleGlyphDescription : IGlyphDescription
- {
- ///
- /// The total number of bytes for instructions.
- ///
- public int InstructionLength { get; }
-
- ///
- /// An array of the last points of each contour.
- ///
- public int[] EndPointsOfContours { get; }
-
- ///
- /// Array of flags for each coordinate in the outline.
- ///
- public SimpleGlyphFlags[] Flags { get; }
-
- ///
- /// The x-coordinates of the points in this glyph. The first coordinates are relative to the origin (0, 0)
- /// the rest are relative to the previous point.
- ///
- public short[] XCoordinates { get; }
-
- ///
- /// The y-coordinates of the points in this glyph. The first coordinates are relative to the origin (0, 0)
- /// the rest are relative to the previous point.
- ///
- public short[] YCoordinates { get; }
-
- public SimpleGlyphDescription(int instructionLength, int[] endPointsOfContours, SimpleGlyphFlags[] flags, short[] xCoordinates, short[] yCoordinates)
- {
- InstructionLength = instructionLength;
- EndPointsOfContours = endPointsOfContours;
- Flags = flags;
- XCoordinates = xCoordinates;
- YCoordinates = yCoordinates;
- }
-
- public bool IsSimple { get; } = true;
-
- public SimpleGlyphDescription SimpleGlyph => this;
-
- public object CompositeGlyph { get; } = null;
- }
-
[Flags]
internal enum SimpleGlyphFlags : byte
{
@@ -226,23 +172,4 @@
///
YSignOrSame = 1 << 5
}
-
- internal struct TrueTypeGlyphBounds
- {
- public short X1 { get; }
-
- public short Y1 { get; }
-
- public short X2 { get; }
-
- public short Y2 { get; }
-
- public TrueTypeGlyphBounds(short x1, short y1, short x2, short y2)
- {
- X1 = x1;
- Y1 = y1;
- X2 = x2;
- Y2 = y2;
- }
- }
}
diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/IGlyphDescription.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/IGlyphDescription.cs
new file mode 100644
index 00000000..06e0670b
--- /dev/null
+++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/IGlyphDescription.cs
@@ -0,0 +1,15 @@
+namespace UglyToad.PdfPig.Fonts.TrueType.Tables
+{
+ using Geometry;
+
+ internal interface IGlyphDescription
+ {
+ bool IsSimple { get; }
+
+ SimpleGlyphDescription SimpleGlyph { get; }
+
+ object CompositeGlyph { get; }
+
+ PdfRectangle GlyphBounds { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/UglyToad.PdfPig/Fonts/TrueType/Tables/SimpleGlyphDescription.cs b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/SimpleGlyphDescription.cs
new file mode 100644
index 00000000..5e7ec499
--- /dev/null
+++ b/src/UglyToad.PdfPig/Fonts/TrueType/Tables/SimpleGlyphDescription.cs
@@ -0,0 +1,56 @@
+namespace UglyToad.PdfPig.Fonts.TrueType.Tables
+{
+ using Geometry;
+
+ internal class SimpleGlyphDescription : IGlyphDescription
+ {
+ ///
+ /// The bounding rectangle for the character.
+ ///
+ public PdfRectangle GlyphBounds { get; }
+
+ ///
+ /// The total number of bytes for instructions.
+ ///
+ public int InstructionLength { get; }
+
+ ///
+ /// An array of the last points of each contour.
+ ///
+ public int[] EndPointsOfContours { get; }
+
+ ///
+ /// Array of flags for each coordinate in the outline.
+ ///
+ public SimpleGlyphFlags[] Flags { get; }
+
+ ///
+ /// The x-coordinates of the points in this glyph. The first coordinates are relative to the origin (0, 0)
+ /// the rest are relative to the previous point.
+ ///
+ public short[] XCoordinates { get; }
+
+ ///
+ /// The y-coordinates of the points in this glyph. The first coordinates are relative to the origin (0, 0)
+ /// the rest are relative to the previous point.
+ ///
+ public short[] YCoordinates { get; }
+
+ public SimpleGlyphDescription(int instructionLength, int[] endPointsOfContours, SimpleGlyphFlags[] flags, short[] xCoordinates, short[] yCoordinates,
+ PdfRectangle bounds)
+ {
+ InstructionLength = instructionLength;
+ EndPointsOfContours = endPointsOfContours;
+ Flags = flags;
+ XCoordinates = xCoordinates;
+ YCoordinates = yCoordinates;
+ GlyphBounds = bounds;
+ }
+
+ public bool IsSimple { get; } = true;
+
+ public SimpleGlyphDescription SimpleGlyph => this;
+
+ public object CompositeGlyph { get; } = null;
+ }
+}
\ No newline at end of file
diff --git a/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs b/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs
index cebdaab3..48ee98e3 100644
--- a/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs
+++ b/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs
@@ -19,6 +19,7 @@
public decimal Area { get; }
public PdfRectangle(PdfPoint point1, PdfPoint point2) : this(point1.X, point1.Y, point2.X, point2.Y) { }
+ public PdfRectangle(short x1, short y1, short x2, short y2) : this((decimal) x1, y1, x2, y2) { }
public PdfRectangle(decimal x1, decimal y1, decimal x2, decimal y2)
{
var bottom = Math.Min(y1, y2);