From b8b947ffa4ea0f5c8152cabaefa779512385e6cd Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Thu, 21 Aug 2014 03:51:20 +1200 Subject: [PATCH] [IMP] catch & warn about any TTFontFile exception It turns out TTFontFile can throw not only TTFError (generic) and KeyError, but also ValueError (unknown cmap) and maybe others. Just catch Exception, warn that the font couldn't be loaded and report why. --- openerp/addons/base/res/res_font.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/openerp/addons/base/res/res_font.py b/openerp/addons/base/res/res_font.py index 767fc3754c1..af21ea708c4 100644 --- a/openerp/addons/base/res/res_font.py +++ b/openerp/addons/base/res/res_font.py @@ -98,17 +98,8 @@ class res_font(osv.Model): font = ttfonts.TTFontFile(font_path) _logger.debug("Found font %s at %s", font.name, font_path) found_fonts.append((font.familyName, font.name, font_path, font.styleName)) - except KeyError, ex: - if ex.args and ex.args[0] == 'head': - # Sometimes, the system can have a lot of Bitmap fonts, and - # in this case, Reportlab can't load the 'head' table from - # the structure of the TTF file (ex: NISC18030.ttf) - # In this case, we have to bypass the loading of this font! - _logger.warning("Could not register Fond %s (Old Bitmap font)", font_path) - else: - raise - except ttfonts.TTFError: - _logger.warning("Could not register Font %s", font_path) + except Exception, ex: + _logger.warning("Could not register Font %s: %s", font_path, ex) for family, name, path, mode in found_fonts: if not self.search(cr, uid, [('family', '=', family), ('name', '=', name)], context=context):