[HarfBuzz] harfbuzz-ng: Branch 'master' - 2 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Oct 26 22:27:32 PDT 2010


 configure.ac          |    2 -
 src/hb-font-private.h |    3 +
 src/hb-font.cc        |   96 ++++++++++++++++++++++++++++++++++----------------
 src/hb-font.h         |   61 +++++++++++++++++++------------
 src/hb-ft.c           |   72 ++++++++++++++++++++++---------------
 src/hb-ot-shape.cc    |    9 +---
 6 files changed, 154 insertions(+), 89 deletions(-)

New commits:
commit 248e3c2ba47889c247959e44166644872aed59ba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 27 01:23:14 2010 -0400

    Oops, remove extra mask setting that broke complex shaping

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 91ed400..5770cbf 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -88,8 +88,6 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
 
   hb_ot_shape_complex_setup_masks (c);
 
-  c->buffer->reset_masks (global_mask);
-
   for (unsigned int i = 0; i < c->num_user_features; i++)
   {
     const hb_feature_t *feature = &c->user_features[i];
commit 502f4cba3e0bcd625d31f8fd295b8b18e2d02a5a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Oct 27 01:13:56 2010 -0400

    Divide get_metrics into get_advance and get_extents
    
    Graphite module not updated.
    Bump version to 0.3.

diff --git a/configure.ac b/configure.ac
index e74dd67..bda299a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT(harfbuzz, 0.2, [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz])
+AC_INIT(harfbuzz, 0.3, [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz])
 AC_CONFIG_SRCDIR([harfbuzz.pc.in])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([1.9.6 gnu dist-bzip2 no-dist-gzip -Wall no-define])
diff --git a/src/hb-font-private.h b/src/hb-font-private.h
index f91da83..b147bce 100644
--- a/src/hb-font-private.h
+++ b/src/hb-font-private.h
@@ -45,8 +45,9 @@ struct _hb_font_funcs_t {
 
   struct {
     hb_font_get_glyph_func_t		get_glyph;
+    hb_font_get_glyph_advance_func_t	get_glyph_advance;
+    hb_font_get_glyph_extents_func_t	get_glyph_extents;
     hb_font_get_contour_point_func_t	get_contour_point;
-    hb_font_get_glyph_metrics_func_t	get_glyph_metrics;
     hb_font_get_kerning_func_t		get_kerning;
   } v;
 };
diff --git a/src/hb-font.cc b/src/hb-font.cc
index bd55681..63631a9 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -49,24 +49,33 @@ hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED,
 		       hb_codepoint_t variation_selector HB_UNUSED)
 { return 0; }
 
-static hb_bool_t
-hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
+static void
+hb_font_get_glyph_advance_nil (hb_font_t *font HB_UNUSED,
 			       hb_face_t *face HB_UNUSED,
 			       const void *user_data HB_UNUSED,
-			       unsigned int point_index HB_UNUSED,
 			       hb_codepoint_t glyph HB_UNUSED,
-			       hb_position_t *x HB_UNUSED,
-			       hb_position_t *y HB_UNUSED)
-{ return false; }
+			       hb_position_t *x_advance HB_UNUSED,
+			       hb_position_t *y_advance HB_UNUSED)
+{ }
 
 static void
-hb_font_get_glyph_metrics_nil (hb_font_t *font HB_UNUSED,
+hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED,
 			       hb_face_t *face HB_UNUSED,
 			       const void *user_data HB_UNUSED,
 			       hb_codepoint_t glyph HB_UNUSED,
-			       hb_glyph_metrics_t *metrics HB_UNUSED)
+			       hb_glyph_extents_t *extents HB_UNUSED)
 { }
 
+static hb_bool_t
+hb_font_get_contour_point_nil (hb_font_t *font HB_UNUSED,
+			       hb_face_t *face HB_UNUSED,
+			       const void *user_data HB_UNUSED,
+			       unsigned int point_index HB_UNUSED,
+			       hb_codepoint_t glyph HB_UNUSED,
+			       hb_position_t *x HB_UNUSED,
+			       hb_position_t *y HB_UNUSED)
+{ return false; }
+
 static hb_position_t
 hb_font_get_kerning_nil (hb_font_t *font HB_UNUSED,
 			 hb_face_t *face HB_UNUSED,
@@ -80,8 +89,9 @@ hb_font_funcs_t _hb_font_funcs_nil = {
   TRUE,  /* immutable */
   {
     hb_font_get_glyph_nil,
+    hb_font_get_glyph_advance_nil,
+    hb_font_get_glyph_extents_nil,
     hb_font_get_contour_point_nil,
-    hb_font_get_glyph_metrics_nil,
     hb_font_get_kerning_nil
   }
 };
@@ -159,23 +169,33 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
 }
 
 void
-hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
-				      hb_font_get_contour_point_func_t contour_point_func)
+hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
+				      hb_font_get_glyph_advance_func_t glyph_advance_func)
 {
   if (ffuncs->immutable)
     return;
 
-  ffuncs->v.get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil;
+  ffuncs->v.get_glyph_advance = glyph_advance_func ? glyph_advance_func : hb_font_get_glyph_advance_nil;
+}
+
+void
+hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
+				      hb_font_get_glyph_extents_func_t glyph_extents_func)
+{
+  if (ffuncs->immutable)
+    return;
+
+  ffuncs->v.get_glyph_extents = glyph_extents_func ? glyph_extents_func : hb_font_get_glyph_extents_nil;
 }
 
 void
-hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
-				      hb_font_get_glyph_metrics_func_t glyph_metrics_func)
+hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
+				      hb_font_get_contour_point_func_t contour_point_func)
 {
   if (ffuncs->immutable)
     return;
 
-  ffuncs->v.get_glyph_metrics = glyph_metrics_func ? glyph_metrics_func : hb_font_get_glyph_metrics_nil;
+  ffuncs->v.get_contour_point = contour_point_func ? contour_point_func : hb_font_get_contour_point_nil;
 }
 
 void
@@ -195,16 +215,22 @@ hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs)
   return ffuncs->v.get_glyph;
 }
 
-hb_font_get_contour_point_func_t
-hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs)
+hb_font_get_glyph_advance_func_t
+hb_font_funcs_get_glyph_advance_func (hb_font_funcs_t *ffuncs)
 {
-  return ffuncs->v.get_contour_point;
+  return ffuncs->v.get_glyph_advance;
+}
+
+hb_font_get_glyph_extents_func_t
+hb_font_funcs_get_glyph_extents_func (hb_font_funcs_t *ffuncs)
+{
+  return ffuncs->v.get_glyph_extents;
 }
 
-hb_font_get_glyph_metrics_func_t
-hb_font_funcs_get_glyph_metrics_func (hb_font_funcs_t *ffuncs)
+hb_font_get_contour_point_func_t
+hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs)
 {
-  return ffuncs->v.get_glyph_metrics;
+  return ffuncs->v.get_contour_point;
 }
 
 hb_font_get_kerning_func_t
@@ -223,6 +249,25 @@ hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
 				   unicode, variation_selector);
 }
 
+void
+hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face,
+			   hb_codepoint_t glyph,
+			   hb_position_t *x_advance, hb_position_t *y_advance)
+{
+  *x_advance = *y_advance = 0;
+  return font->klass->v.get_glyph_advance (font, face, font->user_data,
+					   glyph, x_advance, y_advance);
+}
+
+void
+hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face,
+			   hb_codepoint_t glyph, hb_glyph_extents_t *extents)
+{
+  memset (extents, 0, sizeof (*extents));
+  return font->klass->v.get_glyph_extents (font, face, font->user_data,
+					   glyph, extents);
+}
+
 hb_bool_t
 hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
 			   unsigned int point_index,
@@ -234,15 +279,6 @@ hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
 					   glyph, x, y);
 }
 
-void
-hb_font_get_glyph_metrics (hb_font_t *font, hb_face_t *face,
-			   hb_codepoint_t glyph, hb_glyph_metrics_t *metrics)
-{
-  memset (metrics, 0, sizeof (*metrics));
-  return font->klass->v.get_glyph_metrics (font, face, font->user_data,
-					   glyph, metrics);
-}
-
 hb_position_t
 hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
 		     hb_codepoint_t first_glyph, hb_codepoint_t second_glyph)
diff --git a/src/hb-font.h b/src/hb-font.h
index 934f17c..7b3f1ed 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -111,23 +111,25 @@ hb_font_funcs_is_immutable (hb_font_funcs_t *ffuncs);
 
 /* funcs */
 
-typedef struct _hb_glyph_metrics_t
+typedef struct _hb_glyph_extents_t
 {
-    hb_position_t x_advance;
-    hb_position_t y_advance;
-    hb_position_t x_offset;
-    hb_position_t y_offset;
+    hb_position_t x_bearing;
+    hb_position_t y_bearing;
     hb_position_t width;
     hb_position_t height;
-} hb_glyph_metrics_t;
+} hb_glyph_extents_t;
 
 typedef hb_codepoint_t (*hb_font_get_glyph_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
 						    hb_codepoint_t unicode, hb_codepoint_t variation_selector);
