[Pythonmac-SIG] pyui font troubles

Bob Ippolito bob at redivi.com
Wed Jul 13 00:55:59 CEST 2005


On Jul 12, 2005, at 12:22 PM, David Hill wrote:

> I'm relatively new to Python and I'm trying to work through some
> examples in Sean Riley's "Game Programming with Python" book.
> Unfortunately, I'm having some trouble with most of the examples that
> use his pyui library.
>
> It looks like the examples fail when trying to create a font object
> for the arial font. I took a look in the pyui code that creates the
> font (using pygame) and it has this suspicious line:
>
>
>>  faceFile = os.environ['WINDIR'] + "/Fonts/" + fontRegistery 
>> [faceFile]
>>
>
> where fontRegistery[faceFile] == "arial.ttf"
>
> That didn't fill me with a great deal of confidence (since it
> produces a KeyError exception on WINDIR), so I tried a quick hack:
>
>
>>             if os.environ.has_key( 'WINDIR' ):
>>                 faceFile = os.environ['WINDIR'] + "/Fonts/" +
>> fontRegistery[faceFile]
>>             else:
>>                 faceFile = "/Library/Fonts/Arial"
>>
>
> That gets me the bus error shown below. Clearly, the font format on
> Mac OS X isn't what pygame is expecting.

Yeah, those aren't going to work.

> Has anybody else had any luck getting the code from this book to work?
>
> The error in the console looks like this:
>
>
>> davidh% /usr/local/bin/pythonw terrainView.py
>> Creating font: arial
>> {'impact': 'impact.ttf', 'arial': 'arial.ttf', 'courier':
>> 'cour.ttf', 'courier new': 'cour.ttf', 'times': 'times.ttf', 'comic
>> sans ms': 'comic.ttf', 'times new roman': 'times.ttf'} arial
>> Fatal Python error: (pygame parachute) Bus Error
>> Abort
>>
>
> The stack crawl from the crash report looks like this:

---

> Does anybody have any ideas or suggestions? Is pyui just not Mac (or
> Linux, evidently) friendly? Could I have screwed up my installation
> of Python 2.4 somehow?

Just use the default font (pass None for the path), or get ttfs from  
somewhere and use those.  It sounds like the book (and quite possibly  
pyui) author didn't test anywhere but Windows, so you'll probably run  
into a bunch of stuff like this.

-bob



More information about the Pythonmac-SIG mailing list