mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Properly convert font_features to a list
This commit is contained in:
@@ -410,7 +410,7 @@ class FontConfigPattern(TypedDict):
|
|||||||
postscript_name: str
|
postscript_name: str
|
||||||
style: str
|
style: str
|
||||||
spacing: str
|
spacing: str
|
||||||
fontfeatures: str
|
fontfeatures: List[str]
|
||||||
weight: int
|
weight: int
|
||||||
width: int
|
width: int
|
||||||
slant: int
|
slant: int
|
||||||
|
|||||||
@@ -37,7 +37,21 @@ pattern_as_dict(FcPattern *pat) {
|
|||||||
if (PyDict_SetItemString(ans, #name, p) != 0) { Py_CLEAR(p); Py_CLEAR(ans); return NULL; } \
|
if (PyDict_SetItemString(ans, #name, p) != 0) { Py_CLEAR(p); Py_CLEAR(ans); return NULL; } \
|
||||||
Py_CLEAR(p); \
|
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 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 I(which, key) G(int, FcPatternGetInteger, which, PyLong_FromLong, key)
|
||||||
#define B(which, key) G(int, FcPatternGetBool, which, pybool, key)
|
#define B(which, key) G(int, FcPatternGetBool, which, pybool, key)
|
||||||
#define E(which, key, conv) G(int, FcPatternGetInteger, which, conv, 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_STYLE, style);
|
||||||
S(FC_FULLNAME, full_name);
|
S(FC_FULLNAME, full_name);
|
||||||
S(FC_POSTSCRIPT_NAME, postscript_name);
|
S(FC_POSTSCRIPT_NAME, postscript_name);
|
||||||
S(FC_FONT_FEATURES, fontfeatures);
|
LS(FC_FONT_FEATURES, fontfeatures);
|
||||||
I(FC_WEIGHT, weight);
|
I(FC_WEIGHT, weight);
|
||||||
I(FC_WIDTH, width)
|
I(FC_WIDTH, width)
|
||||||
I(FC_SLANT, slant);
|
I(FC_SLANT, slant);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def find_font_features(postscript_name: str) -> Tuple[str, ...]:
|
|||||||
return tuple()
|
return tuple()
|
||||||
|
|
||||||
features = []
|
features = []
|
||||||
for feat in pat['fontfeatures'].split():
|
for feat in pat['fontfeatures']:
|
||||||
try:
|
try:
|
||||||
parsed = parse_font_feature(feat)
|
parsed = parse_font_feature(feat)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Reference in New Issue
Block a user