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

Re: [pygame] freetype module



On, Sat Jan 15, 2011, Lenard Lindstrom wrote:

> Hi Marcus,
> 
> On 13/01/11 11:13 PM, Marcus von Appen wrote:
> > On, Fri Jan 14, 2011, Lenard Lindstrom wrote:
> >
> >    
> >> Hi everyone,
> >>
> >> A few months back I had a look at the new freetype pygame module. It is
> >> meant to replace the SDL_font based font module, and adds new features
> >> such as text rotation and full Unicode character support. Unfortunately
> >> it also has a serious bug in determining the text bounding rectangle
> >> when the text contains a mix of character with ascenders and descenders.
> >>      
> > The bug can be solved by storing the relative text bbox width and
> > height.
> >
> >    
> I'm not sure how you get the bboxes. I could only get reliable bounding 
> boxes by calling FT_Glyph_Get_CBox on loaded and transformed glyphs. At 
> this point much of the work is done, with just rendering and blitting 
> left. So the freetype.get_size method becomes extra expensive. Saving 
> transformed glyphs would add extra complexity to the cache mechanism. So 
> the architecture of the freetype module class(es) will need to be rethought.

The cbox size are calculated already for the separate glyphs in one of
the methods (I do not recall which one atm). The only key issue (besides
enhancing the structs for storing the correct sizes) here is to get the
baselines adjusted correctly, regardless of whether there are hanging
glyphs (like g, p, ...) or something like that.

I'll give your example a try on tomorrow and post, what the results are
on the different platforms, I'm using for testing.

> >    
> >> 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 ;-).

Best
Marcus

Attachment: pgpkkFQ5jl9mz.pgp
Description: PGP signature