Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OS X] Could not set the fontsize for facefile #14

Open
LukasDrude opened this issue Sep 29, 2015 · 9 comments
Open

[OS X] Could not set the fontsize for facefile #14

LukasDrude opened this issue Sep 29, 2015 · 9 comments
Assignees
Labels

Comments

@LukasDrude
Copy link

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.

@dmnfarrell
Copy link
Owner

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
Copy link
Owner

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.

@LukasDrude
Copy link
Author

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.

@dmnfarrell
Copy link
Owner

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

@LukasDrude
Copy link
Author

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.

@dmnfarrell
Copy link
Owner

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 dmnfarrell self-assigned this Oct 13, 2015
@dmnfarrell dmnfarrell added the bug label Oct 13, 2015
@griggsca91
Copy link

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.

@dmnfarrell
Copy link
Owner

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: matplotlib/matplotlib#3903

@griggsca91
Copy link

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.

dmnfarrell added a commit that referenced this issue Mar 10, 2016
Skip fonts that don't return properties (#14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants