mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-05 04:13:11 +03:00
Do not crop again if glyph is the same as the previous one
This commit is contained in:
parent
ecd3948b45
commit
6cad0d62e7
|
@ -2733,7 +2733,7 @@ _font_text_asBytes(PyObject *encoded_string, unsigned char **text) {
|
||||||
static PyObject *
|
static PyObject *
|
||||||
_font_getmask(ImagingFontObject *self, PyObject *args) {
|
_font_getmask(ImagingFontObject *self, PyObject *args) {
|
||||||
Imaging im;
|
Imaging im;
|
||||||
Imaging bitmap;
|
Imaging bitmap = NULL;
|
||||||
int x, b;
|
int x, b;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int status;
|
int status;
|
||||||
|
@ -2765,10 +2765,13 @@ _font_getmask(ImagingFontObject *self, PyObject *args) {
|
||||||
b = self->baseline;
|
b = self->baseline;
|
||||||
for (x = 0; text[i]; i++) {
|
for (x = 0; text[i]; i++) {
|
||||||
glyph = &self->glyphs[text[i]];
|
glyph = &self->glyphs[text[i]];
|
||||||
bitmap =
|
if (i == 0 || text[i] != text[i - 1]) {
|
||||||
ImagingCrop(self->bitmap, glyph->sx0, glyph->sy0, glyph->sx1, glyph->sy1);
|
ImagingDelete(bitmap);
|
||||||
if (!bitmap) {
|
bitmap =
|
||||||
goto failed;
|
ImagingCrop(self->bitmap, glyph->sx0, glyph->sy0, glyph->sx1, glyph->sy1);
|
||||||
|
if (!bitmap) {
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
status = ImagingPaste(
|
status = ImagingPaste(
|
||||||
im,
|
im,
|
||||||
|
@ -2778,17 +2781,18 @@ _font_getmask(ImagingFontObject *self, PyObject *args) {
|
||||||
glyph->dy0 + b,
|
glyph->dy0 + b,
|
||||||
glyph->dx1 + x,
|
glyph->dx1 + x,
|
||||||
glyph->dy1 + b);
|
glyph->dy1 + b);
|
||||||
ImagingDelete(bitmap);
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
x = x + glyph->dx;
|
x = x + glyph->dx;
|
||||||
b = b + glyph->dy;
|
b = b + glyph->dy;
|
||||||
}
|
}
|
||||||
|
ImagingDelete(bitmap);
|
||||||
free(text);
|
free(text);
|
||||||
return PyImagingNew(im);
|
return PyImagingNew(im);
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
|
ImagingDelete(bitmap);
|
||||||
free(text);
|
free(text);
|
||||||
ImagingDelete(im);
|
ImagingDelete(im);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user