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

Re: [pygame] Font from file object crashes for me



On 11/19/06, Farai Aschwanden <fash@xxxxxxxxxx> wrote:
Hi Brian

Dont know if this helps. I tested in on Mac with Pygame 1.71 and
Python 2.4.1

Thanks Farai - it helps. Looks like the error I'm seeing doesn't
happen with your platform


The font object is created only from pygame.font.Font(). Once a
font is created it's size and TTF file cannot be changed. The
Font objects are mainly used to render() text into a new Surface.
The Font objects also have a few states that can be set with
set_underline(bool), set_bold(bool), set_italic(bool). Each of
these functions contains an equivalent get_XXX() routine to find
the current state. There are also many routines to query the
dimensions of the text. The rendering functions work with both
normal python strings, as well as with unicode strings.

Hmmm... I guess that's a message printed by pygame... it doesn't
really look like an error, but I can't imagine why it would be printed
when opening through a file object, but not when opening by filename
(it would have opened the font by filename repeatedly before pressing
the right arrow)


Then (after several times repeating the message above) I got the
following error message:

IOError: (24, 'Too many open files', 'verasans.ttf'

That might not solve the problem, but it seems the TTF file wont be
closed. I asked myself why the error message appears repeating?

The sample code recreates the pygame font object each time it draws,
so there is probably one of each of those messages for each draw, and
it draws as fast as it can.

I guess in addition to opening from a file object causing that message
to print, it must also be keeping the file handle open even though
both the pygame font object and the file object have both dropped out
of scope (So should have been garbage collected by the ref counter)