+typedef void (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
+						  hb_codepoint_t glyph,
+						  hb_position_t *x_advance, hb_position_t *y_advance);
+typedef void (*hb_font_get_glyph_extents_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
+						  hb_codepoint_t glyph,
+						  hb_glyph_extents_t *metrics);
 typedef hb_bool_t (*hb_font_get_contour_point_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
-						       unsigned int point_index,
-						       hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y);
-typedef void (*hb_font_get_glyph_metrics_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
-						  hb_codepoint_t glyph, hb_glyph_metrics_t *metrics);
+						       unsigned int point_index, hb_codepoint_t glyph,
+						       hb_position_t *x, hb_position_t *y);
 typedef hb_position_t (*hb_font_get_kerning_func_t) (hb_font_t *font, hb_face_t *face, const void *user_data,
 						     hb_codepoint_t first_glyph, hb_codepoint_t second_glyph);
 
@@ -137,12 +139,16 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
 			      hb_font_get_glyph_func_t glyph_func);
 
 void
-hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
-				      hb_font_get_contour_point_func_t contour_point_func);
+hb_font_funcs_set_glyph_advance_func (hb_font_funcs_t *ffuncs,
+				      hb_font_get_glyph_advance_func_t glyph_advance_func);
+
+void
+hb_font_funcs_set_glyph_extents_func (hb_font_funcs_t *ffuncs,
+				      hb_font_get_glyph_extents_func_t glyph_extents_func);
 
 void
-hb_font_funcs_set_glyph_metrics_func (hb_font_funcs_t *ffuncs,
-				      hb_font_get_glyph_metrics_func_t glyph_metrics_func);
+hb_font_funcs_set_contour_point_func (hb_font_funcs_t *ffuncs,
+				      hb_font_get_contour_point_func_t contour_point_func);
 
 void
 hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
@@ -154,12 +160,15 @@ hb_font_funcs_set_kerning_func (hb_font_funcs_t *ffuncs,
 hb_font_get_glyph_func_t
 hb_font_funcs_get_glyph_func (hb_font_funcs_t *ffuncs);
 
+hb_font_get_glyph_advance_func_t
+hb_font_funcs_get_glyph_advance_func (hb_font_funcs_t *ffuncs);
+
+hb_font_get_glyph_extents_func_t
+hb_font_funcs_get_glyph_extents_func (hb_font_funcs_t *ffuncs);
+
 hb_font_get_contour_point_func_t
 hb_font_funcs_get_contour_point_func (hb_font_funcs_t *ffuncs);
 
-hb_font_get_glyph_metrics_func_t
-hb_font_funcs_get_glyph_metrics_func (hb_font_funcs_t *ffuncs);
-
 hb_font_get_kerning_func_t
 hb_font_funcs_get_kerning_func (hb_font_funcs_t *ffuncs);
 
@@ -168,14 +177,20 @@ hb_codepoint_t
 hb_font_get_glyph (hb_font_t *font, hb_face_t *face,
 		   hb_codepoint_t unicode, hb_codepoint_t variation_selector);
 
-hb_bool_t
-hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
-			   unsigned int point_index,
-			   hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y);
+void
+hb_font_get_glyph_advance (hb_font_t *font, hb_face_t *face,
+			   hb_codepoint_t glyph,
+			   hb_position_t *x_advance, hb_position_t *y_advance);
 
 void
