Skip to content

Commit 830a245

Browse files
committed
Use PyCapsule in _imagingft
1 parent 5ef4c21 commit 830a245

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/_imagingft.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,6 @@ font_render(FontObject *self, PyObject *args) {
824824
unsigned char convert_scale; /* scale factor for non-8bpp bitmaps */
825825
PyObject *image;
826826
Imaging im;
827-
Py_ssize_t id;
828827
int mask = 0; /* is FT_LOAD_TARGET_MONO enabled? */
829828
int color = 0; /* is FT_LOAD_COLOR enabled? */
830829
int stroke_width = 0;
@@ -923,10 +922,9 @@ font_render(FontObject *self, PyObject *args) {
923922
PyMem_Del(glyph_info);
924923
return NULL;
925924
}
926-
PyObject *imageId = PyObject_GetAttrString(image, "id");
927-
id = PyLong_AsSsize_t(imageId);
928-
Py_XDECREF(imageId);
929-
im = (Imaging)id;
925+
PyObject *imagePtr = PyObject_GetAttrString(image, "ptr");
926+
im = (Imaging)PyCapsule_GetPointer(imagePtr, IMAGING_MAGIC);
927+
Py_XDECREF(imagePtr);
930928

931929
x_offset -= stroke_width;
932930
y_offset -= stroke_width;

0 commit comments

Comments
 (0)