mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-15 19:54:52 +08:00
use doubles where calculations are being run
This commit is contained in:
@@ -150,7 +150,7 @@
|
||||
}
|
||||
|
||||
var fontSize = currentState.FontState.FontSize;
|
||||
var horizontalScaling = currentState.FontState.HorizontalScaling / 100m;
|
||||
var horizontalScaling = currentState.FontState.HorizontalScaling / 100.0;
|
||||
var characterSpacing = currentState.FontState.CharacterSpacing;
|
||||
var rise = currentState.FontState.Rise;
|
||||
|
||||
@@ -161,7 +161,7 @@
|
||||
|
||||
// TODO: this does not seem correct, produces the correct result for now but we need to revisit.
|
||||
// see: https://stackoverflow.com/questions/48010235/pdf-specification-get-font-size-in-points
|
||||
var pointSize = decimal.Round(rotation.Rotate(transformationMatrix).Multiply(TextMatrices.TextMatrix).Multiply(fontSize).A, 2);
|
||||
var pointSize = Math.Round(rotation.Rotate(transformationMatrix).Multiply(TextMatrices.TextMatrix).Multiply(fontSize).A, 2);
|
||||
|
||||
while (bytes.MoveNext())
|
||||
{
|
||||
@@ -176,7 +176,7 @@
|
||||
unicode = new string((char)code, 1);
|
||||
}
|
||||
|
||||
var wordSpacing = 0m;
|
||||
var wordSpacing = 0.0;
|
||||
if (code == ' ' && codeLength == 1)
|
||||
{
|
||||
wordSpacing += GetCurrentState().FontState.WordSpacing;
|
||||
@@ -228,7 +228,7 @@
|
||||
|
||||
letters.Add(letter);
|
||||
|
||||
decimal tx, ty;
|
||||
double tx, ty;
|
||||
if (font.IsVertical)
|
||||
{
|
||||
var verticalFont = (IVerticalWritingSupported)font;
|
||||
@@ -255,7 +255,7 @@
|
||||
var textState = currentState.FontState;
|
||||
|
||||
var fontSize = textState.FontSize;
|
||||
var horizontalScaling = textState.HorizontalScaling / 100m;
|
||||
var horizontalScaling = textState.HorizontalScaling / 100.0;
|
||||
var font = resourceStore.GetFont(textState.FontName);
|
||||
|
||||
var isVertical = font.IsVertical;
|
||||
@@ -264,9 +264,9 @@
|
||||
{
|
||||
if (token is NumericToken number)
|
||||
{
|
||||
var positionAdjustment = number.Data;
|
||||
var positionAdjustment = (double)number.Data;
|
||||
|
||||
decimal tx, ty;
|
||||
double tx, ty;
|
||||
if (isVertical)
|
||||
{
|
||||
tx = 0;
|
||||
@@ -353,7 +353,7 @@
|
||||
var formMatrix = TransformationMatrix.Identity;
|
||||
if (formStream.StreamDictionary.TryGet<ArrayToken>(NameToken.Matrix, pdfScanner, out var formMatrixToken))
|
||||
{
|
||||
formMatrix = TransformationMatrix.FromArray(formMatrixToken.Data.OfType<NumericToken>().Select(x => x.Data).ToArray());
|
||||
formMatrix = TransformationMatrix.FromArray(formMatrixToken.Data.OfType<NumericToken>().Select(x => (double)x.Data).ToArray());
|
||||
}
|
||||
|
||||
// 2. Update current transformation matrix.
|
||||
@@ -449,7 +449,7 @@
|
||||
&& fontArray.Data[0] is IndirectReferenceToken fontReference && fontArray.Data[1] is NumericToken sizeToken)
|
||||
{
|
||||
currentGraphicsState.FontState.FromExtendedGraphicsState = true;
|
||||
currentGraphicsState.FontState.FontSize = sizeToken.Data;
|
||||
currentGraphicsState.FontState.FontSize = (double)sizeToken.Data;
|
||||
activeExtendedGraphicsStateFont = resourceStore.GetFontDirectly(fontReference, isLenientParsing);
|
||||
}
|
||||
}
|
||||
@@ -500,7 +500,7 @@
|
||||
inlineImageBuilder = null;
|
||||
}
|
||||
|
||||
private void AdjustTextMatrix(decimal tx, decimal ty)
|
||||
private void AdjustTextMatrix(double tx, double ty)
|
||||
{
|
||||
var matrix = TransformationMatrix.GetTranslationMatrix(tx, ty);
|
||||
|
||||
|
@@ -24,7 +24,7 @@ namespace UglyToad.PdfPig.Graphics
|
||||
/// In horizontal writing mode a positive value will expand the distance between letters/glyphs.
|
||||
/// Default value 0.
|
||||
/// </remarks>
|
||||
public decimal CharacterSpacing { get; set; } = 0;
|
||||
public double CharacterSpacing { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// As for <see cref="CharacterSpacing"/> but applies only for the space character (32).
|
||||
@@ -32,18 +32,18 @@ namespace UglyToad.PdfPig.Graphics
|
||||
/// <remarks>
|
||||
/// Default value 0.
|
||||
/// </remarks>
|
||||
public decimal WordSpacing { get; set; } = 0;
|
||||
public double WordSpacing { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Adjusts the width of glyphs/letters by stretching (or compressing) them horizontally.
|
||||
/// Value is a percentage of the normal width.
|
||||
/// </summary>
|
||||
public decimal HorizontalScaling { get; set; } = 100;
|
||||
public double HorizontalScaling { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// The vertical distance in unscaled text space units between the baselines of lines of text.
|
||||
/// </summary>
|
||||
public decimal Leading { get; set; }
|
||||
public double Leading { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the currently active font.
|
||||
@@ -53,7 +53,7 @@ namespace UglyToad.PdfPig.Graphics
|
||||
/// <summary>
|
||||
/// The current font size.
|
||||
/// </summary>
|
||||
public decimal FontSize { get; set; }
|
||||
public double FontSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TextRenderingMode"/> for glyph outlines.
|
||||
@@ -71,7 +71,7 @@ namespace UglyToad.PdfPig.Graphics
|
||||
/// <remarks>
|
||||
/// Always applies to the vertical coordinate irrespective or writing mode.
|
||||
/// </remarks>
|
||||
public decimal Rise { get; set; }
|
||||
public double Rise { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Are all glyphs in a text object treated as a single elementary object for the purpose of the transparent imaging model?
|
||||
|
@@ -2,7 +2,7 @@
|
||||
{
|
||||
using System.IO;
|
||||
using Geometry;
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Append a cubic Bezier curve to the current path.
|
||||
@@ -19,19 +19,34 @@
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The first control point.
|
||||
/// First control point x.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint1 { get; }
|
||||
public decimal X1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The second control point.
|
||||
/// First control point y.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint2 { get; }
|
||||
public decimal Y1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The end point.
|
||||
/// Second control point x.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
public decimal X2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Second control point y.
|
||||
/// </summary>
|
||||
public decimal Y2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// End point x.
|
||||
/// </summary>
|
||||
public decimal X3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// End point y.
|
||||
/// </summary>
|
||||
public decimal Y3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendDualControlPointBezierCurve"/>.
|
||||
@@ -44,17 +59,25 @@
|
||||
/// <param name="y3">End point y coordinate.</param>
|
||||
public AppendDualControlPointBezierCurve(decimal x1, decimal y1, decimal x2, decimal y2, decimal x3, decimal y3)
|
||||
{
|
||||
ControlPoint1 = new PdfPoint(x1, y1);
|
||||
ControlPoint2 = new PdfPoint(x2, y2);
|
||||
End = new PdfPoint(x3, y3);
|
||||
X1 = x1;
|
||||
Y1 = y1;
|
||||
X2 = x2;
|
||||
Y2 = y2;
|
||||
X3 = x3;
|
||||
Y3 = y3;
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var controlPoint1Transform = operationContext.CurrentTransformationMatrix.Transform(ControlPoint1);
|
||||
var controlPoint2Transform = operationContext.CurrentTransformationMatrix.Transform(ControlPoint2);
|
||||
var endTransform = operationContext.CurrentTransformationMatrix.Transform(End);
|
||||
var controlPoint1 = new PdfPoint(X1, Y1);
|
||||
var controlPoint2 = new PdfPoint(X2, Y2);
|
||||
var end = new PdfPoint(X3, Y3);
|
||||
|
||||
var controlPoint1Transform = operationContext.CurrentTransformationMatrix.Transform(controlPoint1);
|
||||
var controlPoint2Transform = operationContext.CurrentTransformationMatrix.Transform(controlPoint2);
|
||||
var endTransform = operationContext.CurrentTransformationMatrix.Transform(end);
|
||||
operationContext.CurrentPath.BezierCurveTo(controlPoint1Transform.X, controlPoint1Transform.Y,
|
||||
controlPoint2Transform.X, controlPoint2Transform.Y,
|
||||
endTransform.X, endTransform.Y);
|
||||
@@ -64,17 +87,17 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(ControlPoint1.X);
|
||||
stream.WriteDecimal(X1);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(ControlPoint1.Y);
|
||||
stream.WriteDecimal(Y1);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(ControlPoint2.X);
|
||||
stream.WriteDecimal(X2);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(ControlPoint2.Y);
|
||||
stream.WriteDecimal(Y2);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.X);
|
||||
stream.WriteDecimal(X3);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.Y);
|
||||
stream.WriteDecimal(Y3);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
@@ -83,7 +106,7 @@
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ControlPoint1.X} {ControlPoint1.Y} {ControlPoint2.X} {ControlPoint2.Y} {End.X} {End.Y} {Symbol}";
|
||||
return $"{X1} {Y1} {X2} {Y2} {X3} {Y3} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@
|
||||
/// </summary>
|
||||
public class AppendEndControlPointBezierCurve : IGraphicsStateOperation
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The symbol for this operation in a stream.
|
||||
/// </summary>
|
||||
@@ -19,15 +20,25 @@
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The first control point.
|
||||
/// The x coordinate of the first control point.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint1 { get; }
|
||||
public decimal X1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The end point and second control point.
|
||||
/// The y coordinate of the first control point.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
public decimal Y1 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of the end point.
|
||||
/// </summary>
|
||||
public decimal X3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the end point.
|
||||
/// </summary>
|
||||
public decimal Y3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendEndControlPointBezierCurve"/>.
|
||||
/// </summary>
|
||||
@@ -37,15 +48,19 @@
|
||||
/// <param name="y3">Control point 2/End y coordinate.</param>
|
||||
public AppendEndControlPointBezierCurve(decimal x1, decimal y1, decimal x3, decimal y3)
|
||||
{
|
||||
ControlPoint1 = new PdfPoint(x1, y1);
|
||||
End = new PdfPoint(x3, y3);
|
||||
X1 = x1;
|
||||
Y1 = y1;
|
||||
X3 = x3;
|
||||
Y3 = y3;
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var controlPoint1Transform = operationContext.CurrentTransformationMatrix.Transform(ControlPoint1);
|
||||
var endTransform = operationContext.CurrentTransformationMatrix.Transform(End);
|
||||
var controlPoint1 = new PdfPoint(X1, Y1);
|
||||
var end = new PdfPoint(X3, Y3);
|
||||
var controlPoint1Transform = operationContext.CurrentTransformationMatrix.Transform(controlPoint1);
|
||||
var endTransform = operationContext.CurrentTransformationMatrix.Transform(end);
|
||||
operationContext.CurrentPath.BezierCurveTo(controlPoint1Transform.X, controlPoint1Transform.Y,
|
||||
endTransform.X,
|
||||
endTransform.Y,
|
||||
@@ -57,13 +72,13 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(ControlPoint1.X);
|
||||
stream.WriteDecimal(X1);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(ControlPoint1.Y);
|
||||
stream.WriteDecimal(Y1);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.X);
|
||||
stream.WriteDecimal(X3);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.Y);
|
||||
stream.WriteDecimal(Y3);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
@@ -72,7 +87,7 @@
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ControlPoint1.X} {ControlPoint1.Y} {End.X} {End.Y} {Symbol}";
|
||||
return $"{X1} {Y1} {X3} {Y3} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,9 +18,14 @@
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The lower left corner.
|
||||
/// The x coordinate of the lower left corner.
|
||||
/// </summary>
|
||||
public PdfPoint LowerLeft { get; }
|
||||
public decimal LowerLeftX { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the lower left corner.
|
||||
/// </summary>
|
||||
public decimal LowerLeftY { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The width of the rectangle.
|
||||
@@ -41,7 +46,8 @@
|
||||
/// <param name="height">The height of the rectangle.</param>
|
||||
public AppendRectangle(decimal x, decimal y, decimal width, decimal height)
|
||||
{
|
||||
LowerLeft = new PdfPoint(x, y);
|
||||
LowerLeftX = x;
|
||||
LowerLeftY = y;
|
||||
|
||||
Width = width;
|
||||
Height = height;
|
||||
@@ -50,17 +56,18 @@
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var lowerLeft = new PdfPoint(LowerLeftX, LowerLeftY);
|
||||
operationContext.BeginSubpath();
|
||||
var lowerLeftTransform = operationContext.CurrentTransformationMatrix.Transform(LowerLeft);
|
||||
operationContext.CurrentPath.Rectangle(lowerLeftTransform.X, lowerLeftTransform.Y, Width, Height);
|
||||
var lowerLeftTransform = operationContext.CurrentTransformationMatrix.Transform(lowerLeft);
|
||||
operationContext.CurrentPath.Rectangle(lowerLeftTransform.X, lowerLeftTransform.Y, (double)Width, (double)Height);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(LowerLeft.X);
|
||||
stream.WriteDecimal(LowerLeftX);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(LowerLeft.Y);
|
||||
stream.WriteDecimal(LowerLeftY);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(Width);
|
||||
stream.WriteWhiteSpace();
|
||||
@@ -73,7 +80,7 @@
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{LowerLeft.X} {LowerLeft.Y} {Width} {Height} {Symbol}";
|
||||
return $"{LowerLeftX} {LowerLeftY} {Width} {Height} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,16 +17,26 @@
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The x coordinate of the second control point.
|
||||
/// </summary>
|
||||
public decimal X2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The second control point.
|
||||
/// The y coordinate of the second control point.
|
||||
/// </summary>
|
||||
public PdfPoint ControlPoint2 { get; }
|
||||
public decimal Y2 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The last point on the curve.
|
||||
/// The x coordinate of the end point of the curve.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
public decimal X3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the end point of the curve.
|
||||
/// </summary>
|
||||
public decimal Y3 { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendStartControlPointBezierCurve"/>.
|
||||
@@ -37,15 +47,19 @@
|
||||
/// <param name="y3">The y coordinate of the end point.</param>
|
||||
public AppendStartControlPointBezierCurve(decimal x2, decimal y2, decimal x3, decimal y3)
|
||||
{
|
||||
ControlPoint2 = new PdfPoint(x2, y2);
|
||||
End = new PdfPoint(x3, y3);
|
||||
X2 = x2;
|
||||
Y2 = y2;
|
||||
X3 = x3;
|
||||
Y3 = y3;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var controlPoint2Transform = operationContext.CurrentTransformationMatrix.Transform(ControlPoint2);
|
||||
var endTransform = operationContext.CurrentTransformationMatrix.Transform(End);
|
||||
var controlPoint2 = new PdfPoint(X2, Y2);
|
||||
var end = new PdfPoint(X3, Y3);
|
||||
var controlPoint2Transform = operationContext.CurrentTransformationMatrix.Transform(controlPoint2);
|
||||
var endTransform = operationContext.CurrentTransformationMatrix.Transform(end);
|
||||
operationContext.CurrentPath.BezierCurveTo(operationContext.CurrentPosition.X,
|
||||
operationContext.CurrentPosition.Y,
|
||||
controlPoint2Transform.X,
|
||||
@@ -58,13 +72,13 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(ControlPoint2.X);
|
||||
stream.WriteDecimal(X2);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(ControlPoint2.Y);
|
||||
stream.WriteDecimal(Y2);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.X);
|
||||
stream.WriteDecimal(X3);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.Y);
|
||||
stream.WriteDecimal(Y3);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
@@ -73,7 +87,7 @@
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{ControlPoint2.X} {ControlPoint2.Y} {End.X} {End.Y} {Symbol}";
|
||||
return $"{X2} {Y2} {X3} {Y3} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,10 +18,15 @@
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The end point of the line.
|
||||
/// The x coordinate of the end point of the line.
|
||||
/// </summary>
|
||||
public PdfPoint End { get; }
|
||||
public decimal X { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate of the end point of the line.
|
||||
/// </summary>
|
||||
public decimal Y { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="AppendStraightLineSegment"/>.
|
||||
/// </summary>
|
||||
@@ -29,13 +34,14 @@
|
||||
/// <param name="y">The y coordinate of the line's end point.</param>
|
||||
public AppendStraightLineSegment(decimal x, decimal y)
|
||||
{
|
||||
End = new PdfPoint(x, y);
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var endPoint = operationContext.CurrentTransformationMatrix.Transform(new PdfPoint(End.X, End.Y));
|
||||
var endPoint = operationContext.CurrentTransformationMatrix.Transform(new PdfPoint(X, Y));
|
||||
operationContext.CurrentPath.LineTo(endPoint.X, endPoint.Y);
|
||||
operationContext.CurrentPosition = endPoint;
|
||||
}
|
||||
@@ -43,9 +49,9 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(End.X);
|
||||
stream.WriteDecimal(X);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(End.Y);
|
||||
stream.WriteDecimal(Y);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteWhiteSpace();
|
||||
@@ -54,7 +60,7 @@
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{End.X} {End.Y} {Symbol}";
|
||||
return $"{X} {Y} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,10 +18,15 @@
|
||||
public string Operator => Symbol;
|
||||
|
||||
/// <summary>
|
||||
/// The point to begin the new subpath at.
|
||||
/// The x coordinate for the subpath to begin at.
|
||||
/// </summary>
|
||||
public PdfPoint Point { get; }
|
||||
public decimal X { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The y coordinate for the subpath to begin at.
|
||||
/// </summary>
|
||||
public decimal Y { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="BeginNewSubpath"/>.
|
||||
/// </summary>
|
||||
@@ -29,14 +34,16 @@
|
||||
/// <param name="y">The y coordinate.</param>
|
||||
public BeginNewSubpath(decimal x, decimal y)
|
||||
{
|
||||
Point = new PdfPoint(x, y);
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var point = new PdfPoint(X, Y);
|
||||
operationContext.BeginSubpath();
|
||||
var pointTransform = operationContext.CurrentTransformationMatrix.Transform(Point);
|
||||
var pointTransform = operationContext.CurrentTransformationMatrix.Transform(point);
|
||||
operationContext.CurrentPosition = pointTransform;
|
||||
operationContext.CurrentPath.MoveTo(pointTransform.X, pointTransform.Y);
|
||||
}
|
||||
@@ -44,9 +51,9 @@
|
||||
/// <inheritdoc />
|
||||
public void Write(Stream stream)
|
||||
{
|
||||
stream.WriteDecimal(Point.X);
|
||||
stream.WriteDecimal(X);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(Point.Y);
|
||||
stream.WriteDecimal(Y);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteText(Symbol);
|
||||
stream.WriteNewLine();
|
||||
@@ -55,7 +62,7 @@
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Point.X} {Point.Y} {Symbol}";
|
||||
return $"{X} {Y} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,7 +32,7 @@
|
||||
/// <inheritdoc />
|
||||
public void Run(IOperationContext operationContext)
|
||||
{
|
||||
var tdOperation = new MoveToNextLineWithOffset(0, -1 * operationContext.GetCurrentState().FontState.Leading);
|
||||
var tdOperation = new MoveToNextLineWithOffset(0, -1 * (decimal)operationContext.GetCurrentState().FontState.Leading);
|
||||
|
||||
tdOperation.Run(operationContext);
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@
|
||||
{
|
||||
var currentTextLineMatrix = operationContext.TextMatrices.TextLineMatrix;
|
||||
|
||||
var matrix = TransformationMatrix.FromValues(1, 0, 0, 1, Tx, Ty);
|
||||
var matrix = TransformationMatrix.FromValues(1, 0, 0, 1, (double)Tx, (double)Ty);
|
||||
|
||||
var transformed = matrix.Multiply(currentTextLineMatrix);
|
||||
|
||||
|
@@ -36,7 +36,7 @@
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.CharacterSpacing = Spacing;
|
||||
currentState.FontState.CharacterSpacing = (double)Spacing;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -49,7 +49,7 @@
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.FontSize = Size;
|
||||
currentState.FontState.FontSize = (double)Size;
|
||||
currentState.FontState.FontName = Font;
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.HorizontalScaling = Scale;
|
||||
currentState.FontState.HorizontalScaling = (double)Scale;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -35,7 +35,7 @@
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.Leading = Leading;
|
||||
currentState.FontState.Leading = (double)Leading;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -35,7 +35,7 @@
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.Rise = Rise;
|
||||
currentState.FontState.Rise = (double)Rise;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -36,7 +36,7 @@
|
||||
{
|
||||
var currentState = operationContext.GetCurrentState();
|
||||
|
||||
currentState.FontState.WordSpacing = Spacing;
|
||||
currentState.FontState.WordSpacing = (double)Spacing;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@@ -1,7 +1,6 @@
|
||||
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
||||
{
|
||||
using System.IO;
|
||||
using Geometry;
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@@ -29,10 +28,25 @@
|
||||
public decimal VerticalDisplacement { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The glyph bounding box.
|
||||
/// The lower left x coordinate of the glyph bounding box.
|
||||
/// </summary>
|
||||
public PdfRectangle BoundingBox { get; }
|
||||
public decimal LowerLeftX { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The lower left y coordinate of the glyph bounding box.
|
||||
/// </summary>
|
||||
public decimal LowerLeftY { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The upper right x coordinate of the glyph bounding box.
|
||||
/// </summary>
|
||||
public decimal UpperRightX { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The upper right y coordinate of the glyph bounding box.
|
||||
/// </summary>
|
||||
public decimal UpperRightY { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="Type3SetGlyphWidthAndBoundingBox"/>.
|
||||
/// </summary>
|
||||
@@ -50,7 +64,10 @@
|
||||
{
|
||||
HorizontalDisplacement = horizontalDisplacement;
|
||||
VerticalDisplacement = verticalDisplacement;
|
||||
BoundingBox = new PdfRectangle(new PdfPoint(lowerLeftX, lowerLeftY), new PdfPoint(upperRightX, upperRightY));
|
||||
LowerLeftX = lowerLeftX;
|
||||
LowerLeftY = lowerLeftY;
|
||||
UpperRightX = upperRightX;
|
||||
UpperRightY = upperRightY;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -65,19 +82,19 @@
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(VerticalDisplacement);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(BoundingBox.Left);
|
||||
stream.WriteDecimal(LowerLeftX);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(BoundingBox.Bottom);
|
||||
stream.WriteDecimal(LowerLeftY);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteDecimal(BoundingBox.Right);
|
||||
stream.WriteDecimal(UpperRightX);
|
||||
stream.WriteWhiteSpace();
|
||||
stream.WriteNumberText(BoundingBox.Top, Symbol);
|
||||
stream.WriteNumberText(UpperRightY, Symbol);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{HorizontalDisplacement} {VerticalDisplacement} {BoundingBox.Left} {BoundingBox.Bottom} {BoundingBox.Right} {BoundingBox.Top} {Symbol}";
|
||||
return $"{HorizontalDisplacement} {VerticalDisplacement} {LowerLeftX} {LowerLeftY} {UpperRightX} {UpperRightY} {Symbol}";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user