@@ -43,14 +43,6 @@ either expressed or implied, of the FreeBSD Project.
43
43
*/
44
44
45
45
46
- static PyTypeObject Py_Layout_Points_Buffer_Type ;
47
- static PyTypeObject Py_Layout_Glyph_Indices_Buffer_Type ;
48
-
49
-
50
- static PyObject * Py_Layout_Points_Buffer_cnew (PyObject * owner );
51
- static PyObject * Py_Layout_Glyph_Indices_Buffer_cnew (PyObject * owner );
52
-
53
-
54
46
static void
55
47
Py_Layout_dealloc (Py_Layout * self )
56
48
{
@@ -159,116 +151,50 @@ static PyObject *layout_bbox_get(Py_Layout *self, PyObject *closure)
159
151
return Py_BBox_cnew (& self -> x .layout_bbox , 1.0 / (double )(1 << 6 ));
160
152
}
161
153
162
-
163
- static PyObject * glyph_indices_get (Py_Layout * self , PyObject * closure )
154
+ static PyObject * layout_get (Py_Layout * self , PyObject * closure )
164
155
{
165
- return Py_Layout_Glyph_Indices_Buffer_cnew ((PyObject * )self );
166
- }
156
+ PyObject * result ;
157
+ PyObject * subresult ;
158
+ ftpy_Layout * layout ;
159
+ size_t i ;
167
160
161
+ layout = & self -> x ;
168
162
169
- static PyObject * points_get (Py_Layout * self , PyObject * closure )
170
- {
171
- return Py_Layout_Points_Buffer_cnew ((PyObject * )self );
172
- }
163
+ result = PyList_New (layout -> size );
164
+
165
+ if (result == NULL ) {
166
+ return NULL ;
167
+ }
168
+
169
+ for (i = 0 ; i < layout -> size ; ++ i ) {
170
+ subresult = Py_BuildValue (
171
+ "(Ok(dd))" ,
172
+ self -> base .owner ,
173
+ layout -> glyph_indices [i ],
174
+ layout -> xys [i ].x ,
175
+ layout -> xys [i ].y );
176
+ if (subresult == NULL ) {
177
+ Py_DECREF (result );
178
+ return NULL ;
179
+ }
180
+ if (PyList_SetItem (result , i , subresult )) {
181
+ Py_DECREF (subresult );
182
+ Py_DECREF (result );
183
+ return NULL ;
184
+ }
185
+ }
173
186
187
+ return result ;
188
+ }
174
189
175
190
static PyGetSetDef Py_Layout_getset [] = {
176
191
DEF_LAYOUT_GETTER (ink_bbox ),
177
192
DEF_LAYOUT_GETTER (layout_bbox ),
178
- DEF_LAYOUT_GETTER (glyph_indices ),
179
- DEF_LAYOUT_GETTER (points ),
193
+ DEF_LAYOUT_GETTER (layout ),
180
194
{NULL }
181
195
};
182
196
183
197
184
-
185
- /****************************************************************************
186
- Ancillary buffers
187
- */
188
-
189
-
190
- static PyObject *
191
- Py_Layout_Points_Buffer_cnew (PyObject * owner )
192
- {
193
- ftpy_Buffer * self ;
194
- self = (ftpy_Buffer * )(& Py_Layout_Points_Buffer_Type )-> tp_alloc (
195
- & Py_Layout_Points_Buffer_Type , 0 );
196
- Py_INCREF (owner );
197
- self -> base .owner = owner ;
198
- return (PyObject * )self ;
199
- }
200
-
201
-
202
- static int Py_Layout_Points_Buffer_get_buffer (
203
- ftpy_Buffer * self , Py_buffer * view , int flags )
204
- {
205
- ftpy_Layout * layout = & ((Py_Layout * )self -> base .owner )-> x ;
206
- size_t itemsize = sizeof (double );
207
-
208
- Py_INCREF (self );
209
- view -> obj = (PyObject * )self ;
210
- view -> buf = layout -> xys ;
211
- view -> readonly = 1 ;
212
- view -> itemsize = itemsize ;
213
- view -> format = "d" ;
214
- view -> len = layout -> size * 2 * itemsize ;
215
- view -> internal = NULL ;
216
- view -> ndim = 2 ;
217
- view -> shape = self -> shape ;
218
- self -> shape [0 ] = layout -> size ;
219
- self -> shape [1 ] = 2 ;
220
- view -> strides = self -> strides ;
221
- self -> strides [0 ] = itemsize * 2 ;
222
- self -> strides [1 ] = itemsize ;
223
- view -> suboffsets = NULL ;
224
-
225
- return 0 ;
226
- }
227
-
228
-
229
- static PyBufferProcs Py_Layout_Points_Buffer_procs ;
230
-
231
-
232
- static PyObject *
233
- Py_Layout_Glyph_Indices_Buffer_cnew (PyObject * owner )
234
- {
235
- ftpy_Buffer * self ;
236
- self = (ftpy_Buffer * )(& Py_Layout_Glyph_Indices_Buffer_Type )-> tp_alloc (
237
- & Py_Layout_Glyph_Indices_Buffer_Type , 0 );
238
- Py_INCREF (owner );
239
- self -> base .owner = owner ;
240
- return (PyObject * )self ;
241
- }
242
-
243
-
244
- static int Py_Layout_Glyph_Indices_Buffer_get_buffer (
245
- ftpy_Buffer * self , Py_buffer * view , int flags )
246
- {
247
- ftpy_Layout * layout = & ((Py_Layout * )self -> base .owner )-> x ;
248
- size_t itemsize = sizeof (FT_ULong );
249
-
250
- Py_INCREF (self );
251
- view -> obj = (PyObject * )self ;
252
- view -> buf = layout -> glyph_indices ;
253
- view -> readonly = 1 ;
254
- view -> itemsize = itemsize ;
255
- view -> format = "L" ;
256
- view -> len = layout -> size * itemsize ;
257
- view -> internal = NULL ;
258
- view -> ndim = 1 ;
259
- view -> shape = self -> shape ;
260
- self -> shape [0 ] = layout -> size ;
261
- view -> strides = self -> strides ;
262
- self -> strides [0 ] = itemsize ;
263
- view -> suboffsets = NULL ;
264
-
265
- return 0 ;
266
- }
267
-
268
-
269
- static PyBufferProcs Py_Layout_Glyph_Indices_Buffer_procs ;
270
-
271
-
272
198
/****************************************************************************
273
199
Setup
274
200
*/
@@ -293,23 +219,5 @@ int setup_Layout(PyObject *m)
293
219
294
220
ftpy_setup_type (m , & Py_Layout_Type );
295
221
296
- if (ftpy_setup_buffer_type (
297
- & Py_Layout_Points_Buffer_Type ,
298
- "freetypy.Layout.PointsBuffer" ,
299
- doc_Layout_points ,
300
- & Py_Layout_Points_Buffer_procs ,
301
- (getbufferproc )Py_Layout_Points_Buffer_get_buffer )) {
302
- return -1 ;
303
- }
304
-
305
- if (ftpy_setup_buffer_type (
306
- & Py_Layout_Glyph_Indices_Buffer_Type ,
307
- "freetypy.Layout.Glyph_Indices_Buffer" ,
308
- doc_Layout_glyph_indices ,
309
- & Py_Layout_Glyph_Indices_Buffer_procs ,
310
- (getbufferproc )Py_Layout_Glyph_Indices_Buffer_get_buffer )) {
311
- return -1 ;
312
- }
313
-
314
222
return 0 ;
315
223
}
0 commit comments