Add graphite2 integration from Martin Hosken To be modified, a lot.
diff --git a/contrib/python/lib/harfbuzz.pyx b/contrib/python/lib/harfbuzz.pyx index f483fd6..3e3774e 100644 --- a/contrib/python/lib/harfbuzz.pyx +++ b/contrib/python/lib/harfbuzz.pyx
@@ -29,17 +29,15 @@ ctypedef unsigned long hb_tag_t hb_tag_t hb_tag_from_string (char *s) ctypedef void (*hb_destroy_func_t) (void *user_data) + ctypedef void *hb_language_t + hb_language_t hb_language_from_string(char *str) + char * hb_language_to_string(hb_language_t language) cdef extern from "hb-unicode.h" : # there must be a better way of syncing this list with the true source ctypedef enum hb_script_t : HB_SCRIPT_COMMON = 0 -cdef extern from "hb-language.h" : - ctypedef void *hb_language_t - hb_language_t hb_language_from_string(char *str) - char * hb_language_to_string(hb_language_t language) - cdef extern from "hb-ot-tag.h" : hb_script_t hb_ot_tag_to_script (hb_tag_t tag) @@ -80,8 +78,8 @@ void hb_buffer_add_glyph(hb_buffer_t *buffer, hb_codepoint_t codepoint, hb_mask_t mask, unsigned int cluster) void hb_buffer_add_utf8(hb_buffer_t *buffer, char *text, unsigned int text_length, unsigned int item_offset, unsigned int item_length) unsigned int hb_buffer_get_length(hb_buffer_t *buffer) - hb_glyph_info_t *hb_buffer_get_glyph_infos(hb_buffer_t *buffer) - hb_glyph_position_t *hb_buffer_get_glyph_positions(hb_buffer_t *buffer) + hb_glyph_info_t *hb_buffer_get_glyph_infos(hb_buffer_t *buffer, unsigned int *len) + hb_glyph_position_t *hb_buffer_get_glyph_positions(hb_buffer_t *buffer, unsigned int *len) cdef extern from "hb-blob.h" : cdef struct hb_blob_t : @@ -111,7 +109,7 @@ unsigned int start unsigned int end - void hb_shape (hb_font_t *font, hb_face_t *face, hb_buffer_t *buffer, hb_feature_t *features, unsigned int num_features) + void hb_shape (hb_font_t *font, hb_buffer_t *buffer, hb_feature_t *features, unsigned int num_features) cdef extern from "hb-ft.h" : hb_face_t *hb_ft_face_create (FT_Face ft_face, hb_destroy_func_t destroy) @@ -156,8 +154,8 @@ res = [] num = hb_buffer_get_length(self.buffer) - infos = hb_buffer_get_glyph_infos(self.buffer) - positions = hb_buffer_get_glyph_positions(self.buffer) + infos = hb_buffer_get_glyph_infos(self.buffer, &num) + positions = hb_buffer_get_glyph_positions(self.buffer, &num) for 0 <= i < num : temp = glyphinfo(infos[i].codepoint, infos[i].cluster, (positions[i].x_advance / scale, positions[i].y_advance / scale), (positions[i].x_offset / scale, positions[i].y_offset / scale), positions[i].var.u32) res.append(temp) @@ -210,6 +208,6 @@ aFeat.start = 0 aFeat.end = -1 aFeat += 1 - hb_shape(self.hbfont, self.hbface, aBuffer.buffer, feats, len(features)) + hb_shape(self.hbfont, aBuffer.buffer, feats, len(features))
diff --git a/contrib/python/runpy b/contrib/python/runpy deleted file mode 100755 index b39db1b..0000000 --- a/contrib/python/runpy +++ /dev/null
@@ -1,2 +0,0 @@ -#!/bin/sh -LD_LIBRARY_PATH=../../src/.libs PYTHONPATH=build/lib.`python -c 'import distutils.util, sys; print distutils.util.get_platform()+"-"+str(sys.version_info[0])+"."+str(sys.version_info[1])'` "$@"
diff --git a/contrib/python/scripts/hbtestfont b/contrib/python/scripts/hbtestfont index 7736ae6..4437105 100755 --- a/contrib/python/scripts/hbtestfont +++ b/contrib/python/scripts/hbtestfont
@@ -100,9 +100,9 @@ glyphs = [] org = [0, 0] for g in res : - glyphs.append((g.gid, org[0] + g.offset[0], org[1] + g.offset[1])) + glyphs.append((g.gid, org[0] + g.offset[0], org[1] - g.offset[1])) org[0] += g.advance[0] - org[1] += g.advance[1] + org[1] -= g.advance[1] gobject.type_register(GlyphsWindow) win = gtk.Window()
diff --git a/contrib/python/setup.py b/contrib/python/setup.py index f592728..681c53b 100755 --- a/contrib/python/setup.py +++ b/contrib/python/setup.py
@@ -1,10 +1,23 @@ #!/usr/bin/python from distutils.core import setup +from optparse import OptionParser from glob import glob from Pyrex.Distutils.extension import Extension from Pyrex.Distutils import build_ext +parser = OptionParser() +parser.add_option('-b','--build', help='Build directory in which libraries are found. Relative to project root') +parser.disable_interspersed_args() + +(opts, args) = parser.parse_args() + +rfile = file("runpy", "w") +rfile.write("""#!/bin/sh +LD_LIBRARY_PATH=../../%s/src/.libs PYTHONPATH=build/lib.`python -c 'import distutils.util, sys; print distutils.util.get_platform()+"-"+str(sys.version_info[0])+"."+str(sys.version_info[1])'` "$@" +""" % opts.build) +rfile.close() + setup(name='harfbuzz', version='0.0.1', description='Harfbuzz compatibility layer', @@ -13,13 +26,14 @@ maintainer_email='martin_hosken@sil.org', packages=['harfbuzz'], ext_modules = [ - Extension("harfbuzz", ["lib/harfbuzz.pyx"], libraries=["harfbuzz"], library_dirs=["../../src/.libs"], include_dirs=["/usr/include/freetype2", "../../src"]), + Extension("harfbuzz", ["lib/harfbuzz.pyx"], libraries=["harfbuzz"], library_dirs=["../../%s/src/.libs" % opts.build], include_dirs=["/usr/include/freetype2", "../../src", "../../%s/src" % opts.build]), Extension("fontconfig", ["lib/fontconfig.pyx"], libraries=["fontconfig"]) ], cmdclass = {'build_ext' : build_ext}, scripts = glob('scripts/*'), license = 'LGPL', platforms = ['Linux', 'Win32', 'Mac OS X'], - package_dir = {'harfbuzz' : 'lib'} + package_dir = {'harfbuzz' : 'lib'}, + script_args = args )