[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Font Error



Gabriele Farina wrote:
Pygame Parachute Traceback:
  File "locals.py", line 105, in SetFont
Fatal Python error: (pygame parachute) Segmentation Fault

What's that error?? I specified "verdana.ttf" as font attribute to
pygame.font.Font(), and this file is in the same directory of the script who
calls the function...where's the problem??
this is a bug in the current SDL_ttf. if you specify a file it cannot open it will crash. the 'pygame parachute' is something that catches a crash and tries to shutdown the graphics and sound cleanly.

even though the font is in the same place as the script, that doesn't always mean the "working directory" is set to the same place as the script.

i usually use a nugget of code like this..

import sys, os
gamepath = os.path.dirname(os.path.abspath(sys.argv[0]))
os.chdir(gamepath)

this will set the current working directory to the same place as the script that was run. regardless of how the script was initially started.