font_manager crashes with IOError
Hi,
After svn update of ETS, my application crashes with the following traceback:
Traceback (most recent call last):
File "tiff_viewer.py", line 7, in <module>
from iocbio.chaco.image_stack_viewer import ImageStackViewer
File "/usr/local/lib/python2.6/dist-packages/iocbio/chaco/image_stack_viewer.py",
line 9, in <module>
from enthought.enable.api import Component, ComponentEditor
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/enable/api.py",
line 8, in <module>
from base import IDroppedOnHandler, TOP, VCENTER, BOTTOM, LEFT,
HCENTER, RIGHT, \
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/enable/base.py",
line 36, in <module>
from enthought.kiva import font_metrics_provider
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/__init__.py",
line 26, in <module>
from fonttools import Font # relative import; not the fonttools project!
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/__init__.py",
line 1, in <module>
from font import Font, str_to_font
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font.py",
line 9, in <module>
from font_manager import FontProperties, fontManager
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 1388, in <module>
_rebuild()
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 1338, in _rebuild
fontManager = FontManager()
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 1056, in __init__
self.ttflist = createFontList(self.ttffiles)
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/font_manager.py",
line 676, in createFontList
font = TTFont(str(fpath))
File "/usr/local/lib/python2.6/dist-packages/Enable-3.3.3.dev_r26056-py2.6-linux-x86_64.egg/enthought/kiva/fonttools/fontTools/ttLib/__init__.py",
line 124, in __init__
file = open(file, "rb")
IOError: [Errno 21] Is a directory:
'/usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf'
I am using ubuntu maverick. The directory
/usr/share/fonts/truetype/ttf-symbol-replacement/symbol-replacement.ttf
contains a file symbol.ttf.
The following patch fixed the IOError:
--- enthought/kiva/fonttools/font_manager.py (revision 26059)
+++ enthought/kiva/fonttools/font_manager.py (working copy)
<at> <at> -430,7 +430,7 <at> <at>
for fname in files:
fontfiles[os.path.abspath(fname)] = 1
- return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
+ return [fname for fname in fontfiles.keys() if os.path.isfile(fname)]
However, I am not sure that this is a proper fix because the
symbol.ttf file might be missed in the list.
Best regards,
Pearu