[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Sep 12 17:57:02 PDT 2013


 contrib/README                    |    2 
 contrib/python/README             |   10 -
 contrib/python/lib/fontconfig.pyx |   47 --------
 contrib/python/lib/harfbuzz.pyx   |  213 --------------------------------------
 contrib/python/scripts/hbtestfont |  116 --------------------
 contrib/python/setup.py           |   39 ------
 6 files changed, 427 deletions(-)

New commits:
commit 4878db218202ed804c9f76edb7e4aa220de8a8d8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Sep 12 20:56:32 2013 -0400

    Remove contrib/ Python hand-coded binding stuff
    
    gobject-introspection coming together.

diff --git a/contrib/README b/contrib/README
deleted file mode 100644
index 0ef4bca..0000000
--- a/contrib/README
+++ /dev/null
@@ -1,2 +0,0 @@
-Contents of this directory and outdated and unmaintained.
-Will be replaced with something functional one day.
diff --git a/contrib/python/README b/contrib/python/README
deleted file mode 100644
index 72a3527..0000000
--- a/contrib/python/README
+++ /dev/null
@@ -1,10 +0,0 @@
-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
-
diff --git a/contrib/python/lib/fontconfig.pyx b/contrib/python/lib/fontconfig.pyx
deleted file mode 100644
index 16e0289..0000000
--- a/contrib/python/lib/fontconfig.pyx
+++ /dev/null
@@ -1,47 +0,0 @@
-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)
diff --git a/contrib/python/lib/harfbuzz.pyx b/contrib/python/lib/harfbuzz.pyx
deleted file mode 100644
index 3e3774e..0000000
--- a/contrib/python/lib/harfbuzz.pyx
+++ /dev/null
@@ -1,213 +0,0 @@
-cdef extern from "stdlib.h":
-    ctypedef int size_t
-    void *malloc(size_t size)
-    void free(void* ptr)
-
-cdef extern from "ft2build.h" :
-    pass
-
-cdef extern from "freetype/freetype.h" :
-    ctypedef void *FT_Library
-    ctypedef void *FT_Face
-    ctypedef int FT_Error
-
-    FT_Error FT_Init_FreeType (FT_Library *alib)
-    FT_Error FT_Done_FreeType (FT_Library alib)
-    FT_Error FT_Done_Face (FT_Face alib)
-    FT_Error FT_New_Face( FT_Library library, char *path, unsigned long index, FT_Face *aface)
-    FT_Error FT_Set_Char_Size (FT_Face aFace, unsigned int size_x, unsigned int size_y, unsigned int res_x, unsigned int res_y)
-
-cdef extern from "hb-common.h" :
-    cdef enum hb_direction_t :
-        HB_DIRECTION_LTR
-        HB_DIRECTION_RTL
-        HB_DIRECTION_TTB
-        HB_DIRECTION_BTT
-    ctypedef unsigned long hb_codepoint_t
-    ctypedef long hb_position_t
-    ctypedef unsigned long hb_mask_t
-    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-ot-tag.h" :
-    hb_script_t hb_ot_tag_to_script (hb_tag_t tag)
-
-cdef extern from "hb-buffer.h" :
-    ctypedef struct hb_buffer_t :
-        pass
-
-    ctypedef struct hb_glyph_info_t :
-        hb_codepoint_t codepoint
-        hb_mask_t mask
-        unsigned long cluster
-
-    ctypedef union hb_var_int_t:
-        unsigned long u32
-
-    ctypedef struct hb_glyph_position_t :
-        hb_position_t x_advance
-        hb_position_t y_advance
-        hb_position_t x_offset
-        hb_position_t y_offset
-        hb_var_int_t  var
-
-    hb_buffer_t *hb_buffer_create(unsigned int size)
-    hb_buffer_t *hb_buffer_reference(hb_buffer_t *buffer)
-    unsigned int hb_buffer_get_reference_count(hb_buffer_t *buffer)
-    void hb_buffer_destroy(hb_buffer_t *buffer)
-    void hb_buffer_set_direction(hb_buffer_t *buffer, hb_direction_t direction)
-    hb_direction_t hb_buffer_get_direction(hb_buffer_t *buffer)
-    void hb_buffer_set_script(hb_buffer_t *buffer, hb_script_t script)
-    hb_script_t hb_buffer_get_script(hb_buffer_t *buffer)
-    void hb_buffer_set_language(hb_buffer_t *buffer, hb_language_t language)
-    hb_language_t hb_buffer_get_language(hb_buffer_t *buffer)
-    void hb_buffer_clear(hb_buffer_t *)
-    void hb_buffer_clear_positions(hb_buffer_t *buffer)
-    void hb_buffer_ensure(hb_buffer_t *buffer, unsigned int size)
-    void hb_buffer_reverse(hb_buffer_t *buffer)
-    void hb_buffer_reverse_clusters(hb_buffer_t *buffer)
-    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, 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 :
-        pass
-# do I need blob functions here?
-
-cdef extern from "hb-font.h" :
-    ctypedef struct hb_face_t :
-        pass
-    ctypedef struct hb_font_t :
-        pass
-
-    ctypedef hb_blob_t * (*hb_get_table_func_t) (hb_tag_t tag, void *user_data)
-    hb_face_t * hb_face_create_for_data(hb_blob_t *blob, unsigned int index)
-    hb_face_t * hb_face_create_for_tables(hb_get_table_func_t get_table, hb_destroy_func_t destroy, void *user_data)
-    hb_face_t * hb_face_reference(hb_face_t *face)
-    unsigned int hb_face_get_reference_count(hb_face_t *face)
-    void hb_face_destroy(hb_face_t *face)
-    void hb_font_destroy(hb_font_t *font)
-    hb_blob_t * hb_face_get_table(hb_face_t *face, hb_tag_t tag)
-
-
-cdef extern from "hb-shape.h" :
-    ctypedef struct hb_feature_t :
-        int tag
-        unsigned int value
-        unsigned int start
-        unsigned int end
-
-    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)
-    hb_font_t *hb_ft_font_create (FT_Face ft_face, hb_destroy_func_t destroy)
-
-class glyphinfo :
- 
-    def __init__(self, gid, cluster, advance, offset, internal = 0) :
-        self.gid = gid
-        self.cluster = cluster
-        self.advance = advance
-        self.offset = offset
-        self.internal = internal
-
-    def __repr__(self) :
-        res = "{0:d}>{1:d}@({2:.2f},{3:.2f})+({4:.2f},{5:.2f})".format(self.gid, self.cluster, self.offset[0], self.offset[1], self.advance[0], self.advance[1])
-        if self.internal : res += "/i=" + str(self.internal)
-        return res
-
-cdef class buffer :
-    cdef hb_buffer_t *buffer
-
-    def __init__(self, char *text, unsigned int length) :
-        """Note text must be a utf-8 string and length is number of chars"""
-        self.buffer = hb_buffer_create(length)
-        hb_buffer_add_utf8(self.buffer, text, length, 0, len(text))
-
-    def set_scriptlang(self, char *script, char *lang) :
-        cdef hb_language_t language
-        cdef hb_script_t scriptnum
-
-        language = hb_language_from_string(lang)
-        scriptnum = hb_ot_tag_to_script(hb_tag_from_string(script))
-        hb_buffer_set_script(self.buffer, scriptnum)
-        hb_buffer_set_language(self.buffer, language)
-
-    def get_info(self, scale = 1) :
-        cdef hb_glyph_info_t *infos
-        cdef hb_glyph_position_t *positions
-        cdef unsigned int num
-        cdef unsigned int i
-        res = []
-
-        num = hb_buffer_get_length(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)
-        return res
-
-    def get_settings(self) :
-        cdef hb_script_t script
-        cdef hb_language_t lang
-
-        script = hb_buffer_get_script(self.buffer)
-        lang = hb_buffer_get_language(self.buffer)
-        return {'script' : script, 'language' : hb_language_to_string(lang)}
-
-    def __del__(self) :
-        hb_buffer_destroy(self.buffer)
-
-cdef class ft :
-    cdef FT_Library engine
-    cdef FT_Face face
-    cdef hb_face_t *hbface
-    cdef hb_font_t *hbfont
-
-    def __init__(self, char *fname, size) :
-        cdef FT_Library engine
-        FT_Init_FreeType(&engine)
-        self.engine = engine
-        cdef FT_Face face
-        FT_New_Face(engine, fname, 0, &face)
-        FT_Set_Char_Size(face, size << 6, size << 6, 72, 72)
-        self.face = face
-        self.hbface = hb_ft_face_create(face, <void (*)(void *)>hb_face_destroy)
-        self.hbfont = hb_ft_font_create(face, <void (*)(void *)>hb_font_destroy)
-
-    def __del__(self) :
-        cdef FT_Library engine
-        engine = self.engine
-        cdef FT_Face face
-        face = self.face
-        FT_Done_Face(face)
-        FT_Done_FreeType(engine)
-
-    def shape(self, buffer aBuffer, features = {}) :
-        cdef hb_feature_t *feats
-        cdef hb_feature_t *aFeat
-        feats = <hb_feature_t *>malloc(sizeof(hb_feature_t) * len(features))
-        aFeat = feats
-        for k,v in features.items() :
-            aFeat.tag = hb_tag_from_string (k)
-            aFeat.value = int(v)
-            aFeat.start = 0
-            aFeat.end = -1
-            aFeat += 1
-        hb_shape(self.hbfont, aBuffer.buffer, feats, len(features))
-
-
diff --git a/contrib/python/scripts/hbtestfont b/contrib/python/scripts/hbtestfont
deleted file mode 100755
index 4437105..0000000
--- a/contrib/python/scripts/hbtestfont
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/python
-
-import harfbuzz, optparse, sys
-from fontconfig import fcPattern
-
-usage = '''usage: %prog [options] codepoints
-    Generates output of glyphs and positions. Each entry is of the form:
-        glyphid>cluster@(offsetx,offsety)+(advancex,advancey)
-
-    codepoints is a space separated list of hex values of Unicode codepoints'''
-p = optparse.OptionParser(usage=usage)
-p.add_option('-s', '--size', default=32, type="int", help="point size")
-p.add_option('-l', '--lang', help="language code")
-p.add_option('-c', '--script', help="script code")
-p.add_option('-F', '--feature', action='append', help="define a feature key=val")
-p.add_option('-f', '--font', help='Font to use to render glyphs. My be a font file', default="verdana")
-p.add_option('-b', '--bold', help='Choose bold fonts', action='store_true')
-p.add_option('-i', '--italic', help='Choose italic fonts', action='store_true')
-p.add_option('-d', '--debug', action='store_true', help="Output trace info")
-p.add_option('--nogui', action='store_true', help="Don't display a gui")
-(opts, args) = p.parse_args()
-
-if opts.font.lower().endswith(".ttf") :
-    fpat = ":file="
-else :
-    fpat = ""
-fpat += opts.font + ":weight="
-fpat += "bold" if opts.bold else "medium"
-fpat += ":slant="
-fpat += "italic" if opts.italic else "roman"
-pat = fcPattern(fpat)
-fname = pat.getString("file", 0)
-family = pat.getString("family", 0)
-print "Processing: " + fname
-if opts.font.lower().endswith(".ttf") and opts.font != fname :
-    print "Failed to find font in fontconfig. Exiting"
-    sys.exit(1)
-
-ft = harfbuzz.ft(fname, opts.size)
-text = "".join(unichr(int(c, 16)) for c in args)
-bytes = text.encode('utf_8')
-buffer = harfbuzz.buffer(bytes, len(text))
-if (opts.lang or opts.script) : buffer.set_scriptlang(opts.script if opts.script else "", opts.lang if opts.lang else "")
-features = {}
-if opts.feature :
-    for f in opts.feature :
-        k, v = f.split("=")
-        features[k] = v
-ft.shape(buffer, features = features)
-res = buffer.get_info(64)       # scale for 26.6
-print res
-
-if not opts.nogui :
-    try:
-        import gtk
-        import gobject
-        import cairo
-        from gtk import gdk
-    except :
-        raise SystemExit
-    import pygtk
-
-    if gtk.pygtk_version < (2, 8) :
-        print "PyGtk 2.8 or later required"
-        raise SystemExit
-
-    class GlyphsWindow (gtk.Widget) :
-        def __init__(self, fontname, bold, italic, size, glyphs) :
-            gtk.Widget.__init__(self)
-            self.fontname = fontname
-            self.size = size
-            self.glyphs = glyphs
-            self.bold = bold
-            self.italic = italic
-
-        def do_realize(self) :
-            self.set_flags(gtk.REALIZED)
-            self.window = gdk.Window(
-                    self.get_parent_window(),
-                    width = self.allocation.width,
-                    height = self.allocation.height,
-                    window_type = gdk.WINDOW_CHILD,
-                    wclass = gdk.INPUT_OUTPUT,
-                    event_mask = self.get_events() | gdk.EXPOSURE_MASK)
-            self.window.set_user_data(self)
-            self.style.attach(self.window)
-            self.style.set_background(self.window, gtk.STATE_NORMAL)
-            self.window.move_resize(*self.allocation)
-            
-        def do_unrealize(self) :
-            self.window.destroy()
-
-        def do_expose_event(self, event) :
-            cr = self.window.cairo_create()
-            cr.set_matrix(cairo.Matrix(1, 0, 0, 1, 0, 1.5 * self.size))
-            cr.set_font_face(cairo.ToyFontFace(self.fontname, cairo.FONT_SLANT_ITALIC if self.italic else cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD if self.bold else cairo.FONT_WEIGHT_NORMAL))
-            cr.set_font_size(self.size)
-            cr.show_glyphs(self.glyphs)      # [(gid, originx, originy)]
-
-    glyphs = []
-    org = [0, 0]
-    for g in res :
-        glyphs.append((g.gid, org[0] + g.offset[0], org[1] - g.offset[1]))
-        org[0] += g.advance[0]
-        org[1] -= g.advance[1]
-
-    gobject.type_register(GlyphsWindow)
-    win = gtk.Window()
-    win.resize(org[0] + 10, 2 * opts.size + 40)
-    win.connect('delete-event', gtk.main_quit)
-    frame = gtk.Frame("glyphs")
-    win.add(frame)
-    w = GlyphsWindow(family, opts.bold, opts.italic, opts.size, glyphs)
-    frame.add(w)
-    win.show_all()
-    gtk.main()
diff --git a/contrib/python/setup.py b/contrib/python/setup.py
deleted file mode 100755
index 681c53b..0000000
--- a/contrib/python/setup.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/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',
-    long_description='Harfbuzz python integration modules and supporting scripts',
-    maintainer='Martin Hosken',
-    maintainer_email='martin_hosken at sil.org',
-    packages=['harfbuzz'],
-    ext_modules = [
-        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'},
-    script_args = args
-)
-



More information about the HarfBuzz mailing list