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

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Nov 6 00:50:25 UTC 2018


 src/hb-ot-cmap-table.hh |   55 ++++++++++++++++++++++++++++++------------------
 src/hb-ot-font.cc       |   13 ++---------
 2 files changed, 38 insertions(+), 30 deletions(-)

New commits:
commit 56ba998cddbb2ba5d24fb0b02d2bf77a46c0f23f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 5 19:49:54 2018 -0500

    [cmap] Push get_nominal_glyphs down into cmap accelerator

diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 2013ae98..399c46bf 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -1060,6 +1060,27 @@ struct cmap
       if (unlikely (!this->get_glyph_funcZ)) return false;
       return this->get_glyph_funcZ (this->get_glyph_data, unicode, glyph);
     }
+    inline unsigned int get_nominal_glyphs (unsigned int count,
+					    const hb_codepoint_t *first_unicode,
+					    unsigned int unicode_stride,
+					    hb_codepoint_t *first_glyph,
+					    unsigned int glyph_stride) const
+    {
+      if (unlikely (!this->get_glyph_funcZ)) return 0;
+
+      hb_cmap_get_glyph_func_t get_glyph_funcZ = this->get_glyph_funcZ;
+      const void *get_glyph_data = this->get_glyph_data;
+
+      unsigned int done;
+      for (done = 0;
+	   done < count && get_glyph_funcZ (get_glyph_data, *first_unicode, first_glyph);
+	   done++)
+      {
+	first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride);
+	first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
+      }
+      return done;
+    }
 
     inline bool get_variation_glyph (hb_codepoint_t  unicode,
 				     hb_codepoint_t  variation_selector,
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index 41bea140..3e2f1f65 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -76,16 +76,9 @@ hb_ot_get_nominal_glyphs (hb_font_t *font HB_UNUSED,
 			  void *user_data HB_UNUSED)
 {
   const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data;
-  const OT::cmap_accelerator_t &cmap = *ot_face->cmap;
-  unsigned int done;
-  for (done = 0;
-       done < count && cmap.get_nominal_glyph (*first_unicode, first_glyph);
-       done++)
-  {
-    first_unicode = &StructAtOffset<hb_codepoint_t> (first_unicode, unicode_stride);
-    first_glyph = &StructAtOffset<hb_codepoint_t> (first_glyph, glyph_stride);
-  }
-  return done;
+  return ot_face->cmap->get_nominal_glyphs (count,
+					    first_unicode, unicode_stride,
+					    first_glyph, glyph_stride);
 }
 
 static hb_bool_t
commit 36d85dce25abd079252d973f804220bf7b97e987
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 5 19:46:29 2018 -0500

    [cmap] Use hb_nonnullptr_t

diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index bcb50790..2013ae98 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -1017,22 +1017,20 @@ struct cmap
       this->blob = hb_sanitize_context_t().reference_table<cmap> (face);
       const cmap *table = this->blob->as<cmap> ();
       bool symbol;
-      subtableZ = table->find_best_subtable (&symbol);
-
-      /* UVS subtable. */
-      subtable_uvsZ = &Null(CmapSubtableFormat14);
+      this->subtable = table->find_best_subtable (&symbol);
+      this->subtable_uvs = &Null(CmapSubtableFormat14);
       {
 	const CmapSubtable *st = table->find_subtable (0, 5);
 	if (st && st->u.format == 14)
-	  subtable_uvsZ = &st->u.format14;
+	  subtable_uvs = &st->u.format14;
       }
 
-      this->get_glyph_data = subtableZ;
+      this->get_glyph_data = subtable;
       if (unlikely (symbol))
       {
 	this->get_glyph_funcZ = get_glyph_from_symbol<CmapSubtable>;
       } else {
-	switch (subtableZ->u.format) {
+	switch (subtable->u.format) {
 	/* Accelerate format 4 and format 12. */
 	default:
 	  this->get_glyph_funcZ = get_glyph_from<CmapSubtable>;
@@ -1042,7 +1040,7 @@ struct cmap
 	  break;
 	case  4:
 	  {
-	    this->format4_accel.init (&subtableZ->u.format4);
+	    this->format4_accel.init (&subtable->u.format4);
 	    this->get_glyph_data = &this->format4_accel;
 	    this->get_glyph_funcZ = this->format4_accel.get_glyph_func;
 	  }
@@ -1067,10 +1065,9 @@ struct cmap
 				     hb_codepoint_t  variation_selector,
 				     hb_codepoint_t *glyph) const
     {
-      if (unlikely (!this->subtable_uvsZ)) return false;
-      switch (this->subtable_uvsZ->get_glyph_variant (unicode,
-						      variation_selector,
-						      glyph))
+      switch (this->subtable_uvs->get_glyph_variant (unicode,
+						     variation_selector,
+						     glyph))
       {
 	case GLYPH_VARIANT_NOT_FOUND:	return false;
 	case GLYPH_VARIANT_FOUND:	return true;
@@ -1082,19 +1079,16 @@ struct cmap
 
     inline void collect_unicodes (hb_set_t *out) const
     {
-      if (unlikely (!this->subtableZ)) return;
-      subtableZ->collect_unicodes (out);
+      subtable->collect_unicodes (out);
     }
     inline void collect_variation_selectors (hb_set_t *out) const
     {
-      if (unlikely (!this->subtable_uvsZ)) return;
-      subtable_uvsZ->collect_variation_selectors (out);
+      subtable_uvs->collect_variation_selectors (out);
     }
     inline void collect_variation_unicodes (hb_codepoint_t variation_selector,
 					    hb_set_t *out) const
     {
-      if (unlikely (!this->subtable_uvsZ)) return;
-      subtable_uvsZ->collect_variation_unicodes (variation_selector, out);
+      subtable_uvs->collect_variation_unicodes (variation_selector, out);
     }
 
     protected:
@@ -1134,8 +1128,8 @@ struct cmap
     }
 
     private:
-    const CmapSubtable *subtableZ;
-    const CmapSubtableFormat14 *subtable_uvsZ;
+    hb_nonnull_ptr_t<const CmapSubtable> subtable;
+    hb_nonnull_ptr_t<const CmapSubtableFormat14> subtable_uvs;
 
     hb_cmap_get_glyph_func_t get_glyph_funcZ;
     const void *get_glyph_data;


More information about the HarfBuzz mailing list