Dear Behdad,

Khaled says he needs this for xetex. I enclose a patch to add getter functions 
to hb-graphite2 for gr_font and gr_face. No idea if the work though ;)

Yours,
Martin

diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index 6c890d4..06eca24 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -113,7 +113,7 @@ _hb_graphite2_shaper_face_data_create (hb_face_t *face)
     hb_blob_destroy (silf_blob);
 
   data->face = face;
-  data->grface = gr_make_face (data, &hb_graphite2_get_table, gr_face_default);
+  data->grface = gr_make_face (data, &hb_graphite2_get_table, gr_face_preloadAll);
 
   if (unlikely (!data->grface)) {
     free (data);
@@ -193,6 +193,21 @@ _hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shaper_shape_plan_dat
  * shaper
  */
 
+gr_font *
+hb_graphite2_font_get_font (hb_font_t *font)
+{
+  if (unlikely (!hb_graphite2_shaper_font_data_ensure(font))) return 0;
+  return HB_SHAPER_DATA_GET (font);
+}
+
+gr_face *
+hb_graphite2_font_get_face (hb_font_t *font)
+{
+  if (unlikely (!hb_graphite2_shaper_face_data_ensure(font->face))) return 0;
+  hb_face_t *face = font->face;
+  return HB_SHAPER_DATA_GET (face)->grface;
+}
+
 struct hb_graphite2_cluster_t {
   unsigned int base_char;
   unsigned int num_chars;
@@ -311,10 +326,18 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
   }
   ci++;
 
-  buffer->clear_output ();
+  //buffer->clear_output ();
   for (unsigned int i = 0; i < ci; ++i)
-    buffer->replace_glyphs (clusters[i].num_chars, clusters[i].num_glyphs, gids + clusters[i].base_glyph);
-  buffer->swap_buffers ();
+  {
+    for (unsigned int j = 0; j < clusters[i].num_glyphs; ++j)
+    {
+      hb_glyph_info_t *info = &buffer->info[clusters[i].base_glyph + j];
+      info->codepoint = gids[clusters[i].base_glyph + j];
+      info->cluster = gr_cinfo_base(gr_seg_cinfo(seg, clusters[i].base_char));
+    }
+  }
+  buffer->len = glyph_count;
+  //buffer->swap_buffers ();
 
   if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
     curradvx = gr_seg_advance_X(seg);
diff --git a/src/hb-graphite2.h b/src/hb-graphite2.h
index 8122495..c244f09 100644
--- a/src/hb-graphite2.h
+++ b/src/hb-graphite2.h
@@ -34,6 +34,11 @@ HB_BEGIN_DECLS
 #define HB_GRAPHITE2_TAG_SILF HB_TAG('S','i','l','f')
 
 /* TODO add gr_font/face etc getters and other glue API */
+gr_font *
+hb_graphite2_font_get_font (hb_font_t *font);
+
+gr_face *
+hb_graphite2_font_get_face (hb_font_t *font);
 
 HB_END_DECLS
 
_______________________________________________
HarfBuzz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to