[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue Jan 6 14:05:45 PST 2015
src/hb-blob.cc | 6 +++---
src/hb-buffer.cc | 2 +-
src/sample.py | 34 ++++++++++++++++++++++++++++------
3 files changed, 32 insertions(+), 10 deletions(-)
New commits:
commit b632e7997d9cb6e4782cab6d8c62e8e5edaa4cb0
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Jan 6 14:05:26 2015 -0800
Fix up gobject-introspection a bit
Minimal shaping works now!
diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 4437930..d8b295e 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -79,11 +79,11 @@ _hb_blob_destroy_user_data (hb_blob_t *blob)
/**
* hb_blob_create: (Xconstructor)
- * @data: (array length=length) (closure user_data) (destroy destroy) (scope notified) (transfer none): Pointer to blob data.
+ * @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: Data parameter to pass to @destroy.
- * @destroy: Callback to call when @data is not needed anymore.
+ * @user_data: (allow-none): Data parameter to pass to @destroy.
+ * @destroy: (allow-none): 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-buffer.cc b/src/hb-buffer.cc
index 74ae273..7bf232d 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -1400,7 +1400,7 @@ hb_buffer_add_utf (hb_buffer_t *buffer,
/**
* hb_buffer_add_utf8:
* @buffer: a buffer.
- * @text: (array length=text_length):
+ * @text: (array length=text_length) (element-type uint8_t):
* @text_length:
* @item_offset:
* @item_length:
diff --git a/src/sample.py b/src/sample.py
index 317a47e..e2daba8 100755
--- a/src/sample.py
+++ b/src/sample.py
@@ -1,13 +1,35 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
+from __future__ import print_function
import sys
from gi.repository import HarfBuzz as hb
-def nothing():
- pass
+def nothing(data):
+ print(data)
-fontdata = file (sys.argv[1]).read ()
-blob = hb.blob_create (fontdata, hb.memory_mode_t.WRITABLE, None, nothing)
-print blob
-buffer = hb.buffer_create ()
+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_guess_segment_properties (buf)
+
+face = hb.face_create (blob, 0)
+font = hb.font_create (face)
+upem = hb.face_get_upem (face)
+hb.font_set_scale (font, upem, upem)
+#hb.ft_font_set_funcs (font)
+hb.ot_font_set_funcs (font)
+
+hb.shape (font, buf, [])
+
+infos = hb.buffer_get_glyph_infos (buf)
+positions = hb.buffer_get_glyph_positions (buf)
+
+for info,pos in zip(infos, positions):
+ gid = info.codepoint
+ cluster = info.cluster
+ advance = pos.x_advance
+
+ print(gid, cluster, advance)
More information about the HarfBuzz
mailing list