From 59c36a7ddd704d4efacbfea33bcee5b8b9e54227 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sun, 7 Jan 2018 15:38:43 +0000 Subject: [PATCH] fix a bug with t* operator due to incorrect specification. add generic name to type 3 fonts. --- .../Integration/SwedishTouringCarChampionshipTests.cs | 4 ++-- src/UglyToad.Pdf/Fonts/Parser/Handlers/Type3FontHandler.cs | 2 +- src/UglyToad.Pdf/Fonts/Simple/Type3Font.cs | 3 +++ .../Graphics/Operations/TextPositioning/MoveToNextLine.cs | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/UglyToad.Pdf.Tests/Integration/SwedishTouringCarChampionshipTests.cs b/src/UglyToad.Pdf.Tests/Integration/SwedishTouringCarChampionshipTests.cs index 1eb742c9..3f1817bf 100644 --- a/src/UglyToad.Pdf.Tests/Integration/SwedishTouringCarChampionshipTests.cs +++ b/src/UglyToad.Pdf.Tests/Integration/SwedishTouringCarChampionshipTests.cs @@ -65,9 +65,9 @@ //[Fact] //public void localFileTest() //{ - // //using (var document = PdfDocument.Open(@"C:\Users\eliot\Downloads\Document (1).pdf")) + // using (var document = PdfDocument.Open(@"C:\Users\eliot\Downloads\Document (1).pdf")) // { - // //var page = document.GetPage(1); + // var page = document.GetPage(1); // } //} } diff --git a/src/UglyToad.Pdf/Fonts/Parser/Handlers/Type3FontHandler.cs b/src/UglyToad.Pdf/Fonts/Parser/Handlers/Type3FontHandler.cs index e7720453..e198b651 100644 --- a/src/UglyToad.Pdf/Fonts/Parser/Handlers/Type3FontHandler.cs +++ b/src/UglyToad.Pdf/Fonts/Parser/Handlers/Type3FontHandler.cs @@ -54,7 +54,7 @@ } } - return new Type3Font(CosName.UNCHANGED, boundingBox, fontMatrix, encoding, firstCharacter, + return new Type3Font(CosName.TYPE3, boundingBox, fontMatrix, encoding, firstCharacter, lastCharacter, widths, toUnicodeCMap); } diff --git a/src/UglyToad.Pdf/Fonts/Simple/Type3Font.cs b/src/UglyToad.Pdf/Fonts/Simple/Type3Font.cs index 207eed1d..c569913f 100644 --- a/src/UglyToad.Pdf/Fonts/Simple/Type3Font.cs +++ b/src/UglyToad.Pdf/Fonts/Simple/Type3Font.cs @@ -19,6 +19,9 @@ private readonly decimal[] widths; private readonly ToUnicodeCMap toUnicodeCMap; + /// + /// Type 3 fonts are usually unnamed. + /// public CosName Name { get; } public bool IsVertical { get; } = false; diff --git a/src/UglyToad.Pdf/Graphics/Operations/TextPositioning/MoveToNextLine.cs b/src/UglyToad.Pdf/Graphics/Operations/TextPositioning/MoveToNextLine.cs index 96898fdf..abf7b35c 100644 --- a/src/UglyToad.Pdf/Graphics/Operations/TextPositioning/MoveToNextLine.cs +++ b/src/UglyToad.Pdf/Graphics/Operations/TextPositioning/MoveToNextLine.cs @@ -6,7 +6,8 @@ /// Move to the start of the next line. /// /// - /// This performs this operation: 0 Tl Td + /// This performs this operation: 0 -Tl Td + /// The offset is negative leading text (Tl) value, this is incorrect in the specification. /// internal class MoveToNextLine : IGraphicsStateOperation { @@ -21,7 +22,7 @@ public void Run(IOperationContext operationContext, IResourceStore resourceStore) { - var tdOperation = new MoveToNextLineWithOffset(0, operationContext.GetCurrentState().FontState.Leading); + var tdOperation = new MoveToNextLineWithOffset(0, -1 * operationContext.GetCurrentState().FontState.Leading); tdOperation.Run(operationContext, resourceStore); }