[pango/harfbuzz-ng] [HB] Add get_attach_points()



commit 807581741d5331235004f2252de92a6de3ce23d0
Author: Behdad Esfahbod <behdad behdad org>
Date:   Tue May 26 12:24:16 2009 -0400

    [HB] Add get_attach_points()
---
 pango/opentype/Makefile.am                 |    2 +-
 pango/opentype/hb-ot-layout-gdef-private.h |   35 ++++++++++++++++++++--------
 pango/opentype/hb-ot-layout-gpos-private.h |   28 +++++----------------
 pango/opentype/hb-ot-layout-gsub-private.h |   28 +++++----------------
 pango/opentype/hb-ot-layout-open-private.h |   12 ++-------
 pango/opentype/hb-ot-layout.cc             |    9 +++++++
 pango/opentype/hb-ot-layout.h              |    6 ++++
 pango/opentype/main.cc                     |    8 +++---
 8 files changed, 62 insertions(+), 66 deletions(-)

diff --git a/pango/opentype/Makefile.am b/pango/opentype/Makefile.am
index 3f662db..cb0ddd0 100644
--- a/pango/opentype/Makefile.am
+++ b/pango/opentype/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = 					\
 	-I $(srcdir)				\
 	$(FREETYPE_CFLAGS)			\
 	$(GLIB_CFLAGS)
-CXX = gcc $(GCCOPTS) -g -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align
+CXX = gcc -g -O2 -fno-rtti -fno-exceptions -Wabi -Wpadded -Wcast-align
 
 noinst_LTLIBRARIES = libharfbuzz-1.la
 
diff --git a/pango/opentype/hb-ot-layout-gdef-private.h b/pango/opentype/hb-ot-layout-gdef-private.h
index d57fb47..d038098 100644
--- a/pango/opentype/hb-ot-layout-gdef-private.h
+++ b/pango/opentype/hb-ot-layout-gdef-private.h
@@ -50,10 +50,18 @@ ASSERT_SIZE (AttachPoint, 2);
 
 struct AttachList
 {
-  /* XXX We need enumeration API here */
-  inline const AttachPoint& get_attach_points (hb_codepoint_t glyph)
+  inline void get_attach_points (hb_codepoint_t glyph_id,
+				 unsigned int *point_count /* IN/OUT */,
+				 unsigned int *point_array /* OUT */) const
   {
-    return this+attachPoint[(this+coverage) (glyph)];
+    unsigned int index = (this+coverage) (glyph_id);
+    const AttachPoint &points = this+attachPoint[index];
+
+    unsigned int count = MIN (points.len, *point_count);
+    for (unsigned int i = 0; i < count; i++)
+      point_array[i] = points[i];
+
+    *point_count = points.len;
   }
 
   private:
@@ -164,9 +172,10 @@ struct LigCaretList
   friend struct GDEF;
 
   private:
-  inline const LigGlyph& get_lig_glyph (hb_codepoint_t glyph)
+  inline const LigGlyph& get_lig_glyph (hb_codepoint_t glyph_id)
   {
-    return this+ligGlyph[(this+coverage) (glyph)];
+    unsigned int index = (this+coverage) (glyph_id);
+    return this+ligGlyph[index];
   }
 
   private:
@@ -198,14 +207,20 @@ struct GDEF
   STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
 
   inline bool has_glyph_classes () const { return glyphClassDef != 0; }
-  inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); }
+  inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const
+  { return (this+glyphClassDef).get_class (glyph); }
 
   inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; }
