From 982c33193504922a6ec7ddf49bbfee1f9abd4422 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sat, 20 Jun 2020 12:46:41 +0100 Subject: [PATCH 1/2] re-use truetype parser for opentype cid fonts --- .../PdfFonts/Parser/Parts/CidFontFactory.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs b/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs index b3e3b9e4..01f11a96 100644 --- a/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs +++ b/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs @@ -114,9 +114,11 @@ switch (descriptor.FontFile.FileType) { case DescriptorFontFile.FontFileType.TrueType: + { var input = new TrueTypeDataBytes(new ByteArrayInputBytes(fontFile)); var ttf = TrueTypeFontParser.Parse(input); return new PdfCidTrueTypeFont(ttf); + } case DescriptorFontFile.FontFileType.FromSubtype: { if (!DirectObjectFinder.TryGet(descriptor.FontFile.ObjectKey, pdfScanner, out StreamToken str)) @@ -139,14 +141,12 @@ if (subtypeName == NameToken.OpenType) { - + var bytes = str.Decode(filterProvider); + var ttf = TrueTypeFontParser.Parse(new TrueTypeDataBytes(new ByteArrayInputBytes(bytes))); + return new PdfCidTrueTypeFont(ttf); } - else - { - throw new PdfDocumentFormatException($"Unexpected subtype for CID font: {subtypeName}."); - } - - throw new NotSupportedException($"Cannot read CID font from subtype: {subtypeName}."); + + throw new PdfDocumentFormatException($"Unexpected subtype for CID font: {subtypeName}."); } default: throw new NotSupportedException("Currently only TrueType fonts are supported."); From 5fb04582a749c12828ffd9b4e1cdb184d769c240 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sat, 20 Jun 2020 12:54:31 +0100 Subject: [PATCH 2/2] 0.1.2-alpha003 --- src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj | 2 +- .../UglyToad.PdfPig.DocumentLayoutAnalysis.csproj | 2 +- src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj | 2 +- .../UglyToad.PdfPig.Tokenization.csproj | 2 +- src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj | 2 +- src/UglyToad.PdfPig/UglyToad.PdfPig.csproj | 2 +- tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj b/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj index 00a13bb4..b6fd4fcd 100644 --- a/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj +++ b/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45;net451;net452;net46;net461;net462;net47 latest - 0.1.2-alpha002 + 0.1.2-alpha003 False true true diff --git a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj index e331fdda..f8a20495 100644 --- a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj +++ b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45;net451;net452;net46;net461;net462;net47 latest - 0.1.2-alpha002 + 0.1.2-alpha003 False true true diff --git a/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj b/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj index 15fd446a..1962a3c1 100644 --- a/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj +++ b/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45;net451;net452;net46;net461;net462;net47 latest - 0.1.2-alpha002 + 0.1.2-alpha003 False true true diff --git a/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj b/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj index 7faa683d..984178f5 100644 --- a/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj +++ b/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45;net451;net452;net46;net461;net462;net47 latest - 0.1.2-alpha002 + 0.1.2-alpha003 False true true diff --git a/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj b/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj index 400156a5..7048746d 100644 --- a/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj +++ b/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45;net451;net452;net46;net461;net462;net47 latest - 0.1.2-alpha002 + 0.1.2-alpha003 False true true diff --git a/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj b/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj index d0279e83..eca28749 100644 --- a/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj +++ b/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj @@ -2,7 +2,7 @@ netstandard2.0;net45;net451;net452;net46;net461;net462;net47 latest - 0.1.2-alpha002 + 0.1.2-alpha003 False true true diff --git a/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj b/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj index c690b864..0c8dfb72 100644 --- a/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj +++ b/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj @@ -12,7 +12,7 @@ PDF;Reader;Document;Adobe;PDFBox;PdfPig;pdf-extract https://github.com/UglyToad/PdfPig true - 0.1.2-alpha002 + 0.1.2-alpha003 0.1.1.0 0.1.1.0 https://raw.githubusercontent.com/UglyToad/PdfPig/master/documentation/pdfpig.png