@@ -74,7 +74,7 @@ static unsigned long read_from_file_callback(
74
74
FT_Stream stream , unsigned long offset , unsigned char * buffer ,
75
75
unsigned long count ) {
76
76
77
- Py_Face * self = (Py_Face * )stream -> descriptor .pointer ;
77
+ Py_Face_Stream_Meta * self = (Py_Face_Stream_Meta * )stream -> descriptor .pointer ;
78
78
79
79
if (ftpy_fseek (self -> fp , offset , SEEK_SET ) == -1 ) {
80
80
return 0 ;
@@ -90,7 +90,7 @@ static unsigned long read_from_file_callback(
90
90
91
91
static void close_file_callback (FT_Stream stream )
92
92
{
93
- Py_Face * self = (Py_Face * )stream -> descriptor .pointer ;
93
+ Py_Face_Stream_Meta * self = (Py_Face_Stream_Meta * )stream -> descriptor .pointer ;
94
94
95
95
ftpy_PyFile_DupClose (self -> py_file , self -> fp , self -> offset );
96
96
@@ -111,7 +111,7 @@ static void close_file_callback(FT_Stream stream)
111
111
static int _py_file_to_open_args (
112
112
PyObject * py_file_arg ,
113
113
FT_Open_Args * open_args ,
114
- Py_Face * face )
114
+ Py_Face_Stream_Meta * meta )
115
115
{
116
116
PyObject * py_file = NULL ;
117
117
int close_file = 0 ;
@@ -140,23 +140,23 @@ static int _py_file_to_open_args(
140
140
141
141
if ((fp = ftpy_PyFile_Dup (py_file , (char * )"rb" , & offset ))) {
142
142
Py_INCREF (py_file );
143
- face -> py_file = py_file ;
144
- face -> close_file = close_file ;
145
- face -> fp = fp ;
146
- face -> offset = offset ;
143
+ meta -> py_file = py_file ;
144
+ meta -> close_file = close_file ;
145
+ meta -> fp = fp ;
146
+ meta -> offset = offset ;
147
147
fseek (fp , 0 , SEEK_END );
148
148
file_size = ftpy_ftell (fp );
149
149
fseek (fp , 0 , SEEK_SET );
150
150
151
- face -> stream .base = NULL ;
152
- face -> stream .size = (unsigned long )file_size ;
153
- face -> stream .pos = 0 ;
154
- face -> stream .descriptor .pointer = face ;
155
- face -> stream .read = & read_from_file_callback ;
156
- face -> stream .close = & close_file_callback ;
151
+ meta -> stream .base = NULL ;
152
+ meta -> stream .size = (unsigned long )file_size ;
153
+ meta -> stream .pos = 0 ;
154
+ meta -> stream .descriptor .pointer = meta ;
155
+ meta -> stream .read = & read_from_file_callback ;
156
+ meta -> stream .close = & close_file_callback ;
157
157
158
158
open_args -> flags = FT_OPEN_STREAM ;
159
- open_args -> stream = & face -> stream ;
159
+ open_args -> stream = & meta -> stream ;
160
160
161
161
result = 0 ;
162
162
goto exit ;
@@ -179,15 +179,15 @@ static int _py_file_to_open_args(
179
179
goto exit ;
180
180
}
181
181
182
- if (face -> mem ) {
183
- free (face -> mem );
182
+ if (meta -> mem ) {
183
+ free (meta -> mem );
184
184
}
185
- face -> mem = PyMem_Malloc (face -> mem_size + data_len );
186
- if (face -> mem == NULL ) {
185
+ meta -> mem = PyMem_Malloc (meta -> mem_size + data_len );
186
+ if (meta -> mem == NULL ) {
187
187
goto exit ;
188
188
}
189
- new_memory = face -> mem + face -> mem_size ;
190
- face -> mem_size += data_len ;
189
+ new_memory = meta -> mem + meta -> mem_size ;
190
+ meta -> mem_size += data_len ;
191
191
192
192
memcpy (new_memory , data_ptr , data_len );
193
193
open_args -> flags = FT_OPEN_MEMORY ;
@@ -226,9 +226,11 @@ Py_Face_dealloc(Py_Face* self)
226
226
if (self -> x ) {
227
227
FT_Done_Face (self -> x );
228
228
}
229
- Py_XDECREF (self -> py_file );
229
+ Py_XDECREF (self -> main .py_file );
230
+ free (self -> main .mem );
231
+ Py_XDECREF (self -> attach .py_file );
232
+ free (self -> attach .mem );
230
233
Py_XDECREF (self -> filename );
231
- free (self -> mem );
232
234
Py_TYPE (self )-> tp_clear ((PyObject * )self );
233
235
Py_TYPE (self )-> tp_free ((PyObject * )self );
234
236
}
@@ -246,10 +248,10 @@ Py_Face_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
246
248
Py_INCREF (freetypy_module );
247
249
self -> base .owner = freetypy_module ;
248
250
self -> x = NULL ;
249
- memset (& self -> stream , 0 , sizeof (FT_StreamRec ));
250
- self -> mem = NULL ;
251
- self -> mem_size = 0 ;
251
+ self -> load_flags = 0 ;
252
252
self -> filename = NULL ;
253
+ memset (& self -> main , 0 , sizeof (Py_Face_Stream_Meta ));
254
+ memset (& self -> attach , 0 , sizeof (Py_Face_Stream_Meta ));
253
255
return (PyObject * )self ;
254
256
}
255
257
@@ -270,7 +272,7 @@ Py_Face_init(Py_Face *self, PyObject *args, PyObject *kwds)
270
272
return -1 ;
271
273
}
272
274
273
- if (_py_file_to_open_args (py_file_arg , & open_args , self )) {
275
+ if (_py_file_to_open_args (py_file_arg , & open_args , & self -> main )) {
274
276
goto exit ;
275
277
}
276
278
@@ -533,7 +535,7 @@ Py_Face_attach(Py_Face *self, PyObject *args, PyObject *kwds)
533
535
return NULL ;
534
536
}
535
537
536
- if (_py_file_to_open_args (py_file_arg , & open_args , self )) {
538
+ if (_py_file_to_open_args (py_file_arg , & open_args , & self -> attach )) {
537
539
return NULL ;
538
540
}
539
541
0 commit comments