Skip to content

kiva/fonttools/fontmanager.py:findfont unable to find suitable fonts #259

Closed
@spichardo

Description

@spichardo

Hi,

When combined with chaco::master in its latest commit, I'm having all sort of errors that font files are being unable to be located:

2016-12-14 16:26:33,226 - MRgHIFU.by.Proteus - ERROR - Uncaught exception
Traceback (most recent call last):
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\qt4\base_window.py", line 198, in paintEvent
self.handler.paintEvent(event)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\qt4\base_window.py", line 50, in paintEvent
self._enable_window._paint(event)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\abstract_window.py", line 468, in _paint
self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\component.py", line 424, in draw
self._draw(gc, view_bounds, mode)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\component.py", line 776, in _draw
self._dispatch_draw(layer, gc, view_bounds, mode)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\container.py", line 272, in _dispatch_draw
component._dispatch_draw(layer, gc, new_bounds, mode)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\container.py", line 257, in _dispatch_draw
my_handler(gc, view_bounds, mode)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\container.py", line 297, in _draw_container_underlay
self._draw_underlay(gc, view_bounds, mode)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\enable\component.py", line 884, in _draw_underlay
underlay.overlay(self, gc, view_bounds, mode)
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\axis.py", line 222, in overlay
self._draw_component(gc, view_bounds, mode, component)
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\axis.py", line 248, in _draw_component
self._compute_labels(gc)
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\axis.py", line 524, in _compute_labels
for ticklabel in self.ticklabel_cache]
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\axis.py", line 524, in
for ticklabel in self.ticklabel_cache]
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\label.py", line 100, in get_bounding_box
width, height = self.get_width_height(gc)
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\label.py", line 93, in get_width_height
self._calc_line_positions(gc)
File "C:\Anaconda2\envs\py33\lib\site-packages\chaco-4.6.0.dev283-py3.3-win-amd64.egg\chaco\label.py", line 241, in _calc_line_positions
gc.set_font(self.font)
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\kiva\agg\agg.py", line 1191, in set_font
newfilename = font.findfont()
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\kiva\fonttools\font.py", line 106, in findfont
return str(fontManager.findfont(fp))
File "C:\Anaconda2\envs\py33\lib\site-packages\enable-4.7.0.dev8-py3.3-win-amd64.egg\kiva\fonttools\font_manager.py", line 1306, in findfont
(prop.get_family(), self.defaultFamily[fontext]))
UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to Bitstream Vera Sans

Then the chaco elements requiring fonts are not displayed in the UI. I'm momentarily fixing this in my application with an ugly hardcoded path to a font file in the function `kiva/fonttools/font.py:findfont

    def findfont(self):
        """ Returns the file name containing the font that most closely matches
        our font properties.
        """
        fp = self._make_font_props()
        #return str(fontManager.findfont(fp))
        return "[path to a font directory]\arial.ttf"

I'm running Win 10 x64 build 14971, I tested it with anaconda x64 and environments for python 3.3 and python 3.5,

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions