Skip to content

Commit

Permalink
Fix descender parameter was ignored on rendering truetype fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Oct 22, 2011
1 parent 9e99408 commit 501c5c4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions _imagingft.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 501c5c4

Please sign in to comment.