From 501c5c47b6f76aa6900ee748087c8a237ce90c26 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 22 Oct 2011 14:33:29 +0900 Subject: [PATCH] Fix descender parameter was ignored on rendering truetype fonts --- _imagingft.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/_imagingft.c b/_imagingft.c index 935808718..285ba7cb6 100644 --- a/_imagingft.c +++ b/_imagingft.c @@ -299,7 +299,7 @@ font_render(FontObject* self, PyObject* args) { int i, x, y; Imaging im; - int index, error, ascender; + int index, error, ascender, descender; int load_flags; unsigned char *source; FT_ULong ch; @@ -349,6 +349,7 @@ font_render(FontObject* self, PyObject* args) int xx, x0, x1; source = (unsigned char*) glyph->bitmap.buffer; ascender = PIXEL(self->face->size->metrics.ascender); + descender = PIXEL(self->face->size->metrics.descender); xx = x + glyph->bitmap_left; x0 = 0; x1 = glyph->bitmap.width; @@ -357,7 +358,7 @@ font_render(FontObject* self, PyObject* args) if (xx + x1 > im->xsize) x1 = im->xsize - xx; for (y = 0; y < glyph->bitmap.rows; y++) { - int yy = y + ascender - glyph->bitmap_top; + int yy = y + ascender + descender - glyph->bitmap_top; if (yy >= 0 && yy < im->ysize) { /* blend this glyph into the buffer */ unsigned char *target = im->image8[yy] + xx; @@ -378,6 +379,7 @@ font_render(FontObject* self, PyObject* args) int xx, x0, x1; source = (unsigned char*) glyph->bitmap.buffer; ascender = PIXEL(self->face->size->metrics.ascender); + descender = PIXEL(self->face->size->metrics.descender); xx = x + glyph->bitmap_left; x0 = 0; x1 = glyph->bitmap.width; @@ -386,7 +388,7 @@ font_render(FontObject* self, PyObject* args) if (xx + x1 > im->xsize) x1 = im->xsize - xx; for (y = 0; y < glyph->bitmap.rows; y++) { - int yy = y + ascender - glyph->bitmap_top; + int yy = y + ascender + descender - glyph->bitmap_top; if (yy >= 0 && yy < im->ysize) { /* blend this glyph into the buffer */ int i;