@@ -258,7 +258,6 @@ typedef struct
258258{
259259 PyObject_HEAD
260260 FT2Font *x;
261- PyObject *fname;
262261 PyObject *py_file;
263262 FT_StreamRec stream;
264263 Py_ssize_t shape[2 ];
@@ -317,7 +316,6 @@ static PyObject *PyFT2Font_new(PyTypeObject *type, PyObject *args, PyObject *kwd
317316 PyFT2Font *self;
318317 self = (PyFT2Font *)type->tp_alloc (type, 0 );
319318 self->x = NULL ;
320- self->fname = NULL ;
321319 self->py_file = NULL ;
322320 memset (&self->stream , 0 , sizeof (FT_StreamRec));
323321 return (PyObject *)self;
@@ -408,9 +406,6 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
408406
409407 CALL_CPP_INIT (" FT2Font->set_kerning_factor" , (self->x ->set_kerning_factor (kerning_factor)));
410408
411- Py_INCREF (filename);
412- self->fname = filename;
413-
414409exit:
415410 return PyErr_Occurred () ? -1 : 0 ;
416411}
@@ -419,7 +414,6 @@ static void PyFT2Font_dealloc(PyFT2Font *self)
419414{
420415 delete self->x ;
421416 Py_XDECREF (self->py_file );
422- Py_XDECREF (self->fname );
423417 Py_TYPE (self)->tp_free ((PyObject *)self);
424418}
425419
@@ -1420,12 +1414,12 @@ static PyObject *PyFT2Font_underline_thickness(PyFT2Font *self, void *closure)
14201414
14211415static PyObject *PyFT2Font_fname (PyFT2Font *self, void *closure)
14221416{
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 ;
14261422 }
1427-
1428- Py_RETURN_NONE;
14291423}
14301424
14311425static int PyFT2Font_get_buffer (PyFT2Font *self, Py_buffer *buf, int flags)
0 commit comments