Add tests to validate feature-from-spec

This commit is contained in:
Kovid Goyal
2024-05-26 09:49:00 +05:30
parent 060732b428
commit 57edb412e6
6 changed files with 64 additions and 5 deletions

View File

@@ -847,6 +847,20 @@ get_variation(Face *self, PyObject *a UNUSED) {
Py_INCREF(ans); return ans;
}
static PyObject*
applied_features(Face *self, PyObject *a UNUSED) {
RAII_PyObject(ans, PyTuple_New(self->font_features.count));
if (!ans) return NULL;
char buf[256];
for (size_t i = 0; i < self->font_features.count; i++) {
hb_feature_to_string(&self->font_features.features[i], buf, arraysz(buf));
PyObject *t = PyUnicode_FromString(buf);
if (!t) return NULL;
PyTuple_SET_ITEM(ans, i, t);
}
Py_INCREF(ans); return ans;
}
static PyObject*
get_features(Face *self, PyObject *a UNUSED) {
FT_Error err;
@@ -1023,6 +1037,7 @@ static PyMethodDef methods[] = {
METHODB(identify_for_debug, METH_NOARGS),
METHODB(extra_data, METH_NOARGS),
METHODB(get_variable_data, METH_NOARGS),
METHODB(applied_features, METH_NOARGS),
METHODB(get_features, METH_NOARGS),
METHODB(get_variation, METH_NOARGS),
METHODB(get_best_name, METH_O),