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

[pygame] Segfault on loading font from StringIO



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