Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d0906aa

Browse filesBrowse files
committed
Parse fallback_list through wrapper
1 parent f8f6939 commit d0906aa
Copy full SHA for d0906aa

File tree

Expand file treeCollapse file tree

1 file changed

+25
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-5
lines changed

‎src/ft2font_wrapper.cpp

Copy file name to clipboardExpand all lines: src/ft2font_wrapper.cpp
+25-5Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ typedef struct
264264
Py_ssize_t shape[2];
265265
Py_ssize_t strides[2];
266266
Py_ssize_t suboffsets[2];
267+
std::vector<FT2Font *> fallbacks;
267268
} PyFT2Font;
268269

269270
static unsigned long read_from_file_callback(FT_Stream stream,
@@ -361,15 +362,18 @@ const char *PyFT2Font_init__doc__ =
361362

362363
static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
363364
{
364-
PyObject *filename = NULL, *open = NULL, *data = NULL;
365+
printf("PyFT2Font init!\n");
366+
PyObject *filename = NULL, *open = NULL, *data = NULL, *fallback_list = NULL;
365367
FT_Open_Args open_args;
366368
long hinting_factor = 8;
367369
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+
};
369373

370374
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)) {
373377
return -1;
374378
}
375379

@@ -382,6 +386,21 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
382386
open_args.flags = FT_OPEN_STREAM;
383387
open_args.stream = &self->stream;
384388

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+
385404
if (PyBytes_Check(filename) || PyUnicode_Check(filename)) {
386405
if (!(open = PyDict_GetItemString(PyEval_GetBuiltins(), "open")) // Borrowed reference.
387406
|| !(self->py_file = PyObject_CallFunction(open, "Os", filename, "rb"))) {
@@ -403,7 +422,7 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)
403422
Py_CLEAR(data);
404423

405424
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)),
407426
Py_CLEAR(self->py_file), -1);
408427

409428
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
444463
{
445464
double ptsize;
446465
double dpi;
466+
printf("PyFT, set_size called!\n");
447467

448468
if (!PyArg_ParseTuple(args, "dd:set_size", &ptsize, &dpi)) {
449469
return NULL;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.