-hb_font_get_glyph_metrics (hb_font_t *font, hb_face_t *face,
-			   hb_codepoint_t glyph, hb_glyph_metrics_t *metrics);
+hb_font_get_glyph_extents (hb_font_t *font, hb_face_t *face,
+			   hb_codepoint_t glyph,
+			   hb_glyph_extents_t *metrics);
+
+hb_bool_t
+hb_font_get_contour_point (hb_font_t *font, hb_face_t *face,
+			   unsigned int point_index, hb_codepoint_t glyph,
+			   hb_position_t *x, hb_position_t *y);
 
 hb_position_t
 hb_font_get_kerning (hb_font_t *font, hb_face_t *face,
diff --git a/src/hb-ft.c b/src/hb-ft.c
index 8619456..1c27668 100644
--- a/src/hb-ft.c
+++ b/src/hb-ft.c
@@ -56,6 +56,48 @@ hb_ft_get_glyph (hb_font_t *font HB_UNUSED,
   return FT_Get_Char_Index (ft_face, unicode);
 }
 
+static void
+hb_ft_get_glyph_advance (hb_font_t *font HB_UNUSED,
+			 hb_face_t *face HB_UNUSED,
+			 const void *user_data,
+			 hb_codepoint_t glyph,
+			 hb_position_t *x_advance,
+			 hb_position_t *y_advance)
+{
+  FT_Face ft_face = (FT_Face) user_data;
+  int load_flags = FT_LOAD_DEFAULT;
+
+  /* TODO: load_flags, embolden, etc */
+
+  if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
+  {
+    *x_advance = ft_face->glyph->advance.x;
+    *y_advance = ft_face->glyph->advance.y;
+  }
+}
+
+static void
+hb_ft_get_glyph_extents (hb_font_t *font HB_UNUSED,
+			 hb_face_t *face HB_UNUSED,
+			 const void *user_data,
+			 hb_codepoint_t glyph,
+			 hb_glyph_extents_t *extents)
+{
+  FT_Face ft_face = (FT_Face) user_data;
+  int load_flags = FT_LOAD_DEFAULT;
+
+  /* TODO: load_flags, embolden, etc */
+
+  if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
+  {
+    /* XXX: A few negations should be in order here, not sure. */
+    extents->x_bearing = ft_face->glyph->metrics.horiBearingX;
+    extents->y_bearing = ft_face->glyph->metrics.horiBearingY;
+    extents->width = ft_face->glyph->metrics.width;
+    extents->height = ft_face->glyph->metrics.height;
+  }
+}
+
 static hb_bool_t
 hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
 			 hb_face_t *face HB_UNUSED,
@@ -85,33 +127,6 @@ hb_ft_get_contour_point (hb_font_t *font HB_UNUSED,
   return TRUE;
 }
 
-static void
-hb_ft_get_glyph_metrics (hb_font_t *font HB_UNUSED,
-			 hb_face_t *face HB_UNUSED,
-			 const void *user_data,
-			 hb_codepoint_t glyph,
-			 hb_glyph_metrics_t *metrics)
-{
-  FT_Face ft_face = (FT_Face) user_data;
-  int load_flags = FT_LOAD_DEFAULT;
-
-  /* TODO: load_flags, embolden, etc */
-
-  metrics->x_advance = metrics->y_advance = 0;
-  metrics->x_offset = metrics->y_offset = 0;
-  metrics->width = metrics->height = 0;
-  if (likely (!FT_Load_Glyph (ft_face, glyph, load_flags)))
-  {
-    /* TODO: A few negations should be in order here, not sure. */
-    metrics->x_advance = ft_face->glyph->advance.x;
-    metrics->y_advance = ft_face->glyph->advance.y;
-    metrics->x_offset = ft_face->glyph->metrics.horiBearingX;
-    metrics->y_offset = ft_face->glyph->metrics.horiBearingY;
-    metrics->width = ft_face->glyph->metrics.width;
-    metrics->height = ft_face->glyph->metrics.height;
-  }
-}
-
 static hb_position_t
 hb_ft_get_kerning (hb_font_t *font HB_UNUSED,
 		   hb_face_t *face HB_UNUSED,
@@ -134,8 +149,9 @@ static hb_font_funcs_t ft_ffuncs = {
   TRUE, /* immutable */
   {
     hb_ft_get_glyph,
+    hb_ft_get_glyph_advance,
+    hb_ft_get_glyph_extents,
     hb_ft_get_contour_point,
-    hb_ft_get_glyph_metrics,
     hb_ft_get_kerning
   }
 };
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 7b4a451..91ed400 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -233,10 +233,9 @@ hb_position_default (hb_ot_shape_context_t *c)
 
   unsigned int count = c->buffer->len;
   for (unsigned int i = 0; i < count; i++) {
-    hb_glyph_metrics_t metrics;
-    hb_font_get_glyph_metrics (c->font, c->face, c->buffer->info[i].codepoint, &metrics);
-    c->buffer->pos[i].x_advance = metrics.x_advance;
-    c->buffer->pos[i].y_advance = metrics.y_advance;
+    hb_font_get_glyph_advance (c->font, c->face, c->buffer->info[i].codepoint,
+			       &c->buffer->pos[i].x_advance,
+			       &c->buffer->pos[i].y_advance);
   }
 }
 



More information about the HarfBuzz mailing list