[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
This commit is contained in:
Stephane Wirtel 2014-01-09 10:54:20 +01:00
parent 5aef04550f
commit 8eebb40313
1 changed files with 10 additions and 1 deletions

View File

@ -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()
return super(res_font, self).clear_caches()