MacOSX Yosemite: failing to find all installed fonts

Issue #249 new
Kurt Dekker
created an issue

I have installed python27 and py27-game via MacPorts. This seems to be the best route for success with MacOSX Yosemite 10.10.3, and yet I'm still not quite there.

The error sequence happens like so:

Python 2.7.10 (default, May 25 2015, 13:06:17) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.init()
(6, 0)
>>> pygame.font.get_fonts()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/sysfont.py", line 596, in get_fonts
    initsysfonts()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/sysfont.py", line 522, in initsysfonts
    fonts = initsysfonts_darwin()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/sysfont.py", line 422, in initsysfonts_darwin
    _search_osx_font_paths(fonts)
UnboundLocalError: local variable 'fonts' referenced before assignment
>>> pygame.ver
'1.9.1release'
>>> 

Is there a better install I should make? I tried homebrew and then it works but has only one font available, a very crunched-up square-ish all-capitals rounded font which I forget the name of.

I suspect there is simply something preventing the Python/PyGame/Freetype subsystem(s) from successfully enumerating my fonts, since every other app on the system can find fonts just fine.

Comments (6)

  1. Kurt Dekker reporter

    I retried with Brew and this is the error sequence:

    Python 2.7.10 (default, Jun 10 2015, 19:42:47) 
    [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pygame
    >>> pygame.init()
    (6, 0)
    >>> pygame.font.get_fonts()
    [None]
    >>> pygame.font.get_default_font()
    'freesansbold.ttf'
    >>> pygame.ver
    '1.9.2a0'
    >>> 
    

    Notably, this is from the steps here:

    http://jalada.co.uk/2011/06/17/installing-pygame-on-os-x-with-a-homebrew-python-2-7-install.html

    I saw that after running python config.py, this was the output, which looks like some freetype stuff was not binding properly.

    python config.py
    Using Darwin configuration...
    
    sh: smpeg-config: command not found
    sh: smpeg-config: command not found
    sh: smpeg-config: command not found
    WARNING: "smpeg-config" failed!
    sh: /usr/X11R6/bin/freetype-config: No such file or directory
    sh: /usr/X11R6/bin/freetype-config: No such file or directory
    sh: /usr/X11R6/bin/freetype-config: No such file or directory
    WARNING: "/usr/X11R6/bin/freetype-config" failed!
    
    Backup existing "Setup" file [Y/n]:n
    Hunting dependencies...
    SDL     : found 1.2.15
    Framework SDL found
    FONT    : found
    Framework SDL_ttf found
    IMAGE   : found
    Framework SDL_image found
    MIXER   : found
    Framework SDL_mixer found
    SMPEG   : not found
    Framework smpeg not found
    Framework CoreMIDI found
    Framework QuickTime found
    PNG     : found
    JPEG    : found
    PORTMIDI: not found
    FREETYPE: not found
    AVFORMAT: not found
    SWSCALE : not found
    

    I do have XQuartz on my system too, if that makes a difference.

  2. Jason Marshall

    Thanks for your thorough reporting, Kurt. Here are some questions:

    1. Which version of XQuartz have you installed?
    2. Also, after installing XQuartz, a full system reboot is necessary. Have you rebooted the system since installing XQuartz?
    3. Is your issue different from Issue #177?
  3. Kurt Dekker reporter

    Yeah, I've got other forms of discontent going here. On one MacOS yosemite system, Quartz 2.7.7, I find all kinds of fonts. On another, zero. I redid my build from tip and now the problem has changed to finding two SDL libraries at runtime, and it being "undefined" which one will bind.

    If I remove either one of the two SDLs that it says it finds, it says "Can't find X, cannot run." This underscores the basic problem that I don't know how MacOS searches for runtime shared libraries.

    I'm going to have to nuke all my libs and start afresh here from clean, now that I know it runs on another macos system with slightly-different libs installed.

    Thanks for your info and ideas. I'll post more when I get things cleared out and rebuilt, if ti doesn't start working magically.

  4. Log in to comment