From 48522ae1a5fa41c875cea0a78b471a11e90c3374 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Sun, 19 Jul 2020 14:36:11 +0100 Subject: [PATCH] support indirect name tokens for cidtogidmap in cid fonts #191 --- .../PdfFonts/Parser/Parts/CidFontFactory.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs b/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs index 01f11a96..01f9d175 100644 --- a/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs +++ b/src/UglyToad.PdfPig/PdfFonts/Parser/Parts/CidFontFactory.cs @@ -291,12 +291,15 @@ return new CharacterIdentifierToGlyphIndexMap(); } - if (entry is NameToken) + if (DirectObjectFinder.TryGet(entry, pdfScanner, out NameToken _)) { return new CharacterIdentifierToGlyphIndexMap(); } - var stream = DirectObjectFinder.Get(entry, pdfScanner); + if (!DirectObjectFinder.TryGet(entry, pdfScanner, out StreamToken stream)) + { + throw new PdfDocumentFormatException($"No stream or name token found for /CIDToGIDMap in dictionary: {dictionary}."); + } var bytes = stream.Decode(filterProvider);