mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-23 19:44:13 +03:00
Determine mask mode in Python instead of C
This commit is contained in:
parent
25cc5afbb1
commit
f016d3079b
|
@ -565,16 +565,16 @@ class FreeTypeFont:
|
||||||
im = None
|
im = None
|
||||||
size = None
|
size = None
|
||||||
|
|
||||||
def fill(mode, im_size):
|
def fill(width, height):
|
||||||
nonlocal im, size
|
nonlocal im, size
|
||||||
|
|
||||||
size = im_size
|
size = (width, height)
|
||||||
if Image.MAX_IMAGE_PIXELS is not None:
|
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:
|
if pixels > 2 * Image.MAX_IMAGE_PIXELS:
|
||||||
return
|
return
|
||||||
|
|
||||||
im = Image.core.fill(mode, size)
|
im = Image.core.fill("RGBA" if mode == "RGBA" else "L", size)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
offset = self.font.render(
|
offset = self.font.render(
|
||||||
|
|
|
@ -877,7 +877,7 @@ font_render(FontObject *self, PyObject *args) {
|
||||||
|
|
||||||
width += stroke_width * 2 + ceil(x_start);
|
width += stroke_width * 2 + ceil(x_start);
|
||||||
height += stroke_width * 2 + ceil(y_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) {
|
if (image == Py_None) {
|
||||||
PyMem_Del(glyph_info);
|
PyMem_Del(glyph_info);
|
||||||
return Py_BuildValue("ii", 0, 0);
|
return Py_BuildValue("ii", 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user