pandastable icon indicating copy to clipboard operation
pandastable copied to clipboard

[OS X] Could not set the fontsize for facefile

Open LukasDrude opened this issue 10 years ago • 9 comments

I am on:

ProductName:    Mac OS X
ProductVersion: 10.10.5
BuildVersion:   14F27

Python 3.3.5 :: Anaconda 2.3.0 (x86_64)

When I execute dataexplore, I get the following error message:

//anaconda/envs/py3k/lib/python3.3/site-packages/matplotlib/__init__.py:1318: UserWarning:  This call to matplotlib.use() has no effect
because the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)
2015-09-28 22:44:28.329 python3[40540:2441260] setCanCycle: is deprecated.  Please use setCollectionBehavior instead
2015-09-28 22:44:28.341 python3[40540:2441260] setCanCycle: is deprecated.  Please use setCollectionBehavior instead
Traceback (most recent call last):
  File "//anaconda/envs/py3k/bin/dataexplore", line 9, in <module>
    load_entry_point('pandastable==0.5.0', 'gui_scripts', 'dataexplore')()
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/app.py", line 540, in main
    app = ViewerApp()
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/app.py", line 88, in __init__
    self.newProject()
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/app.py", line 235, in newProject
    self.addSheet('sheet1')
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/app.py", line 348, in addSheet
    pf = table.showPlotViewer(f2)
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/core.py", line 1878, in showPlotViewer
    self.pf = PlotViewer(table=self, parent=parent)
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/plotting.py", line 56, in __init__
    self.setupGUI()
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/plotting.py", line 99, in setupGUI
    self.mplopts = MPLBaseOptions(parent=self)
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/plotting.py", line 608, in __init__
    fonts = getFonts()
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/plotting.py", line 811, in getFonts
    fonts = [matplotlib.font_manager.FontProperties(fname=fname).get_name() for fname in l]
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/plotting.py", line 811, in <listcomp>
    fonts = [matplotlib.font_manager.FontProperties(fname=fname).get_name() for fname in l]
  File "//anaconda/envs/py3k/lib/python3.3/site-packages/matplotlib/font_manager.py", line 736, in get_name
    return ft2font.FT2Font(findfont(self)).family_name
RuntimeError: Could not set the fontsize for facefile  /System/Library/Fonts/Apple Color Emoji.ttf

What can be a possible issue? I already deleted my .matplotlib folder as suggested on stackoverflow.com.

LukasDrude avatar Sep 29 '15 02:09 LukasDrude

Possibly a try except around the call to getFonts l Unfortunately I can't test this on OSX as I don't have access to a mac at the moment.

dmnfarrell avatar Sep 29 '15 16:09 dmnfarrell

Sorry accidentally closed the issue. I can try and change the default font for mac as a fix. Will do that when I get the chance.

dmnfarrell avatar Sep 29 '15 16:09 dmnfarrell

A quick workaround is to fix indeed the font to a fixed font like this in the file //anaconda/envs/py3k/lib/python3.3/site-packages/pandastable/plotting.py:

def getFonts():
     """Get the current list of system fonts"""

     import matplotlib.font_manager
     l = matplotlib.font_manager.get_fontconfig_fonts()
     fname = '/Library/Fonts/OsakaMono.ttf'
     fonts = [matplotlib.font_manager.FontProperties(fname=fname).get_name()]
     fonts = list(set(fonts))
     fonts.sort()
     #f = matplotlib.font_manager.FontProperties(family='monospace')
     #print (matplotlib.font_manager.findfont(f))
     return fonts

The problem is most likely, that some of the fonts do not behave as the should.

LukasDrude avatar Oct 02 '15 14:10 LukasDrude

Thanks. I will incorporate this kind of fix when I return from hols. So does the software run ok on osx with this fix?

dmnfarrell avatar Oct 02 '15 16:10 dmnfarrell

Although, I managed to get it started, I would still not consider it "running".

  • The application always starts in the background. This seems to be a general issue with Python and tkinter applications on OS X. A possible workaround is to get it to the front using a system call. This is a dirty hack, since you need to know the process name (here "python3.3").
import os
os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "python3.3" to true' ''')
root.mainloop()

Another strange thing is best summarized in a screenshot. The cell, which is edited, is hardly visible: screen shot 2015-10-03 at 14 13 58

I don't ask you to fix all these things, I just wanted to give something back for your effort to create this software. I can create different issues from this, if you want.

LukasDrude avatar Oct 03 '15 18:10 LukasDrude

Those two things you could certainly add issues for if u have time. The problem is I have no way to use OSX and so it has never been tested on mac. But at some point I will do that. I think python 3.4 might be a better bet as this is what I've been using on the other platforms. There must be a solution for the background launching problem.

dmnfarrell avatar Oct 04 '15 03:10 dmnfarrell

Hey just want to say I ran into both issues, but for the font one, just omitting "/System/Library/Fonts/Apple Color Emoji.ttf" from the list of fonts seems to fix the issue of it crashing. Maybe that might be the solution, albeit a non-fluid one. If I'm correct the problem seems to stem with the Freetype library itself.

For the Entry text issue, it looks like the padding being set by self.style.configure("TEntry", padding(3, 3, 3, 3)) is causing that. Removing it fixes it for mac, but I don't know how it affects Linux/Windows.

For the window displaying to the front, adding self.main.lift() to DataExplore init seems to fix that.

griggsca91 avatar Feb 10 '16 04:02 griggsca91

Thanks for testing. The entry style is not much use in linux or windows anyway so I can remove it. self.main.lift() also seems to work ok for linux and windows. I'm not sure about the font problem. How did you omit the font? It might be specific to the version of matplotlib too. I don't have OSX so can't test it. Are you using homebrew or anaconda? Seems to be related to this bug: https://github.com/matplotlib/matplotlib/issues/3903/

dmnfarrell avatar Feb 10 '16 12:02 dmnfarrell

Sorry for the late reply, not ignoring this. Anaconda, Python 3.4. I just simply checked for "Apple Color Emoji.ttf" in the font text in a for loop and omitted all of the text that contained it, I didn't really think it was worth that much time into looking how to properly fix it . That also looks to be what I've seen for issues regarding this.

griggsca91 avatar Feb 16 '16 14:02 griggsca91