-  inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const { return (this+markAttachClassDef).get_class (glyph); }
+  inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const
+  { return (this+markAttachClassDef).get_class (glyph); }
+
+  inline bool has_attach_points () const { return attachList != 0; }
+  inline void get_attach_points (hb_codepoint_t glyph_id,
+				 unsigned int *point_count /* IN/OUT */,
+				 unsigned int *point_array /* OUT */) const
+  { (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
 
-  /* TODO get_attach and get_lig_caret */
-  inline bool has_attach_list () const { return attachList != 0; }
-  inline bool has_lig_caret_list () const { return ligCaretList != 0; }
+  inline bool has_lig_carets () const { return ligCaretList != 0; }
 
   private:
   FixedVersion	version;		/* Version of the GDEF table--initially
diff --git a/pango/opentype/hb-ot-layout-gpos-private.h b/pango/opentype/hb-ot-layout-gpos-private.h
index be192b5..2c4b741 100644
--- a/pango/opentype/hb-ot-layout-gpos-private.h
+++ b/pango/opentype/hb-ot-layout-gpos-private.h
@@ -52,9 +52,7 @@ struct ValueFormat : USHORT
   };
 
   inline unsigned int get_len () const
-  {
-    return _hb_popcount32 ((unsigned int) *this);
-  }
+  { return _hb_popcount32 ((unsigned int) *this); }
 
   const void apply_value (hb_ot_layout_t      *layout,
 			  const char          *base,
@@ -1138,9 +1136,7 @@ struct ContextPos : Context
 
   private:
   inline bool apply (APPLY_ARG_DEF) const
-  {
-    return Context::apply (APPLY_ARG, position_lookup);
-  }
+  { return Context::apply (APPLY_ARG, position_lookup); }
 };
 ASSERT_SIZE (ContextPos, 2);
 
@@ -1150,9 +1146,7 @@ struct ChainContextPos : ChainContext
 
   private:
   inline bool apply (APPLY_ARG_DEF) const
-  {
-    return ChainContext::apply (APPLY_ARG, position_lookup);
-  }
+  { return ChainContext::apply (APPLY_ARG, position_lookup); }
 };
 ASSERT_SIZE (ChainContextPos, 2);
 
@@ -1225,9 +1219,7 @@ ASSERT_SIZE (PosLookupSubTable, 2);
 struct PosLookup : Lookup
 {
   inline const PosLookupSubTable& get_subtable (unsigned int i) const
-  {
-    return (const PosLookupSubTable&) Lookup::get_subtable (i);
-  }
+  { return (const PosLookupSubTable&) Lookup::get_subtable (i); }
 
   /* Like get_type(), but looks through extension lookups.
    * Never returns Extension */
@@ -1315,22 +1307,16 @@ struct GPOS : GSUBGPOS
   static const hb_tag_t Tag		= HB_TAG ('G','P','O','S');
 
   static inline const GPOS& get_for_data (const char *data)
-  {
-    return (const GPOS&) GSUBGPOS::get_for_data (data);
-  }
+  { return (const GPOS&) GSUBGPOS::get_for_data (data); }
 
   inline const PosLookup& get_lookup (unsigned int i) const
-  {
-    return (const PosLookup&) GSUBGPOS::get_lookup (i);
-  }
+  { return (const PosLookup&) GSUBGPOS::get_lookup (i); }
 
   inline bool position_lookup (hb_ot_layout_t *layout,
 			       hb_buffer_t    *buffer,
 			       unsigned int    lookup_index,
 			       hb_ot_layout_feature_mask_t  mask) const
-  {
-    return get_lookup (lookup_index).apply_string (layout, buffer, mask);
-  }
+  { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
 
 };
 ASSERT_SIZE (GPOS, 10);
diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h
index fc69a27..ec7b3b7 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.h
+++ b/pango/opentype/hb-ot-layout-gsub-private.h
@@ -455,9 +455,7 @@ struct ContextSubst : Context
 
   private:
   inline bool apply (APPLY_ARG_DEF) const
-  {
-    return Context::apply (APPLY_ARG, substitute_lookup);
-  }
+  { return Context::apply (APPLY_ARG, substitute_lookup); }
 };
 ASSERT_SIZE (ContextSubst, 2);
 
@@ -467,9 +465,7 @@ struct ChainContextSubst : ChainContext
 
   private:
   inline bool apply (APPLY_ARG_DEF) const
-  {
-    return ChainContext::apply (APPLY_ARG, substitute_lookup);
-  }
+  { return ChainContext::apply (APPLY_ARG, substitute_lookup); }
 };
 ASSERT_SIZE (ChainContextSubst, 2);
 
@@ -614,9 +610,7 @@ ASSERT_SIZE (SubstLookupSubTable, 2);
 struct SubstLookup : Lookup
 {
   inline const SubstLookupSubTable& get_subtable (unsigned int i) const
-  {
-    return (const SubstLookupSubTable&) Lookup::get_subtable (i);
-  }
+  { return (const SubstLookupSubTable&) Lookup::get_subtable (i); }
 
   /* Like get_type(), but looks through extension lookups.
    * Never returns Extension */
@@ -639,9 +633,7 @@ struct SubstLookup : Lookup
   }
 
   inline bool is_reverse (void) const
