Merge pull request #7548 from radarhere/imagefont

This commit is contained in:
Hugo van Kemenade 2023-12-21 12:55:20 +02:00 committed by GitHub
commit b638d056d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -585,16 +585,16 @@ class FreeTypeFont:
im = None
size = None
def fill(mode, im_size):
def fill(width, height):
nonlocal im, size
size = im_size
size = (width, height)
if Image.MAX_IMAGE_PIXELS is not None:
pixels = max(1, size[0]) * max(1, size[1])
pixels = max(1, width) * max(1, height)
if pixels > 2 * Image.MAX_IMAGE_PIXELS:
return
im = Image.core.fill(mode, size)
im = Image.core.fill("RGBA" if mode == "RGBA" else "L", size)
return im
offset = self.font.render(

View File

@ -877,7 +877,7 @@ font_render(FontObject *self, PyObject *args) {
width += stroke_width * 2 + ceil(x_start);
height += stroke_width * 2 + ceil(y_start);
image = PyObject_CallFunction(fill, "s(ii)", strcmp(mode, "RGBA") == 0 ? "RGBA" : "L", width, height);
image = PyObject_CallFunction(fill, "ii", width, height);
if (image == Py_None) {
PyMem_Del(glyph_info);
return Py_BuildValue("ii", 0, 0);