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

Re: [pygame] freetype module



Hi,

On 14/01/11 03:35 PM, Marcus von Appen wrote:
On, Sat Jan 15, 2011, Lenard Lindstrom wrote:


This can cause a Python interpreter crash.

I did not encounter that so far. Can you provide an example for that?


The render_raw method crashed on "gh" when returning a bytes string.
Byte strings have less padding so the python instance and malloc headers
are corrupted. The boundary problem is not noticeable when rendering to
an existing surface with render. But the attached chop.py program
displays "gn", chopping off the h's accender. I would have tried this
with pygame2, but only have SDL_mixer 1.2.8 available for Debian
squeeze. (The pygame2 build fails with these errors:

[Errors]

Simply deactivate SDL_mixer support using export WITH_SDL_MIXER=0 or
adjusting cfg.py. I fixed some leaks there, so that might prevent
the crash (not the miscalculation, though).

And I do have the development packages installed.)
Well, we are talking about Debian here, which means rather old versions
of software ;-).

Okay, pgreloaded built with SDL_mixer disabled. And this attached test programs works.

Lenard

# -*- encoding: utf-8 -*-
import pygame2
from pygame2.sdl import constants, event, video
from pygame2 import freetype

video.init()
freetype.init()
screen = video.set_mode(300, 200)
screen.fill(pygame2.Color('White'))
screen.flip()
f = freetype.Font('sans.ttf')
s, w, h = f.render(u'gĥ', pygame2.Color('Black'), ptsize=90)
screen.fill(pygame2.Color('Green'), pygame2.Rect(10, 30, w, h))
screen.blit(s, (10, 30))
screen.flip()

try:
    loop = True
    while loop:
        for ev in event.get():
            if ev.type == constants.QUIT:
                loop = False
            elif ev.type == constants.KEYDOWN and ev.key == constants.K_ESCAPE:
                loop = False
finally:
    freetype.quit()
    video.quit()