Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/PIL/ImageFont.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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))

Expand Down
27 changes: 10 additions & 17 deletions src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
Loading