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

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



Hi Brian

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

When pressing right cursor key arrow the Debug IO windows is repeating several times the following text:

['verasans.ttf', 'file:verasans.ttf']
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.

opening through file object: verasans.ttf
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.

opening through file object: verasans.ttf
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.

opening through file object: verasans.ttf
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.

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?


Greetings Farai




Am 19.11.2006 um 18:33 schrieb Brian Fisher:

Hey All,
using pygame 1.6 on python 2.3 on windows (cause I don't want to have
to distribute the ms cruntime) with SDL_ttf version 2.0.6 everytime I
try to load a font from a file object I get a pygame parachute
segfault

I'm attaching a test (modified from something on this list before)
that will load a font by name first, then if you press right arrow it
will load it from a file object.

Does this crash for other people when you press right arrow to load
from a file object? if so what version of pygame/python are you using
on what platform?

Does anybody have a sample that properly loads a font from a file
object on pygame 1.6? Is there anything wrong with the way this code
does it?

thanks!

p.s when I try to load a font from a file object with filemon logging
file activity, It seems no data reads from the font happen after the
file is first opened to get the file object, meaning sdl_ttf isn't
using the underlying file at all

this is the console output the test program gives me:
----------------------
['verasans.ttf', 'file:verasans.ttf']
pygame.font.Font(file, size) -> Font
create a new font object

This will create a new font object. The given file can
be a filename or any python file-like object.
The size represents the height of the font in
pixels. The file argument can be 'None', which will
use a plain default font.

You must have at least SDL_ttf-2.0.6 for file object
support. You can load TTF and FON fonts.

opening through file object: verasans.ttf
Pygame Parachute Traceback:
File "c:\temp\Font_Test.py", line 29, in DrawFont
Fatal Python error: (pygame parachute) Segmentation Fault

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
<font_from_file_test.zip>