mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 07:55:10 +02:00
Properly convert font_features to a list
This commit is contained in:
@@ -37,7 +37,21 @@ pattern_as_dict(FcPattern *pat) {
|
||||
if (PyDict_SetItemString(ans, #name, p) != 0) { Py_CLEAR(p); Py_CLEAR(ans); return NULL; } \
|
||||
Py_CLEAR(p); \
|
||||
}}
|
||||
|
||||
#define L(type, get, which, conv, name) { \
|
||||
type out; PyObject *p; int n = 0; \
|
||||
PyObject *l = PyList_New(0); \
|
||||
while (get(pat, which, n, &out) == FcResultMatch) { \
|
||||
p = conv(out); if (p == NULL) { Py_CLEAR(l); Py_CLEAR(ans); return NULL; } \
|
||||
if (PyList_Append(l, p) != 0) { Py_CLEAR(p); Py_CLEAR(l); Py_CLEAR(ans); return NULL; } \
|
||||
Py_CLEAR(p); \
|
||||
n++; \
|
||||
} \
|
||||
if (PyDict_SetItemString(ans, #name, l) != 0) { Py_CLEAR(l); Py_CLEAR(ans); return NULL; } \
|
||||
Py_CLEAR(l); \
|
||||
}
|
||||
#define S(which, key) G(FcChar8*, FcPatternGetString, which, PS, key)
|
||||
#define LS(which, key) L(FcChar8*, FcPatternGetString, which, PS, key)
|
||||
#define I(which, key) G(int, FcPatternGetInteger, which, PyLong_FromLong, key)
|
||||
#define B(which, key) G(int, FcPatternGetBool, which, pybool, key)
|
||||
#define E(which, key, conv) G(int, FcPatternGetInteger, which, conv, key)
|
||||
@@ -46,7 +60,7 @@ pattern_as_dict(FcPattern *pat) {
|
||||
S(FC_STYLE, style);
|
||||
S(FC_FULLNAME, full_name);
|
||||
S(FC_POSTSCRIPT_NAME, postscript_name);
|
||||
S(FC_FONT_FEATURES, fontfeatures);
|
||||
LS(FC_FONT_FEATURES, fontfeatures);
|
||||
I(FC_WEIGHT, weight);
|
||||
I(FC_WIDTH, width)
|
||||
I(FC_SLANT, slant);
|
||||
|
||||
Reference in New Issue
Block a user