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

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



Inside...

Am 19.11.2006 um 23:39 schrieb Brian Fisher:

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
=> Nope, but thats maybe because of the newer Pygame/Python versions Im using (?). Or maybe you run into the same error but with your Pygame version the error message type is just differrent? At least the error happens on the same function/action.


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)
=> Im working with WingIDE (Python IDE) that has a Debug IO window. There the text (probably function documentiation inside Pygame) was printed.


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)
=> Hmmm, it looks to me you open this file several times (without (properly) closing them) and there is a max amount of opened files that the filehandler allows -> "Too many opened..."
I haven't done anything with fonts yet in Pygame but Im confused you have to open the same file again and again. Is there no way to open/ read the file once into memory and then work with it?


Greetings
Faraii