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

Re: [pygame] Segfault on loading font from StringIO



Hi guys, could someone please give me the address I email to start a new thread because the one I keep trying to email is not working

-Zack


On Jan 1, 2012, at 5:50 AM, Radomir Dopieralski <pygame@xxxxxxxxxxxx> wrote:

> Hello everyone,
> 
> I'm having a problem loading a font file from a python file-like
> object. According to the documentation at
> http://www.pygame.org/docs/ref/font.html#pygame.font.Font this should
> be possible, however, I get a segmentation fault every time I pass a
> file-like object that is not created by opening a real file. I want to
> load all my assets from a zip archive, so it's not possible to have a
> real file in the filesystem.
> 
> A simple test case:
> 
> import pygame
> import StringIO
> 
> pygame.font.init()
> 
> f = open("somefont.ttf", "r")
> font = pygame.font.Font(f, 8) # Works fine
> f.close()
> 
> f = open("somefont.ttf", "r")
> buffer = StringIO.StringIO(f.read())
> f.close()
> font = pygame.font.Font(buffer, 8) # Segfault
> 
> Is there any way to make it work as documented? If the documentation
> is wrong, is there any way to create a pygame font object without
> creating a real file in the filesystem?
> 
> Thanks,
> -- 
> Radomir Dopieralski