From 0084f93e1b73ebe0970abe318add72ba1fc9a606 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 18 Aug 2024 17:22:12 +0530 Subject: [PATCH] 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 --- docs/changelog.rst | 2 ++ kitty/font-names.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c497ae40f..37878e017 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -79,6 +79,8 @@ Detailed list of changes - Allow specifying that the :opt:`cursor shape for unfocused windows ` 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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/font-names.c b/kitty/font-names.c index 1e2220e84..7e6cf0d84 100644 --- a/kitty/font-names.c +++ b/kitty/font-names.c @@ -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);