@@ -37,7 +37,21 @@ pattern_as_dict(FcPattern *pat) {
3737 if (PyDict_SetItemString(ans, #name, p) != 0) { Py_CLEAR(p); Py_CLEAR(ans); return NULL; } \
3838 Py_CLEAR(p); \
3939 }}
40+
41+ #define L (type , get , which , conv , name ) { \
42+ type out; PyObject *p; int n = 0; \
43+ PyObject *l = PyList_New(0); \
44+ while (get(pat, which, n, &out) == FcResultMatch) { \
45+ p = conv(out); if (p == NULL) { Py_CLEAR(l); Py_CLEAR(ans); return NULL; } \
46+ if (PyList_Append(l, p) != 0) { Py_CLEAR(p); Py_CLEAR(l); Py_CLEAR(ans); return NULL; } \
47+ Py_CLEAR(p); \
48+ n++; \
49+ } \
50+ if (PyDict_SetItemString(ans, #name, l) != 0) { Py_CLEAR(l); Py_CLEAR(ans); return NULL; } \
51+ Py_CLEAR(l); \
52+ }
4053#define S (which , key ) G(FcChar8*, FcPatternGetString, which, PS, key)
54+ #define LS (which , key ) L(FcChar8*, FcPatternGetString, which, PS, key)
4155#define I (which , key ) G(int, FcPatternGetInteger, which, PyLong_FromLong, key)
4256#define B (which , key ) G(int, FcPatternGetBool, which, pybool, key)
4357#define E (which , key , conv ) G(int, FcPatternGetInteger, which, conv, key)
@@ -46,6 +60,7 @@ pattern_as_dict(FcPattern *pat) {
4660 S (FC_STYLE , style );
4761 S (FC_FULLNAME , full_name );
4862 S (FC_POSTSCRIPT_NAME , postscript_name );
63+ LS (FC_FONT_FEATURES , fontfeatures );
4964 I (FC_WEIGHT , weight );
5065 I (FC_WIDTH , width )
5166 I (FC_SLANT , slant );
@@ -179,6 +194,26 @@ fc_match(PyObject UNUSED *self, PyObject *args) {
179194 return ans ;
180195}
181196
197+ static PyObject *
198+ fc_match_postscript_name (PyObject UNUSED * self , PyObject * args ) {
199+ char * postscript_name = NULL ;
200+ FcPattern * pat = NULL ;
201+ PyObject * ans = NULL ;
202+
203+ if (!PyArg_ParseTuple (args , "|z" , & postscript_name )) return NULL ;
204+ pat = FcPatternCreate ();
205+ if (pat == NULL ) return PyErr_NoMemory ();
206+ if (!postscript_name || strlen (postscript_name ) == 0 ) return NULL ;
207+
208+ AP (FcPatternAddString , FC_POSTSCRIPT_NAME , (const FcChar8 * )postscript_name , "postscript_name" );
209+
210+ ans = _fc_match (pat );
211+
212+ end :
213+ if (pat != NULL ) FcPatternDestroy (pat );
214+ return ans ;
215+ }
216+
182217PyObject *
183218specialize_font_descriptor (PyObject * base_descriptor , FONTS_DATA_HANDLE fg ) {
184219 PyObject * p = PyDict_GetItemString (base_descriptor , "path" ), * ans = NULL ;
@@ -224,6 +259,7 @@ create_fallback_face(PyObject UNUSED *base_face, CPUCell* cell, bool bold, bool
224259static PyMethodDef module_methods [] = {
225260 METHODB (fc_list , METH_VARARGS ),
226261 METHODB (fc_match , METH_VARARGS ),
262+ METHODB (fc_match_postscript_name , METH_VARARGS ),
227263 {NULL , NULL , 0 , NULL } /* Sentinel */
228264};
229265
0 commit comments