diff --git a/src/UglyToad.PdfPig.Core/PdfPoint.cs b/src/UglyToad.PdfPig.Core/PdfPoint.cs index 78654072..1cc949f1 100644 --- a/src/UglyToad.PdfPig.Core/PdfPoint.cs +++ b/src/UglyToad.PdfPig.Core/PdfPoint.cs @@ -16,7 +16,7 @@ /// /// The origin of the coordinates system. /// - public static PdfPoint Origin { get; } = new PdfPoint(0m, 0m); + public static PdfPoint Origin { get; } = new PdfPoint(0.0, 0.0); /// /// The X coordinate for this point. (Horizontal axis). @@ -28,16 +28,6 @@ /// public double Y { get; } - /// - /// Create a new at this position. - /// - [DebuggerStepThrough] - public PdfPoint(decimal x, decimal y) - { - X = (double)x; - Y = (double)y; - } - /// /// Create a new at this position. /// diff --git a/src/UglyToad.PdfPig.Core/PdfRange.cs b/src/UglyToad.PdfPig.Core/PdfRange.cs index 8dbf04c7..44d91c05 100644 --- a/src/UglyToad.PdfPig.Core/PdfRange.cs +++ b/src/UglyToad.PdfPig.Core/PdfRange.cs @@ -11,28 +11,6 @@ private readonly IReadOnlyList rangeArray; private readonly int startingIndex; - /// - /// Constructor assumes a starting index of 0. - /// - /// The array that describes the range. - public PdfRange(IEnumerable range) - : this(range.Select(v => (double)v), 0) - { - } - - /// - /// Constructor with an index into an array. Because some arrays specify - /// multiple ranges ie [0, 1, 0, 2, 2, 3]. It is convenient for this - /// class to take an index into an array. So if you want this range to - /// represent 0, 2 in the above example then you would say new PDRange(array, 1). - /// - /// The array that describes the index - /// The range index into the array for the start of the range. - public PdfRange(IEnumerable range, int index) - : this(range.Select(v => (double)v), index) - { - } - /// /// Constructor assumes a starting index of 0. /// diff --git a/src/UglyToad.PdfPig.Core/TransformationMatrix.cs b/src/UglyToad.PdfPig.Core/TransformationMatrix.cs index c8e1778f..cd9dc1dc 100644 --- a/src/UglyToad.PdfPig.Core/TransformationMatrix.cs +++ b/src/UglyToad.PdfPig.Core/TransformationMatrix.cs @@ -362,14 +362,6 @@ public static TransformationMatrix FromValues(double a, double b, double c, double d) => new TransformationMatrix(a, b, 0, c, d, 0, 0, 0, 1); - /// - /// Create a new from the values. - /// - /// Either all 9 values of the matrix, 6 values in the default PDF order or the 4 values of the top left square. - /// - public static TransformationMatrix FromArray(decimal[] values) - => FromArray(values.Select(x => (double)x).ToArray()); - /// /// Create a new from the values. /// diff --git a/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetrics.cs b/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetrics.cs index 821114df..f7b6eb80 100644 --- a/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetrics.cs +++ b/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetrics.cs @@ -11,7 +11,7 @@ /// /// Version of the Adobe Font Metrics specification used to generate this file. /// - public decimal AfmVersion { get; } + public double AfmVersion { get; } /// /// Any comments in the file. @@ -103,38 +103,38 @@ /// /// Usually the y-value of the top of capital 'H'. /// - public decimal CapHeight { get; } + public double CapHeight { get; } /// /// Usually the y-value of the top of lowercase 'x'. /// - public decimal XHeight { get; } + public double XHeight { get; } /// /// Usually the y-value of the top of lowercase 'd'. /// - public decimal Ascender { get; } + public double Ascender { get; } /// /// Usually the y-value of the bottom of lowercase 'p'. /// - public decimal Descender { get; } + public double Descender { get; } /// /// Distance from the baseline for underlining. /// - public decimal UnderlinePosition { get; } + public double UnderlinePosition { get; } /// /// Width of the line for underlining. /// - public decimal UnderlineThickness { get; } + public double UnderlineThickness { get; } /// /// Angle in degrees counter-clockwise from the vertical of the vertical linea. /// Zero for non-italic fonts. /// - public decimal ItalicAngle { get; } + public double ItalicAngle { get; } /// /// If present all characters have this width and height. @@ -144,12 +144,12 @@ /// /// Horizontal stem width. /// - public decimal HorizontalStemWidth { get; } + public double HorizontalStemWidth { get; } /// /// Vertical stem width. /// - public decimal VerticalStemWidth { get; } + public double VerticalStemWidth { get; } /// /// Metrics for the individual characters. @@ -159,7 +159,7 @@ /// /// Create a new . /// - public AdobeFontMetrics(decimal afmVersion, IReadOnlyList comments, int metricSets, string fontName, + public AdobeFontMetrics(double afmVersion, IReadOnlyList comments, int metricSets, string fontName, string fullName, string familyName, string weight, @@ -174,16 +174,16 @@ bool isBaseFont, AdobeFontMetricsVector vVector, bool isFixedV, - decimal capHeight, - decimal xHeight, - decimal ascender, - decimal descender, - decimal underlinePosition, - decimal underlineThickness, - decimal italicAngle, + double capHeight, + double xHeight, + double ascender, + double descender, + double underlinePosition, + double underlineThickness, + double italicAngle, AdobeFontMetricsCharacterSize characterWidth, - decimal horizontalStemWidth, - decimal verticalStemWidth, + double horizontalStemWidth, + double verticalStemWidth, IReadOnlyDictionary characterMetrics) { AfmVersion = afmVersion; diff --git a/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsBuilder.cs b/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsBuilder.cs index 5b8ca8e8..54b08bc6 100644 --- a/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsBuilder.cs +++ b/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsBuilder.cs @@ -1,13 +1,12 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics { + using Core; using System.Collections.Generic; using System.Linq; - using Core; - using Standard14Fonts; internal class AdobeFontMetricsBuilder { - public decimal AfmVersion { get; } + public double AfmVersion { get; } public List Comments { get; } @@ -37,7 +36,7 @@ /// /// Angle in degrees counter-clockwise from vertical of vertical strokes of the font. /// - public decimal ItalicAngle { get; set; } + public double ItalicAngle { get; set; } /// /// Whether the font is monospaced or not. @@ -52,12 +51,12 @@ /// /// Distance from the baseline for underlining. /// - public decimal UnderlinePosition { get; set; } + public double UnderlinePosition { get; set; } /// /// The stroke width for underlining. /// - public decimal UnderlineThickness { get; set; } + public double UnderlineThickness { get; set; } /// /// Version identifier for the font program. @@ -86,32 +85,32 @@ /// /// The y-value of the top of a capital H. /// - public decimal CapHeight { get; set; } + public double CapHeight { get; set; } /// /// The y-value of the top of lowercase x. /// - public decimal XHeight { get; set; } + public double XHeight { get; set; } /// /// Generally the y-value of the top of lowercase d. /// - public decimal Ascender { get; set; } + public double Ascender { get; set; } /// /// The y-value of the bottom of lowercase p. /// - public decimal Descender { get; set; } + public double Descender { get; set; } /// /// Width of horizontal stems. /// - public decimal StdHw { get; set; } + public double StdHw { get; set; } /// /// Width of vertical stems. /// - public decimal StdVw { get; set; } + public double StdVw { get; set; } public int EscapeCharacter { get; set; } @@ -123,7 +122,7 @@ public bool IsFixedV { get; set; } - public AdobeFontMetricsBuilder(decimal afmVersion) + public AdobeFontMetricsBuilder(double afmVersion) { AfmVersion = afmVersion; Comments = new List(); diff --git a/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsParser.cs b/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsParser.cs index c56be615..4df929c1 100644 --- a/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsParser.cs +++ b/src/UglyToad.PdfPig.Fonts/AdobeFontMetrics/AdobeFontMetricsParser.cs @@ -344,7 +344,7 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics throw new InvalidFontFormatException($"The AFM file was not valid, it did not start with {StartFontMetrics}."); } - var version = ReadDecimal(bytes, stringBuilder); + var version = ReadDouble(bytes, stringBuilder); var builder = new AdobeFontMetricsBuilder(version); @@ -368,7 +368,7 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics builder.Weight = ReadLine(bytes, stringBuilder); break; case ItalicAngle: - builder.ItalicAngle = ReadDecimal(bytes, stringBuilder); + builder.ItalicAngle = ReadDouble(bytes, stringBuilder); break; case IsFixedPitch: builder.IsFixedPitch = ReadBool(bytes, stringBuilder); @@ -378,10 +378,10 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics ReadDouble(bytes, stringBuilder), ReadDouble(bytes, stringBuilder)); break; case UnderlinePosition: - builder.UnderlinePosition = ReadDecimal(bytes, stringBuilder); + builder.UnderlinePosition = ReadDouble(bytes, stringBuilder); break; case UnderlineThickness: - builder.UnderlineThickness = ReadDecimal(bytes, stringBuilder); + builder.UnderlineThickness = ReadDouble(bytes, stringBuilder); break; case Version: builder.Version = ReadLine(bytes, stringBuilder); @@ -393,37 +393,37 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics builder.EncodingScheme = ReadLine(bytes, stringBuilder); break; case MappingScheme: - builder.MappingScheme = (int)ReadDecimal(bytes, stringBuilder); + builder.MappingScheme = (int)ReadDouble(bytes, stringBuilder); break; case CharacterSet: builder.CharacterSet = ReadLine(bytes, stringBuilder); break; case EscChar: - builder.EscapeCharacter = (int) ReadDecimal(bytes, stringBuilder); + builder.EscapeCharacter = (int)ReadDouble(bytes, stringBuilder); break; case Characters: - builder.Characters = (int) ReadDecimal(bytes, stringBuilder); + builder.Characters = (int)ReadDouble(bytes, stringBuilder); break; case IsBaseFont: builder.IsBaseFont = ReadBool(bytes, stringBuilder); break; case CapHeight: - builder.CapHeight = ReadDecimal(bytes, stringBuilder); + builder.CapHeight = ReadDouble(bytes, stringBuilder); break; case XHeight: - builder.XHeight = ReadDecimal(bytes, stringBuilder); + builder.XHeight = ReadDouble(bytes, stringBuilder); break; case Ascender: - builder.Ascender = ReadDecimal(bytes, stringBuilder); + builder.Ascender = ReadDouble(bytes, stringBuilder); break; case Descender: - builder.Descender = ReadDecimal(bytes, stringBuilder); + builder.Descender = ReadDouble(bytes, stringBuilder); break; case StdHw: - builder.StdHw = ReadDecimal(bytes, stringBuilder); + builder.StdHw = ReadDouble(bytes, stringBuilder); break; case StdVw: - builder.StdVw = ReadDecimal(bytes, stringBuilder); + builder.StdVw = ReadDouble(bytes, stringBuilder); break; case CharWidth: builder.SetCharacterWidth(ReadDouble(bytes, stringBuilder), ReadDouble(bytes, stringBuilder)); @@ -435,7 +435,7 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics builder.IsFixedV = ReadBool(bytes, stringBuilder); break; case StartCharMetrics: - var count = (int)ReadDecimal(bytes, stringBuilder); + var count = (int)ReadDouble(bytes, stringBuilder); for (var i = 0; i < count; i++) { var metric = ReadCharacterMetric(bytes, stringBuilder); @@ -457,17 +457,9 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics return builder.Build(); } - private static decimal ReadDecimal(IInputBytes input, StringBuilder stringBuilder) - { - var str = ReadString(input, stringBuilder); - - return decimal.Parse(str, CultureInfo.InvariantCulture); - } - private static double ReadDouble(IInputBytes input, StringBuilder stringBuilder) { - var dec = ReadDecimal(input, stringBuilder); - return (double) dec; + return double.Parse(ReadString(input, stringBuilder), CultureInfo.InvariantCulture); } private static bool ReadBool(IInputBytes input, StringBuilder stringBuilder) @@ -484,7 +476,7 @@ namespace UglyToad.PdfPig.Fonts.AdobeFontMetrics throw new InvalidFontFormatException($"The AFM should have contained a boolean but instead contained: {boolean}."); } } - + private static string ReadString(IInputBytes input, StringBuilder stringBuilder) { stringBuilder.Clear(); diff --git a/src/UglyToad.PdfPig.Fonts/AdobeStylePrivateDictionary.cs b/src/UglyToad.PdfPig.Fonts/AdobeStylePrivateDictionary.cs index 9e431219..3467688f 100644 --- a/src/UglyToad.PdfPig.Fonts/AdobeStylePrivateDictionary.cs +++ b/src/UglyToad.PdfPig.Fonts/AdobeStylePrivateDictionary.cs @@ -12,12 +12,12 @@ /// /// Default value of . /// - public static readonly decimal DefaultBlueScale = 0.039625m; + public static readonly double DefaultBlueScale = 0.039625; /// /// Default value of . /// - public static readonly decimal DefaultExpansionFactor = 0.06m; + public static readonly double DefaultExpansionFactor = 0.06; /// /// Default value of . @@ -76,7 +76,7 @@ /// points on a 300-dpi device, you should set BlueScale to /// (11 − 0.49) ÷ 240 or 0.04379 /// - public decimal BlueScale { get; } + public double BlueScale { get; } /// /// Optional: The character space distance beyond the flat position of alignment zones @@ -97,22 +97,22 @@ /// /// Optional: The dominant width of horizontal stems vertically in character space units. /// - public decimal? StandardHorizontalWidth { get; } + public double? StandardHorizontalWidth { get; } /// /// Optional: The dominant width of vertical stems horizontally in character space units. /// - public decimal? StandardVerticalWidth { get; } + public double? StandardVerticalWidth { get; } /// /// Optional: Up to 12 numbers with the most common widths for horizontal stems vertically in character space units. /// - public IReadOnlyList StemSnapHorizontalWidths { get; } + public IReadOnlyList StemSnapHorizontalWidths { get; } /// /// Optional: Up to 12 numbers with the most common widths for vertical stems horizontally in character space units. /// - public IReadOnlyList StemSnapVerticalWidths { get; } + public IReadOnlyList StemSnapVerticalWidths { get; } /// /// Optional: At small sizes at low resolutions this controls whether bold characters should appear thicker using @@ -131,8 +131,8 @@ /// Optional: The limit for changing the size of a character bounding box for /// 1 counters during font processing. /// - public decimal ExpansionFactor { get; } - + public double ExpansionFactor { get; } + /// /// Creates a new . /// @@ -153,8 +153,8 @@ BlueShift = builder.BlueShift ?? DefaultBlueShift; StandardHorizontalWidth = builder.StandardHorizontalWidth; StandardVerticalWidth = builder.StandardVerticalWidth; - StemSnapHorizontalWidths = builder.StemSnapHorizontalWidths ?? EmptyArray.Instance; - StemSnapVerticalWidths = builder.StemSnapVerticalWidths ?? EmptyArray.Instance; + StemSnapHorizontalWidths = builder.StemSnapHorizontalWidths ?? EmptyArray.Instance; + StemSnapVerticalWidths = builder.StemSnapVerticalWidths ?? EmptyArray.Instance; ForceBold = builder.ForceBold ?? false; LanguageGroup = builder.LanguageGroup ?? DefaultLanguageGroup; ExpansionFactor = builder.ExpansionFactor ?? DefaultExpansionFactor; @@ -188,7 +188,7 @@ /// /// . /// - public decimal? BlueScale { get; set; } + public double? BlueScale { get; set; } /// /// . @@ -203,22 +203,22 @@ /// /// . /// - public decimal? StandardHorizontalWidth { get; set; } + public double? StandardHorizontalWidth { get; set; } /// /// . /// - public decimal? StandardVerticalWidth { get; set; } + public double? StandardVerticalWidth { get; set; } /// /// . /// - public IReadOnlyList StemSnapHorizontalWidths { get; set; } + public IReadOnlyList StemSnapHorizontalWidths { get; set; } /// /// . /// - public IReadOnlyList StemSnapVerticalWidths { get; set; } + public IReadOnlyList StemSnapVerticalWidths { get; set; } /// /// . @@ -229,11 +229,11 @@ /// . /// public int? LanguageGroup { get; set; } - + /// /// . /// - public decimal? ExpansionFactor { get; set; } + public double? ExpansionFactor { get; set; } } } } diff --git a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/CompactFontFormatFont.cs b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/CompactFontFormatFont.cs index 36c30c2e..88d5f7a3 100644 --- a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/CompactFontFormatFont.cs +++ b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/CompactFontFormatFont.cs @@ -37,7 +37,7 @@ /// /// The value of Italic Angle from the top dictionary or 0. /// - public decimal ItalicAngle => TopDictionary?.ItalicAngle ?? 0; + public double ItalicAngle => TopDictionary?.ItalicAngle ?? 0.0; internal CompactFontFormatFont(CompactFontFormatTopLevelDictionary topDictionary, CompactFontFormatPrivateDictionary privateDictionary, ICompactFontFormatCharset charset, @@ -157,7 +157,7 @@ /// /// Get the default width of x for the character. /// - protected virtual decimal GetDefaultWidthX(string characterName) + protected virtual double GetDefaultWidthX(string characterName) { return PrivateDictionary.DefaultWidthX; } @@ -165,7 +165,7 @@ /// /// Get the nominal width of x for the character. /// - protected virtual decimal GetNominalWidthX(string characterName) + protected virtual double GetNominalWidthX(string characterName) { return PrivateDictionary.NominalWidthX; } @@ -197,7 +197,7 @@ FdSelect = fdSelect; } - protected override decimal GetDefaultWidthX(string characterName) + protected override double GetDefaultWidthX(string characterName) { if (!TryGetPrivateDictionaryForCharacter(characterName, out var dictionary)) { @@ -207,7 +207,7 @@ return dictionary.DefaultWidthX; } - protected override decimal GetNominalWidthX(string characterName) + protected override double GetNominalWidthX(string characterName) { if (!TryGetPrivateDictionaryForCharacter(characterName, out var dictionary)) { diff --git a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatDictionaryReader.cs b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatDictionaryReader.cs index 8915c46e..eeb84521 100644 --- a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatDictionaryReader.cs +++ b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatDictionaryReader.cs @@ -91,7 +91,7 @@ return builder; } - private static decimal ReadRealNumber(CompactFontFormatData data) + private static double ReadRealNumber(CompactFontFormatData data) { var sb = new StringBuilder(); var done = false; @@ -170,10 +170,10 @@ if (sb.Length == 0) { - return 0m; + return 0.0; } - return hasExponent ? decimal.Parse(sb.ToString(), NumberStyles.Float, CultureInfo.InvariantCulture) : decimal.Parse(sb.ToString(), CultureInfo.InvariantCulture); + return hasExponent ? double.Parse(sb.ToString(), NumberStyles.Float, CultureInfo.InvariantCulture) : double.Parse(sb.ToString(), CultureInfo.InvariantCulture); } protected abstract void ApplyOperation(TBuilder builder, List operands, OperandKey operandKey, IReadOnlyList stringIndex); @@ -187,7 +187,7 @@ if (!operands[0].Int.HasValue) { - throw new InvalidOperationException($"The first operand for reading a string was not an integer. Got: {operands[0].Decimal}"); + throw new InvalidOperationException($"The first operand for reading a string was not an integer. Got: {operands[0].Double}"); } var index = operands[0].Int.Value; @@ -213,17 +213,17 @@ return new PdfRectangle(); } - return new PdfRectangle((double)operands[0].Decimal, (double)operands[1].Decimal, - (double)operands[2].Decimal, (double)operands[3].Decimal); + return new PdfRectangle(operands[0].Double, operands[1].Double, + operands[2].Double, operands[3].Double); } - protected static decimal[] ToArray(List operands) + protected static double[] ToArray(List operands) { - var result = new decimal[operands.Count]; + var result = new double[operands.Count]; for (int i = 0; i < result.Length; i++) { - result[i] = operands[i].Decimal; + result[i] = operands[i].Double; } return result; @@ -255,12 +255,12 @@ return results; } - results[0] = (int)operands[0].Decimal; + results[0] = (int)operands[0].Double; for (var i = 1; i < operands.Count; i++) { var previous = results[i - 1]; - var current = operands[i].Decimal; + var current = operands[i].Double; results[i] = (int)(previous + current); } @@ -268,21 +268,21 @@ return results; } - protected static decimal[] ReadDeltaToArray(List operands) + protected static double[] ReadDeltaToArray(List operands) { - var results = new decimal[operands.Count]; + var results = new double[operands.Count]; if (operands.Count == 0) { return results; } - results[0] = operands[0].Decimal; + results[0] = operands[0].Double; for (var i = 1; i < operands.Count; i++) { var previous = results[i - 1]; - var current = operands[i].Decimal; + var current = operands[i].Double; results[i] = previous + current; } @@ -294,18 +294,18 @@ { public int? Int { get; } - public decimal Decimal { get; } + public double Double { get; } public Operand(int integer) { Int = integer; - Decimal = integer; + Double = integer; } - public Operand(decimal d) + public Operand(double d) { Int = null; - Decimal = d; + Double = d; } } diff --git a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionary.cs b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionary.cs index 848ea258..12ec4fdc 100644 --- a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionary.cs +++ b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionary.cs @@ -7,7 +7,7 @@ /// /// Compatibility entry. /// - public decimal InitialRandomSeed { get; } + public double InitialRandomSeed { get; } /// /// The offset in bytes for the local subroutine index in this font. The value is relative to this private dictionary. @@ -17,12 +17,12 @@ /// /// If a glyph's width equals the default width X it can be omitted from the charstring. /// - public decimal DefaultWidthX { get; } + public double DefaultWidthX { get; } /// /// If not equal to , Glyph width is computed by adding the charstring width to the nominal width X value. /// - public decimal NominalWidthX { get; } + public double NominalWidthX { get; } /// /// @@ -44,19 +44,19 @@ public class Builder : BaseBuilder { - public decimal InitialRandomSeed { get; set; } + public double InitialRandomSeed { get; set; } public int? LocalSubroutineOffset { get; set; } /// /// If a glyph's width equals the default width X it can be omitted from the charstring. /// - public decimal DefaultWidthX { get; set; } + public double DefaultWidthX { get; set; } /// /// If not equal to , Glyph width is computed by adding the charstring width to the nominal width X value. /// - public decimal NominalWidthX { get; set; } + public double NominalWidthX { get; set; } public CompactFontFormatPrivateDictionary Build() { diff --git a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionaryReader.cs b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionaryReader.cs index 34b75e11..b6a3cb04 100644 --- a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionaryReader.cs +++ b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatPrivateDictionaryReader.cs @@ -31,10 +31,10 @@ dictionary.FamilyOtherBlues = ReadDeltaToIntArray(operands); break; case 10: - dictionary.StandardHorizontalWidth = operands[0].Decimal; + dictionary.StandardHorizontalWidth = operands[0].Double; break; case 11: - dictionary.StandardVerticalWidth = operands[0].Decimal; + dictionary.StandardVerticalWidth = operands[0].Double; break; case 12: { @@ -46,7 +46,7 @@ switch (operandKey.Byte1.Value) { case 9: - dictionary.BlueScale = operands[0].Decimal; + dictionary.BlueScale = operands[0].Double; break; case 10: dictionary.BlueShift = operands[0].Int; @@ -61,16 +61,16 @@ dictionary.StemSnapVerticalWidths = ReadDeltaToArray(operands); break; case 14: - dictionary.ForceBold = operands[0].Decimal == 1; + dictionary.ForceBold = operands[0].Double == 1; break; case 17: dictionary.LanguageGroup = operands[0].Int; break; case 18: - dictionary.ExpansionFactor = operands[0].Decimal; + dictionary.ExpansionFactor = operands[0].Double; break; case 19: - dictionary.InitialRandomSeed = operands[0].Decimal; + dictionary.InitialRandomSeed = operands[0].Double; break; } } @@ -79,10 +79,10 @@ dictionary.LocalSubroutineOffset = GetIntOrDefault(operands, -1); break; case 20: - dictionary.DefaultWidthX = operands[0].Decimal; + dictionary.DefaultWidthX = operands[0].Double; break; case 21: - dictionary.NominalWidthX = operands[0].Decimal; + dictionary.NominalWidthX = operands[0].Double; break; } } diff --git a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionary.cs b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionary.cs index 1f55ebc9..368a5b94 100644 --- a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionary.cs +++ b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionary.cs @@ -20,25 +20,25 @@ public bool IsFixedPitch { get; set; } - public decimal ItalicAngle { get; set; } + public double ItalicAngle { get; set; } - public decimal UnderlinePosition { get; set; } = -100; + public double UnderlinePosition { get; set; } = -100; - public decimal UnderlineThickness { get; set; } = 50; + public double UnderlineThickness { get; set; } = 50; - public decimal PaintType { get; set; } + public double PaintType { get; set; } public CompactFontFormatCharStringType CharStringType { get; set; } = CompactFontFormatCharStringType.Type2; public TransformationMatrix? FontMatrix { get; set; } - public decimal StrokeWidth { get; set; } + public double StrokeWidth { get; set; } - public decimal UniqueId { get; set; } + public double UniqueId { get; set; } public PdfRectangle FontBoundingBox { get; set; } = new PdfRectangle(0, 0, 0, 0); - public decimal[] Xuid { get; set; } + public double[] Xuid { get; set; } public int CharSetOffset { get; set; } = UnsetOffset; @@ -54,7 +54,7 @@ public string BaseFontName { get; set; } - public decimal[] BaseFontBlend { get; set; } + public double[] BaseFontBlend { get; set; } public bool IsCidFont { get; set; } @@ -91,7 +91,7 @@ public int Count { get; set; } = 8720; - public decimal UidBase { get; set; } + public double UidBase { get; set; } public int FontDictionaryArray { get; set; } @@ -106,13 +106,13 @@ public string Ordering { get; set; } - public decimal Supplement { get; set; } + public double Supplement { get; set; } } /// /// Defines the format of the CharString data contained within a Compact Font Format font. /// - internal enum CompactFontFormatCharStringType + internal enum CompactFontFormatCharStringType : byte { /// /// The Type 1 CharString format as defined by the Adobe Type 1 Font Format. diff --git a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionaryReader.cs b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionaryReader.cs index 3f626268..a07172b5 100644 --- a/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionaryReader.cs +++ b/src/UglyToad.PdfPig.Fonts/CompactFontFormat/Dictionaries/CompactFontFormatTopLevelDictionaryReader.cs @@ -50,19 +50,19 @@ dictionary.Copyright = GetString(operands, stringIndex); break; case 1: - dictionary.IsFixedPitch = operands[0].Decimal == 1; + dictionary.IsFixedPitch = operands[0].Double == 1; break; case 2: - dictionary.ItalicAngle = operands[0].Decimal; + dictionary.ItalicAngle = operands[0].Double; break; case 3: - dictionary.UnderlinePosition = operands[0].Decimal; + dictionary.UnderlinePosition = operands[0].Double; break; case 4: - dictionary.UnderlineThickness = operands[0].Decimal; + dictionary.UnderlineThickness = operands[0].Double; break; case 5: - dictionary.PaintType = operands[0].Decimal; + dictionary.PaintType = operands[0].Double; break; case 6: dictionary.CharStringType = (CompactFontFormatCharStringType)GetIntOrDefault(operands, 2); @@ -86,7 +86,7 @@ } break; case 8: - dictionary.StrokeWidth = operands[0].Decimal; + dictionary.StrokeWidth = operands[0].Double; break; case 20: dictionary.SyntheticBaseFontIndex = GetIntOrDefault(operands); @@ -143,7 +143,7 @@ } break; case 13: - dictionary.UniqueId = operands.Count > 0 ? operands[0].Decimal : 0; + dictionary.UniqueId = operands.Count > 0 ? operands[0].Double : 0; break; case 14: dictionary.Xuid = ToArray(operands); diff --git a/src/UglyToad.PdfPig.Fonts/TrueType/Tables/MaximumProfileTable.cs b/src/UglyToad.PdfPig.Fonts/TrueType/Tables/MaximumProfileTable.cs index ec44ba60..c146cccd 100644 --- a/src/UglyToad.PdfPig.Fonts/TrueType/Tables/MaximumProfileTable.cs +++ b/src/UglyToad.PdfPig.Fonts/TrueType/Tables/MaximumProfileTable.cs @@ -11,12 +11,12 @@ public TrueTypeHeaderTable DirectoryTable { get; } - public bool IsCompressedFontFormat => Version == 0.5m; + public bool IsCompressedFontFormat => Version == 0.5; /// /// The table version number. CFF fonts must use version 0.5 and only set number of glyphs. TrueType must use version 1. /// - public decimal Version { get; } + public double Version { get; } /// /// The number of glyphs in the font. @@ -26,7 +26,7 @@ public BasicMaximumProfileTable(TrueTypeHeaderTable directoryTable, float version, int numberOfGlyphs) { DirectoryTable = directoryTable; - Version = (decimal)version; + Version = version; NumberOfGlyphs = numberOfGlyphs; } diff --git a/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1ArrayTokenizer.cs b/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1ArrayTokenizer.cs index a432916e..7578a1f1 100644 --- a/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1ArrayTokenizer.cs +++ b/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1ArrayTokenizer.cs @@ -44,7 +44,7 @@ { if (char.IsNumber(part[0]) || part[0] == '-') { - if (decimal.TryParse(part, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var value)) + if (double.TryParse(part, NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out var value)) { tokens.Add(new NumericToken(value)); } diff --git a/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1EncryptedPortionParser.cs b/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1EncryptedPortionParser.cs index 670854c9..cf6bb28b 100644 --- a/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1EncryptedPortionParser.cs +++ b/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1EncryptedPortionParser.cs @@ -123,27 +123,27 @@ } case Type1Symbols.StdHorizontalStemWidth: { - var widths = ReadArrayValues(tokenizer, x => x.AsDecimal()); + var widths = ReadArrayValues(tokenizer, x => x.AsDouble()); var width = widths[0]; builder.StandardHorizontalWidth = width; break; } case Type1Symbols.StdVerticalStemWidth: { - var widths = ReadArrayValues(tokenizer, x => x.AsDecimal()); + var widths = ReadArrayValues(tokenizer, x => x.AsDouble()); var width = widths[0]; builder.StandardVerticalWidth = width; break; } case Type1Symbols.StemSnapHorizontalWidths: { - var widths = ReadArrayValues(tokenizer, x => x.AsDecimal()); + var widths = ReadArrayValues(tokenizer, x => x.AsDouble()); builder.StemSnapHorizontalWidths = widths; break; } case Type1Symbols.StemSnapVerticalWidths: { - var widths = ReadArrayValues(tokenizer, x => x.AsDecimal()); + var widths = ReadArrayValues(tokenizer, x => x.AsDouble()); builder.StemSnapVerticalWidths = widths; break; } @@ -603,7 +603,7 @@ return results; } - private static decimal ReadNumeric(Type1Tokenizer tokenizer) + private static double ReadNumeric(Type1Tokenizer tokenizer) { var token = tokenizer.GetNext(); @@ -612,7 +612,7 @@ throw new InvalidOperationException($"Expected to read a numeric token, instead got: {token}."); } - return token.AsDecimal(); + return token.AsDouble(); } private static bool ReadBoolean(Type1Tokenizer tokenizer) diff --git a/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1Token.cs b/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1Token.cs index 107bfe2e..414b4813 100644 --- a/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1Token.cs +++ b/src/UglyToad.PdfPig.Fonts/Type1/Parser/Type1Token.cs @@ -42,12 +42,12 @@ public int AsInt() { - return (int)AsDecimal(); + return (int)AsDouble(); } - public decimal AsDecimal() + public double AsDouble() { - return decimal.Parse(Text, CultureInfo.InvariantCulture); + return double.Parse(Text, CultureInfo.InvariantCulture); } public bool AsBool() diff --git a/src/UglyToad.PdfPig.Tests/Core/TransformationMatrixTests.cs b/src/UglyToad.PdfPig.Tests/Core/TransformationMatrixTests.cs index 40ad603d..19a9ab63 100644 --- a/src/UglyToad.PdfPig.Tests/Core/TransformationMatrixTests.cs +++ b/src/UglyToad.PdfPig.Tests/Core/TransformationMatrixTests.cs @@ -10,19 +10,19 @@ { new object[] { - new decimal[] + new double[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 }, - new decimal[] + new double[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 }, - new decimal[] + new double[] { 1, 0, 0, 0, 1, 0, @@ -31,19 +31,19 @@ }, new object[] { - new decimal[] + new double[] { 65, 9, 3, 5, 2, 7, 11, 1, 6 }, - new decimal[] + new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, - new decimal[] + new double[] { 122, 199, 276, 62, 76, 90, @@ -52,19 +52,19 @@ }, new object[] { - new decimal[] + new double[] { 3, 5, 7, 11, 13, -3, 17, -6, -9 }, - new decimal[] + new double[] { 5, 4, 3, 3, 7, 12, 1, 0, 6 }, - new decimal[] + new double[] { 37, 47, 111, 91, 135, 171, @@ -75,7 +75,7 @@ [Theory] [MemberData(nameof(MultiplicationData))] - public void MultipliesCorrectly(decimal[] a, decimal[] b, decimal[] expected) + public void MultipliesCorrectly(double[] a, double[] b, double[] expected) { var matrixA = TransformationMatrix.FromArray(a); var matrixB = TransformationMatrix.FromArray(b); @@ -156,7 +156,7 @@ public void InversesCorrectly(double[] a, double[] expected) { var matrixA = TransformationMatrix.FromArray(a); - + var expectedMatrix = TransformationMatrix.FromArray(expected); var result = matrixA.Inverse(); diff --git a/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType0Tests.cs b/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType0Tests.cs index 4dc2c959..e5b6ece9 100644 --- a/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType0Tests.cs +++ b/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType0Tests.cs @@ -16,7 +16,7 @@ private static ArrayToken GetArrayToken(params double[] data) { - return new ArrayToken(data.Select(v => new NumericToken((decimal)v)).ToArray()); + return new ArrayToken(data.Select(v => new NumericToken(v)).ToArray()); } [Fact] diff --git a/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType2Tests.cs b/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType2Tests.cs index a9a57214..69b33e7f 100644 --- a/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType2Tests.cs +++ b/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType2Tests.cs @@ -15,12 +15,12 @@ DictionaryToken dictionaryToken = new DictionaryToken(new Dictionary() { { NameToken.FunctionType, new NumericToken(2) }, - { NameToken.Domain, new ArrayToken(domain.Select(v => new NumericToken((decimal)v)).ToArray()) }, - { NameToken.Range, new ArrayToken(range.Select(v => new NumericToken((decimal)v)).ToArray()) }, + { NameToken.Domain, new ArrayToken(domain.Select(v => new NumericToken(v)).ToArray()) }, + { NameToken.Range, new ArrayToken(range.Select(v => new NumericToken(v)).ToArray()) }, - { NameToken.C0, new ArrayToken(c0.Select(v => new NumericToken((decimal)v)).ToArray()) }, - { NameToken.C1, new ArrayToken(c1.Select(v => new NumericToken((decimal)v)).ToArray()) }, - { NameToken.N, new NumericToken((decimal)n) }, + { NameToken.C0, new ArrayToken(c0.Select(v => new NumericToken(v)).ToArray()) }, + { NameToken.C1, new ArrayToken(c1.Select(v => new NumericToken(v)).ToArray()) }, + { NameToken.N, new NumericToken(n) }, }); var func = PdfFunctionParser.Create(dictionaryToken, new TestPdfTokenScanner(), new TestFilterProvider()); diff --git a/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType4Tests.cs b/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType4Tests.cs index 6c0fc025..6054e046 100644 --- a/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType4Tests.cs +++ b/src/UglyToad.PdfPig.Tests/Functions/PdfFunctionType4Tests.cs @@ -16,8 +16,8 @@ DictionaryToken dictionaryToken = new DictionaryToken(new Dictionary() { { NameToken.FunctionType, new NumericToken(4) }, - { NameToken.Domain, new ArrayToken(domain.Select(v => new NumericToken((decimal)v)).ToArray()) }, - { NameToken.Range, new ArrayToken(range.Select(v => new NumericToken((decimal)v)).ToArray()) }, + { NameToken.Domain, new ArrayToken(domain.Select(v => new NumericToken(v)).ToArray()) }, + { NameToken.Range, new ArrayToken(range.Select(v => new NumericToken(v)).ToArray()) }, }); var data = Encoding.ASCII.GetBytes(function); // OtherEncodings.Iso88591.GetBytes(function); diff --git a/src/UglyToad.PdfPig.Tests/Graphics/Operations/GraphicsStateOperationTests.cs b/src/UglyToad.PdfPig.Tests/Graphics/Operations/GraphicsStateOperationTests.cs index 3c7122da..b48814f2 100644 --- a/src/UglyToad.PdfPig.Tests/Graphics/Operations/GraphicsStateOperationTests.cs +++ b/src/UglyToad.PdfPig.Tests/Graphics/Operations/GraphicsStateOperationTests.cs @@ -99,10 +99,6 @@ { result[i] = 0.5; } - else if (type == typeof(decimal)) - { - result[i] = 0.5m; - } else if (type == typeof(int)) { result[i] = 1; @@ -114,13 +110,6 @@ 1, 0, 0, 1, 2, 5 }; } - else if (type == typeof(decimal[]) || type == typeof(IReadOnlyList)) - { - result[i] = new decimal[] - { - 1, 0, 0, 1, 2, 5 - }; - } else if (type == typeof(IReadOnlyList)) { result[i] = new IToken[] { new StringToken("Text") }; diff --git a/src/UglyToad.PdfPig.Tokens/NumericToken.cs b/src/UglyToad.PdfPig.Tokens/NumericToken.cs index 2d6371e1..72461f3d 100644 --- a/src/UglyToad.PdfPig.Tokens/NumericToken.cs +++ b/src/UglyToad.PdfPig.Tokens/NumericToken.cs @@ -158,16 +158,6 @@ /// public double Double => Data; - /// - /// Create a . - /// - /// The number to represent. - //[Obsolete("Use double constructor instead.")] - public NumericToken(decimal value) - { - Data = (double)value; - } - /// /// Create a . /// diff --git a/src/UglyToad.PdfPig/Content/PageRotationDegrees.cs b/src/UglyToad.PdfPig/Content/PageRotationDegrees.cs index 38bd219e..77819b85 100644 --- a/src/UglyToad.PdfPig/Content/PageRotationDegrees.cs +++ b/src/UglyToad.PdfPig/Content/PageRotationDegrees.cs @@ -21,7 +21,7 @@ /// /// Get the rotation expressed in radians (anti-clockwise). /// - public decimal Radians + public double Radians { get { @@ -30,11 +30,11 @@ case 0: return 0; case 90: - return -(decimal)(0.5 * Math.PI); + return -0.5 * Math.PI; case 180: - return -(decimal) Math.PI; + return -Math.PI; case 270: - return -(decimal) (1.5 * Math.PI); + return -1.5 * Math.PI; default: throw new InvalidOperationException($"Invalid value for rotation: {Value}."); } diff --git a/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs b/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs index a9fe5a6c..61d27c16 100644 --- a/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs +++ b/src/UglyToad.PdfPig/Graphics/CurrentGraphicsState.cs @@ -120,7 +120,7 @@ namespace UglyToad.PdfPig.Graphics /// /// The precision for rendering color gradients on the output device. /// - public decimal Smoothness { get; set; } = 0; + public double Smoothness { get; set; } = 0; #endregion /// diff --git a/src/UglyToad.PdfPig/Graphics/Operations/OperationWriteHelper.cs b/src/UglyToad.PdfPig/Graphics/Operations/OperationWriteHelper.cs index 67351b73..9d13aebc 100644 --- a/src/UglyToad.PdfPig/Graphics/Operations/OperationWriteHelper.cs +++ b/src/UglyToad.PdfPig/Graphics/Operations/OperationWriteHelper.cs @@ -36,37 +36,14 @@ stream.WriteByte(NewLine); } - public static void WriteDecimal(this Stream stream, decimal value) - { - stream.WriteText(value.ToString("G", CultureInfo.InvariantCulture)); - } - - public static void WriteDecimal(this Stream stream, double value) - { - stream.WriteText(value.ToString("G", CultureInfo.InvariantCulture)); - } - - public static void WriteDecimal(this Stream stream, int value) - { - stream.WriteText(value.ToString("G", CultureInfo.InvariantCulture)); - } - public static void WriteDouble(this Stream stream, double value) { stream.WriteText(value.ToString("G", CultureInfo.InvariantCulture)); } - public static void WriteNumberText(this Stream stream, decimal number, string text) - { - stream.WriteDecimal(number); - stream.WriteWhiteSpace(); - stream.WriteText(text); - stream.WriteNewLine(); - } - public static void WriteNumberText(this Stream stream, int number, string text) { - stream.WriteDecimal(number); + stream.WriteDouble(number); stream.WriteWhiteSpace(); stream.WriteText(text); stream.WriteNewLine(); diff --git a/src/UglyToad.PdfPig/Graphics/ReflectionGraphicsStateOperationFactory.cs b/src/UglyToad.PdfPig/Graphics/ReflectionGraphicsStateOperationFactory.cs index 5fc29872..ef52e41c 100644 --- a/src/UglyToad.PdfPig/Graphics/ReflectionGraphicsStateOperationFactory.cs +++ b/src/UglyToad.PdfPig/Graphics/ReflectionGraphicsStateOperationFactory.cs @@ -421,7 +421,7 @@ namespace UglyToad.PdfPig.Graphics throw new InvalidOperationException($"Fewer operands {operands.Count} found than required ({offset + 1}) for operator: {op.Data}."); } - if (parameter.ParameterType == typeof(decimal)) + if (parameter.ParameterType == typeof(double)) { if (operands[offset] is NumericToken numeric) { @@ -429,7 +429,7 @@ namespace UglyToad.PdfPig.Graphics } else { - throw new InvalidOperationException($"Expected a decimal parameter for operation type {operationType.FullName}. Instead got: {operands[offset]}"); + throw new InvalidOperationException($"Expected a double parameter for operation type {operationType.FullName}. Instead got: {operands[offset]}"); } offset++; @@ -477,7 +477,7 @@ namespace UglyToad.PdfPig.Graphics } else { - throw new InvalidOperationException($"Expected a decimal array parameter for operation type {operationType.FullName}. Instead got: {operands[offset]}"); + throw new InvalidOperationException($"Expected a NameToken parameter for operation type {operationType.FullName}. Instead got: {operands[offset]}"); } offset++; diff --git a/src/UglyToad.PdfPig/Util/PatternParser.cs b/src/UglyToad.PdfPig/Util/PatternParser.cs index 01ee2b63..c2fded9a 100644 --- a/src/UglyToad.PdfPig/Util/PatternParser.cs +++ b/src/UglyToad.PdfPig/Util/PatternParser.cs @@ -47,7 +47,7 @@ else { // optional - Default value: the identity matrix [1 0 0 1 0 0] - matrix = TransformationMatrix.FromArray(new decimal[] { 1, 0, 0, 1, 0, 0 }); + matrix = TransformationMatrix.FromArray(new double[] { 1, 0, 0, 1, 0, 0 }); } DictionaryToken patternExtGState = null; diff --git a/src/UglyToad.PdfPig/Util/ShadingParser.cs b/src/UglyToad.PdfPig/Util/ShadingParser.cs index 6b974415..5ffc5f0a 100644 --- a/src/UglyToad.PdfPig/Util/ShadingParser.cs +++ b/src/UglyToad.PdfPig/Util/ShadingParser.cs @@ -151,7 +151,7 @@ else { // Optional - Default value: the identity matrix [1 0 0 1 0 0] - matrix = TransformationMatrix.FromArray(new decimal[] { 1, 0, 0, 1, 0, 0 }); + matrix = TransformationMatrix.FromArray(new double[] { 1, 0, 0, 1, 0, 0 }); } if (!shadingDictionary.ContainsKey(NameToken.Function)) diff --git a/src/UglyToad.PdfPig/Writer/Fonts/TrueTypeWritingFont.cs b/src/UglyToad.PdfPig/Writer/Fonts/TrueTypeWritingFont.cs index 8e0afc4f..c60ec949 100644 --- a/src/UglyToad.PdfPig/Writer/Fonts/TrueTypeWritingFont.cs +++ b/src/UglyToad.PdfPig/Writer/Fonts/TrueTypeWritingFont.cs @@ -63,7 +63,7 @@ var bbox = font.TableRegister.HeaderTable.Bounds; - var scaling = 1000m / font.TableRegister.HeaderTable.UnitsPerEm; + var scaling = 1000.0 / font.TableRegister.HeaderTable.UnitsPerEm; var descriptorDictionary = new Dictionary { { NameToken.Type, NameToken.FontDescriptor }, @@ -71,7 +71,7 @@ // TODO: get flags TrueTypeEmbedder.java { NameToken.Flags, new NumericToken((int)FontDescriptorFlags.Symbolic) }, { NameToken.FontBbox, GetBoundingBox(bbox, scaling) }, - { NameToken.ItalicAngle, new NumericToken((decimal)postscript.ItalicAngle) }, + { NameToken.ItalicAngle, new NumericToken(postscript.ItalicAngle) }, { NameToken.Ascent, new NumericToken(Math.Round(hhead.Ascent * scaling, 2)) }, { NameToken.Descent, new NumericToken(Math.Round(hhead.Descent * scaling, 2)) }, { NameToken.CapHeight, new NumericToken(90) }, @@ -91,7 +91,7 @@ descriptorDictionary[NameToken.Xheight] = new NumericToken(twoPlus.XHeight); } - descriptorDictionary[NameToken.StemV] = new NumericToken(((decimal)bbox.Width) * scaling * 0.13m); + descriptorDictionary[NameToken.StemV] = new NumericToken(bbox.Width * scaling * 0.13); var lastCharacter = 0; var widths = new List { NumericToken.Zero }; @@ -103,7 +103,7 @@ } var glyphId = font.WindowsUnicodeCMap.CharacterCodeToGlyphIndex(kvp.Key); - var width = decimal.Round(font.TableRegister.HorizontalMetricsTable.GetAdvanceWidth(glyphId) * scaling, 2); + var width = Math.Round(font.TableRegister.HorizontalMetricsTable.GetAdvanceWidth(glyphId) * scaling, 2); widths.Add(new NumericToken(width)); } @@ -162,14 +162,14 @@ } } - private static ArrayToken GetBoundingBox(PdfRectangle boundingBox, decimal scaling) + private static ArrayToken GetBoundingBox(PdfRectangle boundingBox, double scaling) { return new ArrayToken(new[] { - new NumericToken(Math.Round((decimal)boundingBox.Left * scaling, 2)), - new NumericToken(Math.Round((decimal)boundingBox.Bottom * scaling, 2)), - new NumericToken(Math.Round((decimal)boundingBox.Right * scaling, 2)), - new NumericToken(Math.Round((decimal)boundingBox.Top * scaling, 2)) + new NumericToken(Math.Round(boundingBox.Left * scaling, 2)), + new NumericToken(Math.Round(boundingBox.Bottom * scaling, 2)), + new NumericToken(Math.Round(boundingBox.Right * scaling, 2)), + new NumericToken(Math.Round(boundingBox.Top * scaling, 2)) }); } } diff --git a/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs b/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs index 2bc6f960..96f17444 100644 --- a/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs +++ b/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs @@ -592,7 +592,7 @@ namespace UglyToad.PdfPig.Writer } const int desiredLeafSize = 25; // allow customization at some point? - var numLeafs = (int)Math.Ceiling(Decimal.Divide(Pages.Count, desiredLeafSize)); + var numLeafs = (int)Math.Ceiling(Pages.Count / (double)desiredLeafSize); var leafRefs = new List(); var leafChildren = new List>(); @@ -772,7 +772,7 @@ namespace UglyToad.PdfPig.Writer { var currentTreeDepth = (int)Math.Ceiling(Math.Log(pagesNodes.Count, desiredLeafSize)); var perBranch = (int)Math.Ceiling(Math.Pow(desiredLeafSize, currentTreeDepth - 1)); - var branches = (int)Math.Ceiling(decimal.Divide(pagesNodes.Count, (decimal)perBranch)); + var branches = (int)Math.Ceiling(pagesNodes.Count / (double)perBranch); for (var i = 0; i < branches; i++) { var part = pagesNodes.Skip(i * perBranch).Take(perBranch).ToList(); @@ -837,10 +837,10 @@ namespace UglyToad.PdfPig.Writer { return new ArrayToken(new[] { - new NumericToken((decimal)rectangle.BottomLeft.X), - new NumericToken((decimal)rectangle.BottomLeft.Y), - new NumericToken((decimal)rectangle.TopRight.X), - new NumericToken((decimal)rectangle.TopRight.Y) + new NumericToken(rectangle.BottomLeft.X), + new NumericToken(rectangle.BottomLeft.Y), + new NumericToken(rectangle.TopRight.X), + new NumericToken(rectangle.TopRight.Y) }); } diff --git a/src/UglyToad.PdfPig/Writer/PdfPageBuilder.cs b/src/UglyToad.PdfPig/Writer/PdfPageBuilder.cs index e1688250..0e86e9c0 100644 --- a/src/UglyToad.PdfPig/Writer/PdfPageBuilder.cs +++ b/src/UglyToad.PdfPig/Writer/PdfPageBuilder.cs @@ -380,7 +380,7 @@ } /// - /// Sets the stroke color with the exact decimal value between 0 and 1 for any following operations to the RGB value. Use to reset. + /// Sets the stroke color with the exact value between 0 and 1 for any following operations to the RGB value. Use to reset. /// /// Red - 0 to 1 /// Green - 0 to 1 @@ -1063,12 +1063,12 @@ { if (value < 0) { - throw new ArgumentOutOfRangeException(argument, $"Provided decimal for RGB color was less than zero: {value}."); + throw new ArgumentOutOfRangeException(argument, $"Provided double for RGB color was less than zero: {value}."); } if (value > 1) { - throw new ArgumentOutOfRangeException(argument, $"Provided decimal for RGB color was greater than one: {value}."); + throw new ArgumentOutOfRangeException(argument, $"Provided double for RGB color was greater than one: {value}."); } return value;