1 cdef extern from "fontconfig/fontconfig.h" :
2 ctypedef struct FcPattern :
4 ctypedef struct FcConfig :
6 cdef enum FcResult '_FcResult' :
7 FcResultMatch = 0, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId,
11 FcPattern *FcNameParse(FcChar8 *name)
12 FcPattern *FcFontMatch(FcConfig *config, FcPattern *match, FcResult *res)
13 FcResult FcPatternGetInteger(FcPattern *pattern, char *typeid, int index, int *res)
14 FcResult FcPatternGetString(FcPattern *pattern, char *typeid, int index, FcChar8 **res)
15 void FcPatternPrint(FcPattern *pattern)
16 void FcPatternDestroy(FcPattern *pattern)
18 FcConfig *FcConfigGetCurrent()
20 cdef class fcPattern :
21 cdef FcPattern *_pattern
23 def __init__(self, char *name) :
27 temp = FcNameParse(<FcChar8 *>name)
28 self._pattern = FcFontMatch(FcConfigGetCurrent(), temp, &res)
29 if res != FcResultMatch :
30 print "Failed to match" + str(res)
31 self._pattern = <FcPattern *>0
33 def __destroy__(self) :
34 FcPatternDestroy(self._pattern)
36 def getInteger(self, char *typeid, int index) :
38 if self._pattern == <FcPattern *>0 or FcPatternGetInteger(self._pattern, typeid, index, &res) != FcResultMatch : return None
41 def getString(self, char *typeid, int index) :
43 if self._pattern == <FcPattern *>0 or FcPatternGetString(self._pattern, typeid, index, &res) != FcResultMatch : return None
46 def debugPrint(self) :
47 FcPatternPrint(self._pattern)