src/hb-blob.cc | 4 ++-- src/hb-glib.cc | 11 +++++++++++ src/hb-glib.h | 3 +++ src/hb-shape.cc | 2 +- src/hb-unicode.cc | 2 +- src/sample.py | 15 ++++++++++++++- 6 files changed, 32 insertions(+), 5 deletions(-)
New commits: commit 0ef179e2dc040c13497af847b8c1cec846dbdbf9 Author: Behdad Esfahbod <[email protected]> Date: Tue Jan 6 16:58:33 2015 -0800 [glib] Add hb_glib_blob_create() that takes GBytes diff --git a/src/hb-glib.cc b/src/hb-glib.cc index af43cab..61dff5e 100644 --- a/src/hb-glib.cc +++ b/src/hb-glib.cc @@ -382,3 +382,14 @@ hb_glib_get_unicode_funcs (void) return const_cast<hb_unicode_funcs_t *> (&_hb_glib_unicode_funcs); } +hb_blob_t * +hb_glib_blob_create (GBytes *gbytes) +{ + gsize size = 0; + gconstpointer data = g_bytes_get_data (gbytes, &size); + return hb_blob_create ((const char *) data, + size, + HB_MEMORY_MODE_READONLY, + g_bytes_ref (gbytes), + (hb_destroy_func_t) g_bytes_unref); +} diff --git a/src/hb-glib.h b/src/hb-glib.h index 63a9d33..1a8f42e 100644 --- a/src/hb-glib.h +++ b/src/hb-glib.h @@ -46,6 +46,9 @@ hb_glib_script_from_script (hb_script_t script); hb_unicode_funcs_t * hb_glib_get_unicode_funcs (void); +hb_blob_t * +hb_glib_blob_create (GBytes *gbytes); + HB_END_DECLS commit b91904a40da6287f84bc79de60674fa57232ec09 Author: Behdad Esfahbod <[email protected]> Date: Tue Jan 6 15:43:14 2015 -0800 [bindings] Replace deprecated allow-none with optional and nullable diff --git a/src/hb-blob.cc b/src/hb-blob.cc index d8b295e..51ea20d 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -82,8 +82,8 @@ _hb_blob_destroy_user_data (hb_blob_t *blob) * @data: (array length=length) (element-type uint8_t) (closure user_data) (destroy destroy) (scope notified) (transfer none): Pointer to blob data. * @length: Length of @data in bytes. * @mode: Memory mode for @data. - * @user_data: (allow-none): Data parameter to pass to @destroy. - * @destroy: (allow-none): Callback to call when @data is not needed anymore. + * @user_data: (nullable): Data parameter to pass to @destroy. + * @destroy: (nullable): Callback to call when @data is not needed anymore. * * Creates a new "blob" object wrapping @data. The @mode parameter is used * to negotiate ownership and lifecycle of @data. diff --git a/src/hb-shape.cc b/src/hb-shape.cc index 100fb3c..9a59c08 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc @@ -200,7 +200,7 @@ parse_one_feature (const char **pp, const char *end, hb_feature_t *feature) * hb_feature_from_string: * @str: (array length=len): * @len: - * @feature: (out) (allow-none): + * @feature: (out) (optional): * * * diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc index d59dfb2..fc19006 100644 --- a/src/hb-unicode.cc +++ b/src/hb-unicode.cc @@ -157,7 +157,7 @@ hb_unicode_funcs_get_default (void) /** * hb_unicode_funcs_create: (Xconstructor) - * @parent: (allow-none): + * @parent: (nullable): * * * commit 81a31f3eff44a85bb2160d51156a01a18f0a97df Author: Behdad Esfahbod <[email protected]> Date: Tue Jan 6 15:37:31 2015 -0800 [bindings] Make sample Python 2/3 compatible diff --git a/src/sample.py b/src/sample.py index e2daba8..5a76f91 100755 --- a/src/sample.py +++ b/src/sample.py @@ -5,6 +5,19 @@ from __future__ import print_function import sys from gi.repository import HarfBuzz as hb +# Python 2/3 compatibility +try: + unicode +except NameError: + unicode = str + +def tounicode(s, encoding='utf-8'): + if not isinstance(s, unicode): + return s.decode(encoding) + else: + return s + + def nothing(data): print(data) @@ -12,7 +25,7 @@ fontdata = open (sys.argv[1], 'rb').read () blob = hb.blob_create (fontdata, hb.memory_mode_t.DUPLICATE, 1234, None) buf = hb.buffer_create () -hb.buffer_add_utf8 (buf, "Hello Ø¨ÙØ¯Ø§Ø¯", 0, -1) +hb.buffer_add_utf8 (buf, tounicode("Hello Ø¨ÙØ¯Ø§Ø¯").encode('utf-8'), 0, -1) hb.buffer_guess_segment_properties (buf) face = hb.face_create (blob, 0)
_______________________________________________ HarfBuzz mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/harfbuzz
