diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index cf7983c0f0c..99efa53432f 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -282,7 +282,7 @@ def __init__( def load_from_bytes(f: IO[bytes]) -> None: self.font_bytes = f.read() self.font = core.getfont( - "", size, index, encoding, self.font_bytes, layout_engine + "", size, index, encoding, layout_engine, self.font_bytes ) if is_path(font): @@ -297,7 +297,7 @@ def load_from_bytes(f: IO[bytes]) -> None: with open(font, "rb") as f: load_from_bytes(f) return - self.font = core.getfont(font, size, index, encoding, b"", layout_engine) + self.font = core.getfont(font, size, index, encoding, layout_engine) else: load_from_bytes(cast("IO[bytes]", font)) diff --git a/src/_imagingft.c b/src/_imagingft.c index 8a387deec77..284441ecdc2 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -122,7 +122,7 @@ geterror(int code) { } static PyObject * -getfont(PyObject *self_, PyObject *args, PyObject *kw) { +getfont(PyObject *self_, PyObject *args) { /* create a font object from a file name and a size (in pixels) */ FontObject *self; @@ -137,9 +137,6 @@ getfont(PyObject *self_, PyObject *args, PyObject *kw) { unsigned char *encoding = NULL; unsigned char *font_bytes = NULL; Py_ssize_t font_bytes_size = 0; - static char *kwlist[] = { - "filename", "size", "index", "encoding", "font_bytes", "layout_engine", NULL - }; if (!library) { PyErr_SetString(PyExc_OSError, "failed to initialize FreeType library"); @@ -149,38 +146,34 @@ getfont(PyObject *self_, PyObject *args, PyObject *kw) { #if PY_MAJOR_VERSION > 3 || PY_MINOR_VERSION > 11 PyConfig config; PyConfig_InitPythonConfig(&config); - if (!PyArg_ParseTupleAndKeywords( + if (!PyArg_ParseTuple( args, - kw, - "etfnsy#n", - kwlist, + "etfnsn|y#", config.filesystem_encoding, &filename, &size, &index, &encoding, + &layout_engine, &font_bytes, - &font_bytes_size, - &layout_engine + &font_bytes_size )) { PyConfig_Clear(&config); return NULL; } PyConfig_Clear(&config); #else - if (!PyArg_ParseTupleAndKeywords( + if (!PyArg_ParseTuple( args, - kw, - "etfnsy#n", - kwlist, + "etfnsn|y#", Py_FileSystemDefaultEncoding, &filename, &size, &index, &encoding, + &layout_engine, &font_bytes, - &font_bytes_size, - &layout_engine + &font_bytes_size )) { return NULL; } @@ -1690,7 +1683,7 @@ static PyTypeObject Font_Type = { }; static PyMethodDef _functions[] = { - {"getfont", (PyCFunction)getfont, METH_VARARGS | METH_KEYWORDS}, {NULL, NULL} + {"getfont", (PyCFunction)getfont, METH_VARARGS}, {NULL, NULL} }; static int