mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
DRYing out the code
This commit is contained in:
parent
f4f3ed744b
commit
0b9e404761
31
_imagingft.c
31
_imagingft.c
|
@ -349,21 +349,25 @@ font_render(FontObject* self, PyObject* args)
|
||||||
&delta);
|
&delta);
|
||||||
x += delta.x >> 6;
|
x += delta.x >> 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = FT_Load_Glyph(self->face, index, load_flags);
|
error = FT_Load_Glyph(self->face, index, load_flags);
|
||||||
if (error)
|
if (error)
|
||||||
return geterror(error);
|
return geterror(error);
|
||||||
|
|
||||||
glyph = self->face->glyph;
|
glyph = self->face->glyph;
|
||||||
|
|
||||||
|
int xx, x0, x1;
|
||||||
|
source = (unsigned char*) glyph->bitmap.buffer;
|
||||||
|
xx = x + glyph->bitmap_left;
|
||||||
|
x0 = 0;
|
||||||
|
x1 = glyph->bitmap.width;
|
||||||
|
if (xx < 0)
|
||||||
|
x0 = -xx;
|
||||||
|
if (xx + x1 > im->xsize)
|
||||||
|
x1 = im->xsize - xx;
|
||||||
|
|
||||||
if (mask) {
|
if (mask) {
|
||||||
/* use monochrome mask (on palette images, etc) */
|
/* use monochrome mask (on palette images, etc) */
|
||||||
int xx, x0, x1;
|
|
||||||
source = (unsigned char*) glyph->bitmap.buffer;
|
|
||||||
xx = x + glyph->bitmap_left;
|
|
||||||
x0 = 0;
|
|
||||||
x1 = glyph->bitmap.width;
|
|
||||||
if (xx < 0)
|
|
||||||
x0 = -xx;
|
|
||||||
if (xx + x1 > im->xsize)
|
|
||||||
x1 = im->xsize - xx;
|
|
||||||
for (y = 0; y < glyph->bitmap.rows; y++) {
|
for (y = 0; y < glyph->bitmap.rows; y++) {
|
||||||
int yy = y + im->ysize - (PIXEL(glyph->metrics.horiBearingY) + ascender);
|
int yy = y + im->ysize - (PIXEL(glyph->metrics.horiBearingY) + ascender);
|
||||||
if (yy >= 0 && yy < im->ysize) {
|
if (yy >= 0 && yy < im->ysize) {
|
||||||
|
@ -383,15 +387,6 @@ font_render(FontObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* use antialiased rendering */
|
/* use antialiased rendering */
|
||||||
int xx, x0, x1;
|
|
||||||
source = (unsigned char*) glyph->bitmap.buffer;
|
|
||||||
xx = x + glyph->bitmap_left;
|
|
||||||
x0 = 0;
|
|
||||||
x1 = glyph->bitmap.width;
|
|
||||||
if (xx < 0)
|
|
||||||
x0 = -xx;
|
|
||||||
if (xx + x1 > im->xsize)
|
|
||||||
x1 = im->xsize - xx;
|
|
||||||
for (y = 0; y < glyph->bitmap.rows; y++) {
|
for (y = 0; y < glyph->bitmap.rows; y++) {
|
||||||
int yy = y + im->ysize - (PIXEL(glyph->metrics.horiBearingY) + ascender);
|
int yy = y + im->ysize - (PIXEL(glyph->metrics.horiBearingY) + ascender);
|
||||||
if (yy >= 0 && yy < im->ysize) {
|
if (yy >= 0 && yy < im->ysize) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user