Skip to content

Commit

Permalink
Merge pull request #45 from tk0miya/fix-rendered-chars-have-been-chipped
Browse files Browse the repository at this point in the history
Fix rendered characters have been chipped for some TrueType fonts
  • Loading branch information
aclark4life committed Apr 9, 2013
2 parents 2156276 + 103cf49 commit 1a293f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions _imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,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 @@ -332,6 +332,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 @@ -340,7 +341,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 @@ -361,6 +362,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 @@ -369,7 +371,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

1 comment on commit 1a293f9

@fabiomcosta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the problem in linux, but introduces the bug in OSX.

This is before the fix in OSX:

After:

Please sign in to comment.