MacOS Intel: Fix a crash in the choose-fonts kitten when displaying previews of variable fonts

Looks like a bug in Py_BuildValue for s# values on that platform. Workaround by
constructing the string directly and passing to to Py_BuildValue.

Fixes #7734
This commit is contained in:
Kovid Goyal
2024-08-18 17:22:12 +05:30
parent 33fa9a08e4
commit 0084f93e1b
2 changed files with 4 additions and 2 deletions

View File

@@ -79,6 +79,8 @@ Detailed list of changes
- Allow specifying that the :opt:`cursor shape for unfocused windows <cursor_shape_unfocused>` should remain unchanged (:pull:`7728`)
- MacOS Intel: Fix a crash in the choose-fonts kitten when displaying previews of variable fonts (:iss:`7734`)
0.36.0 [2024-08-17]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -325,8 +325,8 @@ read_fvar_font_table(const uint8_t *table, size_t table_len, PyObject *name_look
const double minimum = next32, def = next32, maximum = next32;
p = (uint16_t*)(pos + 16);
int32_t flags = next, strid = next;
PyObject *axis = Py_BuildValue("{sd sd sd ss# sO sN}",
"minimum", minimum, "maximum", maximum, "default", def, "tag", pos, 4,
PyObject *axis = Py_BuildValue("{sd sd sd sN sO sN}",
"minimum", minimum, "maximum", maximum, "default", def, "tag", PyUnicode_FromStringAndSize((const char*)pos, 4),
"hidden", (flags & 1) ? Py_True : Py_False, "strid", get_best_name(name_lookup_table, strid)
); if (!axis) return NULL;
PyTuple_SET_ITEM(axes, i, axis);