mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #45 from tk0miya/fix-rendered-chars-have-been-chipped
Fix rendered characters have been chipped for some TrueType fonts
This commit is contained in:
commit
1a293f9f75
|
@ -282,7 +282,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
Imaging im;
|
Imaging im;
|
||||||
int index, error, ascender;
|
int index, error, ascender, descender;
|
||||||
int load_flags;
|
int load_flags;
|
||||||
unsigned char *source;
|
unsigned char *source;
|
||||||
FT_ULong ch;
|
FT_ULong ch;
|
||||||
|
@ -332,6 +332,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
int xx, x0, x1;
|
int xx, x0, x1;
|
||||||
source = (unsigned char*) glyph->bitmap.buffer;
|
source = (unsigned char*) glyph->bitmap.buffer;
|
||||||
ascender = PIXEL(self->face->size->metrics.ascender);
|
ascender = PIXEL(self->face->size->metrics.ascender);
|
||||||
|
descender = PIXEL(self->face->size->metrics.descender);
|
||||||
xx = x + glyph->bitmap_left;
|
xx = x + glyph->bitmap_left;
|
||||||
x0 = 0;
|
x0 = 0;
|
||||||
x1 = glyph->bitmap.width;
|
x1 = glyph->bitmap.width;
|
||||||
|
@ -340,7 +341,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
if (xx + x1 > im->xsize)
|
if (xx + x1 > im->xsize)
|
||||||
x1 = im->xsize - xx;
|
x1 = im->xsize - xx;
|
||||||
for (y = 0; y < glyph->bitmap.rows; y++) {
|
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) {
|
if (yy >= 0 && yy < im->ysize) {
|
||||||
/* blend this glyph into the buffer */
|
/* blend this glyph into the buffer */
|
||||||
unsigned char *target = im->image8[yy] + xx;
|
unsigned char *target = im->image8[yy] + xx;
|
||||||
|
@ -361,6 +362,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
int xx, x0, x1;
|
int xx, x0, x1;
|
||||||
source = (unsigned char*) glyph->bitmap.buffer;
|
source = (unsigned char*) glyph->bitmap.buffer;
|
||||||
ascender = PIXEL(self->face->size->metrics.ascender);
|
ascender = PIXEL(self->face->size->metrics.ascender);
|
||||||
|
descender = PIXEL(self->face->size->metrics.descender);
|
||||||
xx = x + glyph->bitmap_left;
|
xx = x + glyph->bitmap_left;
|
||||||
x0 = 0;
|
x0 = 0;
|
||||||
x1 = glyph->bitmap.width;
|
x1 = glyph->bitmap.width;
|
||||||
|
@ -369,7 +371,7 @@ font_render(FontObject* self, PyObject* args)
|
||||||
if (xx + x1 > im->xsize)
|
if (xx + x1 > im->xsize)
|
||||||
x1 = im->xsize - xx;
|
x1 = im->xsize - xx;
|
||||||
for (y = 0; y < glyph->bitmap.rows; y++) {
|
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) {
|
if (yy >= 0 && yy < im->ysize) {
|
||||||
/* blend this glyph into the buffer */
|
/* blend this glyph into the buffer */
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user