From 3396820d490cae0fd2a0f5b8a2c3d00bc4268d88 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Thu, 9 May 2019 19:14:11 +0100 Subject: [PATCH] throw more descriptive exception when loading system font finder --- .../Fonts/SystemFonts/SystemFontFinder.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/UglyToad.PdfPig/Fonts/SystemFonts/SystemFontFinder.cs b/src/UglyToad.PdfPig/Fonts/SystemFonts/SystemFontFinder.cs index 74547523..ca531bb4 100644 --- a/src/UglyToad.PdfPig/Fonts/SystemFonts/SystemFontFinder.cs +++ b/src/UglyToad.PdfPig/Fonts/SystemFonts/SystemFontFinder.cs @@ -34,7 +34,15 @@ {"ZapfDingbats", new[] {"ZapfDingbatsITC", "Dingbats", "MS-Gothic"}} }; - var names = Standard14.GetNames(); + HashSet names; + try + { + names = Standard14.GetNames(); + } + catch (Exception ex) + { + throw new InvalidOperationException("Failed to load the Standard 14 fonts from the assembly's resources.", ex); + } foreach (var name in names) { @@ -48,7 +56,7 @@ } else { - dict[name] = new[] {value}; + dict[name] = new[] { value }; } } } @@ -149,7 +157,7 @@ private TrueTypeFontProgram GetTrueTypeFontNamed(string name) { -if (cache.TryGetValue(name, out var result)) + if (cache.TryGetValue(name, out var result)) { return result; }