Blame SOURCES/Make-font_manager-ignore-KeyErrors-for-bad-fonts.patch

6ae730
From faa88c94e36ae1c51ca75c1a8eee87d7148156e3 Mon Sep 17 00:00:00 2001
6ae730
From: Damon McDougall <damon.mcdougall@gmail.com>
6ae730
Date: Mon, 17 Dec 2012 10:15:48 -0600
6ae730
Subject: [PATCH 1/5] Make font_manager ignore KeyErrors for bad fonts
6ae730
6ae730
Signed-off-by: John Kacur <jkacur@redhat.com>
6ae730
---
6ae730
 lib/matplotlib/font_manager.py | 10 ++++++++--
6ae730
 1 file changed, 8 insertions(+), 2 deletions(-)
6ae730
6ae730
diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py
6ae730
index 4ba6f80d0145..f9418dc5b4bd 100644
6ae730
--- a/lib/matplotlib/font_manager.py
6ae730
+++ b/lib/matplotlib/font_manager.py
6ae730
@@ -565,7 +565,10 @@ def createFontList(fontfiles, fontext='ttf'):
6ae730
             except RuntimeError:
6ae730
                 verbose.report("Could not parse font file %s"%fpath)
6ae730
                 continue
6ae730
-            prop = afmFontProperty(fpath, font)
6ae730
+            try:
6ae730
+                prop = afmFontProperty(fpath, font)
6ae730
+            except KeyError:
6ae730
+                continue
6ae730
         else:
6ae730
             try:
6ae730
                 font = ft2font.FT2Font(str(fpath))
6ae730
@@ -576,7 +579,10 @@ def createFontList(fontfiles, fontext='ttf'):
6ae730
                 verbose.report("Cannot handle unicode filenames")
6ae730
                 #print >> sys.stderr, 'Bad file is', fpath
6ae730
                 continue
6ae730
-            prop = ttfFontProperty(font)
6ae730
+            try:
6ae730
+                prop = ttfFontProperty(font)
6ae730
+            except KeyError:
6ae730
+                continue
6ae730
 
6ae730
         fontlist.append(prop)
6ae730
     return fontlist
6ae730
-- 
6ae730
2.20.1
6ae730