commit
80af2812fb
11 changed files with 160 additions and 119 deletions
@ -0,0 +1,10 @@ |
||||
This contains a wrapping of harfbuzz into python. The module is dependent on pyrex. To build, type: |
||||
|
||||
python setup.py build |
||||
|
||||
In addition there is a test application, hbtestfont. It has GTK based gui output and for this, python modules for gtk, gobject and cairo are needed. The application may be run without gui output using the --nogui option. |
||||
|
||||
Applications may be executed in the build context, without needing to install any modules or libraries, using the runpy script from the contrib/python directory. Thus one might type: |
||||
|
||||
./runpy script/hbtestfont -f "Charis SIL" 0048 0069 0303 |
||||
|
@ -0,0 +1,47 @@ |
||||
cdef extern from "fontconfig/fontconfig.h" : |
||||
ctypedef struct FcPattern : |
||||
pass |
||||
ctypedef struct FcConfig : |
||||
pass |
||||
cdef enum FcResult '_FcResult' : |
||||
FcResultMatch = 0, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId, |
||||
FcResultOutOfMemory |
||||
|
||||
ctypedef char FcChar8 |
||||
FcPattern *FcNameParse(FcChar8 *name) |
||||
FcPattern *FcFontMatch(FcConfig *config, FcPattern *match, FcResult *res) |
||||
FcResult FcPatternGetInteger(FcPattern *pattern, char *typeid, int index, int *res) |
||||
FcResult FcPatternGetString(FcPattern *pattern, char *typeid, int index, FcChar8 **res) |
||||
void FcPatternPrint(FcPattern *pattern) |
||||
void FcPatternDestroy(FcPattern *pattern) |
||||
|
||||
FcConfig *FcConfigGetCurrent() |
||||
|
||||
cdef class fcPattern : |
||||
cdef FcPattern *_pattern |
||||
|
||||
def __init__(self, char *name) : |
||||
cdef FcPattern *temp |
||||
cdef FcResult res |
||||
|
||||
temp = FcNameParse(<FcChar8 *>name) |
||||
self._pattern = FcFontMatch(FcConfigGetCurrent(), temp, &res) |
||||
if res != FcResultMatch : |
||||
print "Failed to match" + str(res) |
||||
self._pattern = <FcPattern *>0 |
||||
|
||||
def __destroy__(self) : |
||||
FcPatternDestroy(self._pattern) |
||||
|
||||
def getInteger(self, char *typeid, int index) : |
||||
cdef int res |
||||
if self._pattern == <FcPattern *>0 or FcPatternGetInteger(self._pattern, typeid, index, &res) != FcResultMatch : return None |
||||
return res |
||||
|
||||
def getString(self, char *typeid, int index) : |
||||
cdef FcChar8 *res |
||||
if self._pattern == <FcPattern *>0 or FcPatternGetString(self._pattern, typeid, index, &res) != FcResultMatch : return None |
||||
return <char *>res |
||||
|
||||
def debugPrint(self) : |
||||
FcPatternPrint(self._pattern) |
Loading…
Reference in new issue