@@ -264,6 +264,7 @@ typedef struct
264
264
Py_ssize_t shape[2 ];
265
265
Py_ssize_t strides[2 ];
266
266
Py_ssize_t suboffsets[2 ];
267
+ std::vector<FT2Font *> fallbacks;
267
268
} PyFT2Font;
268
269
269
270
static unsigned long read_from_file_callback (FT_Stream stream,
@@ -361,15 +362,18 @@ const char *PyFT2Font_init__doc__ =
361
362
362
363
static int PyFT2Font_init (PyFT2Font *self, PyObject *args, PyObject *kwds)
363
364
{
364
- PyObject *filename = NULL , *open = NULL , *data = NULL ;
365
+ printf (" PyFT2Font init!\n " );
366
+ PyObject *filename = NULL , *open = NULL , *data = NULL , *fallback_list = NULL ;
365
367
FT_Open_Args open_args;
366
368
long hinting_factor = 8 ;
367
369
int kerning_factor = 0 ;
368
- const char *names[] = { " filename" , " hinting_factor" , " _kerning_factor" , NULL };
370
+ const char *names[] = {
371
+ " filename" , " hinting_factor" , " _fallback_list" , " _kerning_factor" , NULL
372
+ };
369
373
370
374
if (!PyArg_ParseTupleAndKeywords (
371
- args, kwds, " O|l$i :FT2Font" , (char **)names, &filename,
372
- &hinting_factor, &kerning_factor)) {
375
+ args, kwds, " O|l$Oi :FT2Font" , (char **)names, &filename,
376
+ &hinting_factor, &fallback_list, & kerning_factor)) {
373
377
return -1 ;
374
378
}
375
379
@@ -382,6 +386,21 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
382
386
open_args.flags = FT_OPEN_STREAM;
383
387
open_args.stream = &self->stream ;
384
388
389
+ if (fallback_list && PyList_Check (fallback_list)) {
390
+ Py_ssize_t size = PyList_Size (fallback_list);
391
+
392
+ for (int i = 0 ; i < size; ++i) {
393
+ PyObject* item = PyList_GetItem (fallback_list, i);
394
+
395
+ // TODO: check whether item is actually an FT2Font
396
+ FT2Font *fback = reinterpret_cast <PyFT2Font *>(item)->x ;
397
+ self->fallbacks .push_back (fback);
398
+ }
399
+
400
+ Py_INCREF (fallback_list);
401
+ }
402
+ printf (" Fallback SIZE: %lu \n " , self->fallbacks .size ());
403
+
385
404
if (PyBytes_Check (filename) || PyUnicode_Check (filename)) {
386
405
if (!(open = PyDict_GetItemString (PyEval_GetBuiltins (), " open" )) // Borrowed reference.
387
406
|| !(self->py_file = PyObject_CallFunction (open , " Os" , filename, " rb" ))) {
@@ -403,7 +422,7 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
403
422
Py_CLEAR (data);
404
423
405
424
CALL_CPP_FULL (
406
- " FT2Font" , (self->x = new FT2Font (open_args, hinting_factor)),
425
+ " FT2Font" , (self->x = new FT2Font (open_args, hinting_factor, self-> fallbacks )),
407
426
Py_CLEAR (self->py_file ), -1 );
408
427
409
428
CALL_CPP_INIT (" FT2Font->set_kerning_factor" , (self->x ->set_kerning_factor (kerning_factor)));
@@ -444,6 +463,7 @@ static PyObject *PyFT2Font_set_size(PyFT2Font *self, PyObject *args, PyObject *k
444
463
{
445
464
double ptsize;
446
465
double dpi;
466
+ printf (" PyFT, set_size called!\n " );
447
467
448
468
if (!PyArg_ParseTuple (args, " dd:set_size" , &ptsize, &dpi)) {
449
469
return NULL ;
0 commit comments