Patch for freetype issue

Erwan Loaëc <[email protected]>
Newsgroups gmane.comp.python.image
Message-ID <[email protected]>
Hello,

I've found a bug in the function font_render() of _imagingft.c.
The "x" value is adapted according to the horiBearingX value of the 
first glyph but the concerned glyph is loaded after.

I suggest the patch in attachment.
Is anyone can take a look and confirm this is really a bug ?

Regards,


-- 
Erwan Loaec

_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig
_imagingft.c.patch (text/x-patch, 1.1 KB)
--- Imaging-1.1.7/_imagingft.c	2009-11-01 01:44:12.000000000 +0100
+++ Imaging-1.1.7_patch/_imagingft.c	2011-01-14 16:06:10.000000000 +0100
@@ -331,18 +331,18 @@
         load_flags |= FT_LOAD_TARGET_MONO;
 
     for (x = i = 0; font_getchar(string, i, &ch); i++) {
+        index = FT_Get_Char_Index(self->face, ch);
+        error = FT_Load_Glyph(self->face, index, load_flags);
+        if (error)
+            return geterror(error);
         if (i == 0 && self->face->glyph->metrics.horiBearingX < 0)
             x = -PIXEL(self->face->glyph->metrics.horiBearingX);
-        index = FT_Get_Char_Index(self->face, ch);
         if (kerning && last_index && index) {
             FT_Vector delta;
             FT_Get_Kerning(self->face, last_index, index, ft_kerning_default,
                            &delta);
             x += delta.x >> 6;
         }
-        error = FT_Load_Glyph(self->face, index, load_flags);
-        if (error)
-            return geterror(error);
         glyph = self->face->glyph;
         if (mask) {
             /* use monochrome mask (on palette images, etc) */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.