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
2 changes: 1 addition & 1 deletion .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["pypy3.11", "3.12", "3.13", "3.14", "3.15"]
python-version: ["pypy3.12", "pypy3.11", "3.15", "3.14", "3.13", "3.12"]
architecture: ["x64"]
os: ["windows-latest"]
include:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
"ubuntu-latest",
]
python-version: [
"pypy3.12",
"pypy3.11",
"3.15t",
"3.15",
Expand Down
41 changes: 8 additions & 33 deletions src/_imagingft.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ getfont(PyObject *self_, PyObject *args, PyObject *kw) {
FontObject *self;
int error = 0;

char *filename = NULL;
PyBytesObject *filename_bytes = NULL;
float size;
FT_Size_RequestRec req;
FT_Long width;
Expand All @@ -137,51 +137,27 @@ getfont(PyObject *self_, PyObject *args, PyObject *kw) {
return NULL;
}

#if PY_MAJOR_VERSION > 3 || PY_MINOR_VERSION > 11
PyConfig config;
PyConfig_InitPythonConfig(&config);
if (!PyArg_ParseTupleAndKeywords(
args,
kw,
"etf|nsy#n",
"O&f|nsy#n",
kwlist,
config.filesystem_encoding,
&filename,
PyUnicode_FSConverter,
&filename_bytes,
&size,
&index,
&encoding,
&font_bytes,
&font_bytes_size,
&layout_engine
)) {
PyConfig_Clear(&config);
return NULL;
}
PyConfig_Clear(&config);
#else
if (!PyArg_ParseTupleAndKeywords(
args,
kw,
"etf|nsy#n",
kwlist,
Py_FileSystemDefaultEncoding,
&filename,
&size,
&index,
&encoding,
&font_bytes,
&font_bytes_size,
&layout_engine
)) {
return NULL;
}
#endif
const char *filename = PyBytes_AS_STRING(filename_bytes);

self = PyObject_New(FontObject, &Font_Type);
if (!self) {
if (filename) {
PyMem_Free(filename);
}
Py_DECREF(filename_bytes);
return NULL;
}

Expand Down Expand Up @@ -229,19 +205,18 @@ getfont(PyObject *self_, PyObject *args, PyObject *kw) {
FT_MAKE_TAG(encoding[0], encoding[1], encoding[2], encoding[3]);
error = FT_Select_Charmap(self->face, encoding_tag);
}
if (filename) {
PyMem_Free(filename);
}

if (error) {
if (self->font_bytes) {
PyMem_Free(self->font_bytes);
self->font_bytes = NULL;
}
Py_DECREF(filename_bytes);
Py_DECREF(self);
return geterror(error);
}

Py_DECREF(filename_bytes);
return (PyObject *)self;
}

Expand Down
Loading
Loading