-  {
-    return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle);
-  }
+  { return HB_UNLIKELY (get_effective_type () == SubstLookupSubTable::ReverseChainSingle); }
 
   inline bool apply_once (hb_ot_layout_t *layout,
 			  hb_buffer_t    *buffer,
@@ -721,22 +713,16 @@ struct GSUB : GSUBGPOS
   static const hb_tag_t Tag		= HB_TAG ('G','S','U','B');
 
   static inline const GSUB& get_for_data (const char *data)
-  {
-    return (const GSUB&) GSUBGPOS::get_for_data (data);
-  }
+  { return (const GSUB&) GSUBGPOS::get_for_data (data); }
 
   inline const SubstLookup& get_lookup (unsigned int i) const
-  {
-    return (const SubstLookup&) GSUBGPOS::get_lookup (i);
-  }
+  { return (const SubstLookup&) GSUBGPOS::get_lookup (i); }
 
   inline bool substitute_lookup (hb_ot_layout_t *layout,
 				 hb_buffer_t    *buffer,
 			         unsigned int    lookup_index,
 				 hb_ot_layout_feature_mask_t  mask) const
-  {
-    return get_lookup (lookup_index).apply_string (layout, buffer, mask);
-  }
+  { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
 
 };
 ASSERT_SIZE (GSUB, 10);
diff --git a/pango/opentype/hb-ot-layout-open-private.h b/pango/opentype/hb-ot-layout-open-private.h
index 96656c3..0da23ef 100644
--- a/pango/opentype/hb-ot-layout-open-private.h
+++ b/pango/opentype/hb-ot-layout-open-private.h
@@ -322,9 +322,7 @@ struct ArrayOf
     return array[i];
   }
   inline unsigned int get_size () const
-  {
-    return sizeof (len) + len * sizeof (array[0]);
-  }
+  { return sizeof (len) + len * sizeof (array[0]); }
 
   USHORT len;
   Type array[];
@@ -341,9 +339,7 @@ struct HeadlessArrayOf
     return array[i-1];
   }
   inline unsigned int get_size () const
-  {
-    return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]);
-  }
+  { return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]); }
 
   USHORT len;
   Type array[];
@@ -359,9 +355,7 @@ struct LongArrayOf
     return array[i];
   }
   inline unsigned int get_size () const
-  {
-    return sizeof (len) + len * sizeof (array[0]);
-  }
+  { return sizeof (len) + len * sizeof (array[0]); }
 
   ULONG len;
   Type array[];
diff --git a/pango/opentype/hb-ot-layout.cc b/pango/opentype/hb-ot-layout.cc
index 3cabde3..5a30f94 100644
--- a/pango/opentype/hb-ot-layout.cc
+++ b/pango/opentype/hb-ot-layout.cc
@@ -302,6 +302,15 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
     hb_ot_layout_set_glyph_class (layout, glyphs[i], (hb_ot_layout_glyph_class_t) klasses[i]);
 }
 
+void
+hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
+				hb_codepoint_t  glyph,
+				unsigned int   *point_count /* IN/OUT */,
+				unsigned int   *point_array /* OUT */)
+{
+  layout->gdef->get_attach_points (glyph, point_count, point_array);
+}
+
 /*
  * GSUB/GPOS
  */
diff --git a/pango/opentype/hb-ot-layout.h b/pango/opentype/hb-ot-layout.h
index 8c94bde..984243c 100644
--- a/pango/opentype/hb-ot-layout.h
+++ b/pango/opentype/hb-ot-layout.h
@@ -99,6 +99,12 @@ hb_ot_layout_build_glyph_classes (hb_ot_layout_t *layout,
 				  unsigned char  *klasses,
 				  uint16_t        count);
 
+void
+hb_ot_layout_get_attach_points (hb_ot_layout_t *layout,
+				hb_codepoint_t  glyph,
+				unsigned int   *point_count /* IN/OUT */,
+				unsigned int   *point_array /* OUT */);
+
 /*
  * GSUB/GPOS
  */
diff --git a/pango/opentype/main.cc b/pango/opentype/main.cc
index 9d1f8a0..11aa57d 100644
--- a/pango/opentype/main.cc
+++ b/pango/opentype/main.cc
@@ -155,10 +155,10 @@ main (int argc, char **argv)
 		  gdef.has_glyph_classes () ? "" : "no ");
 	printf ("    Has %smark attachment types\n",
 		  gdef.has_mark_attachment_types () ? "" : "no ");
-	printf ("    Has %sattach list\n",
-		  gdef.has_attach_list () ? "" : "no ");
-	printf ("    Has %slig caret list\n",
-		  gdef.has_lig_caret_list () ? "" : "no ");
+	printf ("    Has %sattach points\n",
+		  gdef.has_attach_points () ? "" : "no ");
+	printf ("    Has %slig carets\n",
+		  gdef.has_lig_carets () ? "" : "no ");
 
 	for (int glyph = 0; glyph < 1; glyph++)
 	  printf ("    glyph %d has class %d and mark attachment type %d\n",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]