@@ -258,7 +258,6 @@ typedef struct
258
258
{
259
259
PyObject_HEAD
260
260
FT2Font *x;
261
- PyObject *fname;
262
261
PyObject *py_file;
263
262
FT_StreamRec stream;
264
263
Py_ssize_t shape[2 ];
@@ -317,7 +316,6 @@ static PyObject *PyFT2Font_new(PyTypeObject *type, PyObject *args, PyObject *kwd
317
316
PyFT2Font *self;
318
317
self = (PyFT2Font *)type->tp_alloc (type, 0 );
319
318
self->x = NULL ;
320
- self->fname = NULL ;
321
319
self->py_file = NULL ;
322
320
memset (&self->stream , 0 , sizeof (FT_StreamRec));
323
321
return (PyObject *)self;
@@ -408,9 +406,6 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
408
406
409
407
CALL_CPP_INIT (" FT2Font->set_kerning_factor" , (self->x ->set_kerning_factor (kerning_factor)));
410
408
411
- Py_INCREF (filename);
412
- self->fname = filename;
413
-
414
409
exit :
415
410
return PyErr_Occurred () ? -1 : 0 ;
416
411
}
@@ -419,7 +414,6 @@ static void PyFT2Font_dealloc(PyFT2Font *self)
419
414
{
420
415
delete self->x ;
421
416
Py_XDECREF (self->py_file );
422
- Py_XDECREF (self->fname );
423
417
Py_TYPE (self)->tp_free ((PyObject *)self);
424
418
}
425
419
@@ -1420,12 +1414,12 @@ static PyObject *PyFT2Font_underline_thickness(PyFT2Font *self, void *closure)
1420
1414
1421
1415
static PyObject *PyFT2Font_fname (PyFT2Font *self, void *closure)
1422
1416
{
1423
- if (self->fname ) {
1424
- Py_INCREF (self->fname );
1425
- return self->fname ;
1417
+ if (self->stream .close ) { // Called passed a filename to the constructor.
1418
+ return PyObject_GetAttrString (self->py_file , " name" );
1419
+ } else {
1420
+ Py_INCREF (self->py_file );
1421
+ return self->py_file ;
1426
1422
}
1427
-
1428
- Py_RETURN_NONE;
1429
1423
}
1430
1424
1431
1425
static int PyFT2Font_get_buffer (PyFT2Font *self, Py_buffer *buf, int flags)
0 commit comments