[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Segfault on loading font from StringIO
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Segfault on loading font from StringIO
- From: Radomir Dopieralski <pygame@xxxxxxxxxxxx>
- Date: Sun, 1 Jan 2012 11:50:04 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 01 Jan 2012 05:50:15 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=OzBb4fn1hPjH8WBqgZ9L2e/n7VhnnSgQmew9xPHU4ug=; b=ZI2ySh2Gvke9lTNXZPrwphiz0bPn3lPfCiXtPQcsU/RjRkNKBcG+0kK28UklW3Bezy s2rIDwWUL9HZCwPYRQ7739A5KeaNVLhWNV3i1jnNV18Q0uculuF+jQZAxNC/E8LUaLTl Pgx7KFJcRSaHkQJj777he0PxKpgP7bHJ5YxII=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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