[Pythonmac-SIG] pyui font troubles

David Hill davidh at mac.com
Wed Jul 13 01:16:45 CEST 2005


Thanks!

Now I'm getting somewhere. The examples now run and draw their  
initial screens but they don't update. Everything seems to be running  
OK in the background but the window doesn't update at all after the  
initial drawing.

Oh, and I'm getting strange libpng errors in the console:

> libpng warning: Incomplete compressed datastream in iCCP chunk
> libpng warning: Profile size field missing from iCCP chunk

Sigh, it looks like I'll need to dig into this a bit more. At least  
passing None in the font code is working.

Thanks,

Dave


On Jul 12, 2005, at 5:55 PM, Bob Ippolito wrote:

>
> 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