From 8eebb4031355e6415c99f0a00b3226053a104956 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Thu, 9 Jan 2014 10:54:20 +0100 Subject: [PATCH] [FIX] On OSX, the system has a lot of Bitmap fonts, and in this case, Reportlab can not load the 'head' table from the structure of the TTF file. There is no good way to check if a TTF file is an old style or new style. bzr revid: stw@openerp.com-20140109095420-uixw7u1b0dbhcp4v --- openerp/addons/base/res/res_font.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_font.py b/openerp/addons/base/res/res_font.py index 306a8944783..47e49bf4d39 100644 --- a/openerp/addons/base/res/res_font.py +++ b/openerp/addons/base/res/res_font.py @@ -81,6 +81,15 @@ 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) @@ -112,4 +121,4 @@ class res_font(osv.Model): def clear_caches(self): """Force worker to resync at next report loading by setting an empty font list""" customfonts.CustomTTFonts = [] - return super(res_font, self).clear_caches() \ No newline at end of file + return super(res_font, self).clear_caches()