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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Nov 21 01:46:25 UTC 2018


 docs/harfbuzz-sections.txt    |   14 +--
 src/gen-emoji-table.py        |   13 +-
 src/hb-deprecated.h           |   37 ++++++++
 src/hb-ot-var-fvar-table.hh   |  114 +++++++++++++++++--------
 src/hb-ot-var.cc              |   41 ++++++---
 src/hb-ot-var.h               |   66 ++++++--------
 src/hb-unicode-emoji-table.hh |  189 +++---------------------------------------
 test/api/test-ot-face.c       |    2 
 8 files changed, 208 insertions(+), 268 deletions(-)

New commits:
commit f48bb9a3939067f24a81007e642caaac77cc7167
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Nov 20 20:40:55 2018 -0500

    [var] Deprecated axis enumeration API and add new version
    
    New version has axis flags.
    
    New API:
    +hb_ot_var_axis_info_t
    +hb_ot_var_find_axis_info()
    +hb_ot_var_get_axis_infos()
    
    Deprecated API:
    -HB_OT_VAR_NO_AXIS_INDEX
    -hb_ot_var_axis_t
    -hb_ot_var_find_axis()
    -hb_ot_var_get_axes()

diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 63d5f6ce..5f5dcef7 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -161,6 +161,10 @@ hb_ot_layout_table_choose_script
 hb_ot_layout_table_find_script
 hb_ot_tag_from_language
 hb_ot_tags_from_script
+HB_OT_VAR_NO_AXIS_INDEX
+hb_ot_var_axis_t
+hb_ot_var_find_axis
+hb_ot_var_get_axes
 hb_set_invert
 hb_unicode_eastasian_width_func_t
 hb_unicode_eastasian_width
@@ -581,14 +585,12 @@ HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE
 HB_OT_TAG_VAR_AXIS_SLANT
 HB_OT_TAG_VAR_AXIS_WEIGHT
 HB_OT_TAG_VAR_AXIS_WIDTH
-HB_OT_VAR_NO_AXIS_INDEX
-hb_ot_var_axis_t
 hb_ot_var_has_data
-hb_ot_var_find_axis
-hb_ot_var_get_axis_count
-hb_ot_var_get_axes
 hb_ot_var_axis_flags_t
-hb_ot_var_axis_get_flags
+hb_ot_var_axis_info_t
+hb_ot_var_find_axis_info
+hb_ot_var_get_axis_count
+hb_ot_var_get_axis_infos
 hb_ot_var_get_named_instance_count
 hb_ot_var_named_instance_get_subfamily_name_id
 hb_ot_var_named_instance_get_postscript_name_id
diff --git a/src/hb-deprecated.h b/src/hb-deprecated.h
index e39b79f7..a74431f0 100644
--- a/src/hb-deprecated.h
+++ b/src/hb-deprecated.h
@@ -241,6 +241,43 @@ HB_EXTERN HB_DEPRECATED_FOR (hb_ot_tags_from_script_and_language) hb_tag_t
 hb_ot_tag_from_language (hb_language_t language);
 
 
+typedef unsigned int hb_ot_name_id_t; /* Since is in hb-ot.h */
+
+/**
+ * HB_OT_VAR_NO_AXIS_INDEX:
+ *
+ * Since: 1.4.2
+ * Deprecated: REPLACEME
+ */
+#define HB_OT_VAR_NO_AXIS_INDEX		0xFFFFFFFFu
+
+/**
+ * hb_ot_var_axis_t:
+ *
+ * Since: 1.4.2
+ * Deprecated: REPLACEME
+ */
+typedef struct hb_ot_var_axis_t
+{
+  hb_tag_t tag;
+  hb_ot_name_id_t name_id;
+  float min_value;
+  float default_value;
+  float max_value;
+} hb_ot_var_axis_t;
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_var_get_axis_infos) unsigned int
+hb_ot_var_get_axes (hb_face_t        *face,
+		    unsigned int      start_offset,
+		    unsigned int     *axes_count /* IN/OUT */,
+		    hb_ot_var_axis_t *axes_array /* OUT */);
+
+HB_EXTERN HB_DEPRECATED_FOR (hb_ot_var_find_axis_info) hb_bool_t
+hb_ot_var_find_axis (hb_face_t        *face,
+		     hb_tag_t          axis_tag,
+		     unsigned int     *axis_index,
+		     hb_ot_var_axis_t *axis_info);
+
 #endif
 
 HB_END_DECLS
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 0bf9d10d..5c8832e1 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -115,28 +115,62 @@ struct fvar
   inline unsigned int get_axis_count (void) const
   { return axisCount; }
 
-  inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const
+  inline void get_axis_deprecated (unsigned int axis_index,
+				   hb_ot_var_axis_t *info) const
   {
-    if (info)
+    const AxisRecord &axis = get_axes ()[axis_index];
+    info->tag = axis.axisTag;
+    info->name_id =  axis.axisNameID;
+    info->default_value = axis.defaultValue / 65536.;
+    /* Ensure order, to simplify client math. */
+    info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
+    info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
+  }
+
+  inline void get_axis_info (unsigned int axis_index,
+			     hb_ot_var_axis_info_t *info) const
+  {
+    const AxisRecord &axis = get_axes ()[axis_index];
+    info->axis_index = axis_index;
+    info->tag = axis.axisTag;
+    info->name_id =  axis.axisNameID;
+    info->flags = (hb_ot_var_axis_flags_t) (unsigned int) axis.flags;
+    info->default_value = axis.defaultValue / 65536.;
+    /* Ensure order, to simplify client math. */
+    info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
+    info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
+    info->reserved = 0;
+  }
+
+  inline unsigned int get_axes_deprecated (unsigned int      start_offset,
+					   unsigned int     *axes_count /* IN/OUT */,
+					   hb_ot_var_axis_t *axes_array /* OUT */) const
+  {
+    if (axes_count)
     {
-      const AxisRecord &axis = get_axes ()[index];
-      info->tag = axis.axisTag;
-      info->name_id =  axis.axisNameID;
-      info->default_value = axis.defaultValue / 65536.;
-      /* Ensure order, to simplify client math. */
-      info->min_value = MIN<float> (info->default_value, axis.minValue / 65536.);
-      info->max_value = MAX<float> (info->default_value, axis.maxValue / 65536.);
-    }
+      /* TODO Rewrite as hb_array_t<>::sub-array() */
+      unsigned int count = axisCount;
+      start_offset = MIN (start_offset, count);
+
+      count -= start_offset;
+      axes_array += start_offset;
+
+      count = MIN (count, *axes_count);
+      *axes_count = count;
 
-    return true;
+      for (unsigned int i = 0; i < count; i++)
+	get_axis_deprecated (start_offset + i, axes_array + i);
+    }
+    return axisCount;
   }
 
-  inline unsigned int get_axis_infos (unsigned int      start_offset,
-				      unsigned int     *axes_count /* IN/OUT */,
-				      hb_ot_var_axis_t *axes_array /* OUT */) const
+  inline unsigned int get_axis_infos (unsigned int           start_offset,
+				      unsigned int          *axes_count /* IN/OUT */,
+				      hb_ot_var_axis_info_t *axes_array /* OUT */) const
   {
     if (axes_count)
     {
+      /* TODO Rewrite as hb_array_t<>::sub-array() */
       unsigned int count = axisCount;
       start_offset = MIN (start_offset, count);
 
@@ -147,32 +181,48 @@ struct fvar
       *axes_count = count;
 
       for (unsigned int i = 0; i < count; i++)
-	get_axis (start_offset + i, axes_array + i);
+	get_axis_info (start_offset + i, axes_array + i);
     }
     return axisCount;
   }
 
-  inline bool find_axis (hb_tag_t tag, unsigned int *index, hb_ot_var_axis_t *info) const
+  inline bool find_axis_deprecated (hb_tag_t tag,
+				    unsigned int *axis_index,
+				    hb_ot_var_axis_t *info) const
   {
     const AxisRecord *axes = get_axes ();
     unsigned int count = get_axis_count ();
     for (unsigned int i = 0; i < count; i++)
       if (axes[i].axisTag == tag)
       {
-        if (index)
-	  *index = i;
-	return get_axis (i, info);
+        if (axis_index)
+	  *axis_index = i;
+	get_axis_deprecated (i, info);
+	return true;
+      }
+    if (axis_index)
+      *axis_index = HB_OT_VAR_NO_AXIS_INDEX;
+    return false;
+  }
+
+  inline bool find_axis_info (hb_tag_t tag,
+			      hb_ot_var_axis_info_t *info) const
+  {
+    const AxisRecord *axes = get_axes ();
+    unsigned int count = get_axis_count ();
+    for (unsigned int i = 0; i < count; i++)
+      if (axes[i].axisTag == tag)
+      {
+	get_axis_info (i, info);
+	return true;
       }
-    if (index)
-      *index = HB_OT_VAR_NO_AXIS_INDEX;
     return false;
   }
 
   inline int normalize_axis_value (unsigned int axis_index, float v) const
   {
-    hb_ot_var_axis_t axis;
-    if (!get_axis (axis_index, &axis))
-      return 0;
+    hb_ot_var_axis_info_t axis;
+    get_axis_info (axis_index, &axis);
 
     v = MAX (MIN (v, axis.max_value), axis.min_value); /* Clamp. */
 
@@ -188,25 +238,25 @@ struct fvar
   inline unsigned int get_instance_count (void) const
   { return instanceCount; }
 
-  inline hb_ot_name_id_t get_instance_subfamily_name_id (unsigned int index) const
+  inline hb_ot_name_id_t get_instance_subfamily_name_id (unsigned int instance_index) const
   {
-    const InstanceRecord &instance = get_instance (index);
+    const InstanceRecord &instance = get_instance (instance_index);
     return instance.subfamilyNameID;
   }
 
-  inline hb_ot_name_id_t get_instance_postscript_name_id (unsigned int index) const
+  inline hb_ot_name_id_t get_instance_postscript_name_id (unsigned int instance_index) const
   {
-    const InstanceRecord &instance = get_instance (index);
+    const InstanceRecord &instance = get_instance (instance_index);
     if (instanceSize >= axisCount * 4 + 6)
       return StructAfter<NameID> (instance.get_coordinates (axisCount));
     return HB_OT_NAME_ID_INVALID;
   }
 
-  inline unsigned int get_instance_coords (unsigned int  index,
+  inline unsigned int get_instance_coords (unsigned int  instance_index,
 					   unsigned int *coords_length, /* IN/OUT */
 					   float        *coords         /* OUT */) const
   {
-    if (unlikely (index >= instanceCount))
+    if (unlikely (instance_index >= instanceCount))
     {
       if (coords_length)
         *coords_length = 0;
@@ -215,7 +265,7 @@ struct fvar
 
     if (coords_length && *coords_length)
     {
-      const InstanceRecord &instance = get_instance (index);
+      const InstanceRecord &instance = get_instance (instance_index);
       hb_array_t<const Fixed> instanceCoords = instance.get_coordinates (axisCount)
 						       .sub_array (0, *coords_length);
       for (unsigned int i = 0; i < instanceCoords.len; i++)
diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc
index 279e8723..56d24817 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -53,7 +53,6 @@
  * @face: #hb_face_t to test
  *
  * This function allows to verify the presence of OpenType variation data on the face.
- * Alternatively, use hb_ot_var_get_axis_count().
  *
  * Return value: true if face has a `fvar' table and false otherwise
  *
@@ -80,6 +79,7 @@ hb_ot_var_get_axis_count (hb_face_t *face)
  * hb_ot_var_get_axes:
  *
  * Since: 1.4.2
+ * Deprecated: REPLACEME
  **/
 unsigned int
 hb_ot_var_get_axes (hb_face_t        *face,
@@ -87,13 +87,14 @@ hb_ot_var_get_axes (hb_face_t        *face,
 		    unsigned int     *axes_count /* IN/OUT */,
 		    hb_ot_var_axis_t *axes_array /* OUT */)
 {
-  return face->table.fvar->get_axis_infos (start_offset, axes_count, axes_array);
+  return face->table.fvar->get_axes_deprecated (start_offset, axes_count, axes_array);
 }
 
 /**
  * hb_ot_var_find_axis:
  *
  * Since: 1.4.2
+ * Deprecated: REPLACEME
  **/
 hb_bool_t
 hb_ot_var_find_axis (hb_face_t        *face,
@@ -101,9 +102,37 @@ hb_ot_var_find_axis (hb_face_t        *face,
 		     unsigned int     *axis_index,
 		     hb_ot_var_axis_t *axis_info)
 {
-  return face->table.fvar->find_axis (axis_tag, axis_index, axis_info);
+  return face->table.fvar->find_axis_deprecated (axis_tag, axis_index, axis_info);
+}
+
+/**
+ * hb_ot_var_get_axis_infos:
+ *
+ * Since: REPLACEME
+ **/
+HB_EXTERN unsigned int
+hb_ot_var_get_axis_infos (hb_face_t             *face,
+			  unsigned int           start_offset,
+			  unsigned int          *axes_count /* IN/OUT */,
+			  hb_ot_var_axis_info_t *axes_array /* OUT */)
+{
+  return face->table.fvar->get_axis_infos (start_offset, axes_count, axes_array);
 }
 
+/**
+ * hb_ot_var_find_axis_info:
+ *
+ * Since: REPLACEME
+ **/
+HB_EXTERN hb_bool_t
+hb_ot_var_find_axis_info (hb_face_t             *face,
+			  hb_tag_t               axis_tag,
+			  hb_ot_var_axis_info_t *axis_info)
+{
+  return face->table.fvar->find_axis_info (axis_tag, axis_info);
+}
+
+
 /*
  * Named instances.
  */
@@ -156,10 +185,10 @@ hb_ot_var_normalize_variations (hb_face_t            *face,
   const OT::fvar &fvar = *face->table.fvar;
   for (unsigned int i = 0; i < variations_length; i++)
   {
-    unsigned int axis_index;
-    if (hb_ot_var_find_axis (face, variations[i].tag, &axis_index, nullptr) &&
-	axis_index < coords_length)
-      coords[axis_index] = fvar.normalize_axis_value (axis_index, variations[i].value);
+    hb_ot_var_axis_info_t info;
+    if (hb_ot_var_find_axis_info (face, variations[i].tag, &info) &&
+	info.axis_index < coords_length)
+      coords[info.axis_index] = fvar.normalize_axis_value (info.axis_index, variations[i].value);
   }
 
   face->table.avar->map_coords (coords, coords_length);
diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index 0114e5c9..779be104 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -55,43 +55,11 @@ hb_ot_var_has_data (hb_face_t *face);
  * Variation axes.
  */
 
-/**
- * HB_OT_VAR_NO_AXIS_INDEX:
- *
- * Since: 1.4.2
- */
-#define HB_OT_VAR_NO_AXIS_INDEX		0xFFFFFFFFu
 
 HB_EXTERN unsigned int
 hb_ot_var_get_axis_count (hb_face_t *face);
 
 /**
- * hb_ot_var_axis_t:
- *
- * Since: 1.4.2
- */
-typedef struct hb_ot_var_axis_t
-{
-  hb_tag_t tag;
-  hb_ot_name_id_t name_id;
-  float min_value;
-  float default_value;
-  float max_value;
-} hb_ot_var_axis_t;
-
-HB_EXTERN unsigned int
-hb_ot_var_get_axes (hb_face_t        *face,
-		    unsigned int      start_offset,
-		    unsigned int     *axes_count /* IN/OUT */,
-		    hb_ot_var_axis_t *axes_array /* OUT */);
-
-HB_EXTERN hb_bool_t
-hb_ot_var_find_axis (hb_face_t        *face,
-		     hb_tag_t          axis_tag,
-		     unsigned int     *axis_index,
-		     hb_ot_var_axis_t *axis_info);
-
-/**
  * hb_ot_var_axis_flags_t:
  * @HB_OT_VAR_AXIS_FLAG_HIDDEN: The axis should not be exposed directly in user interfaces.
  *
@@ -103,6 +71,35 @@ typedef enum { /*< flags >*/
   _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/
 } hb_ot_var_axis_flags_t;
 
+/**
+ * hb_ot_var_axis_info_t:
+ *
+ * Since: REPLACEME
+ */
+typedef struct hb_ot_var_axis_info_t
+{
+  unsigned int			axis_index;
+  hb_tag_t			tag;
+  hb_ot_name_id_t		name_id;
+  hb_ot_var_axis_flags_t	flags;
+  float				min_value;
+  float				default_value;
+  float				max_value;
+  /*< private >*/
+  unsigned int			reserved;
+} hb_ot_var_axis_info_t;
+
+HB_EXTERN unsigned int
+hb_ot_var_get_axis_infos (hb_face_t             *face,
+			  unsigned int           start_offset,
+			  unsigned int          *axes_count /* IN/OUT */,
+			  hb_ot_var_axis_info_t *axes_array /* OUT */);
+
+HB_EXTERN hb_bool_t
+hb_ot_var_find_axis_info (hb_face_t             *face,
+			  hb_tag_t               axis_tag,
+			  hb_ot_var_axis_info_t *axis_info);
+
 
 /*
  * Named instances.
diff --git a/test/api/test-ot-face.c b/test/api/test-ot-face.c
index d6eefbaa..757bc1f8 100644
--- a/test/api/test-ot-face.c
+++ b/test/api/test-ot-face.c
@@ -93,7 +93,7 @@ test_face (hb_face_t *face,
   hb_ot_name_get_utf32 (face, cp, NULL, NULL, NULL);
 
   hb_ot_var_get_axis_count (face);
-  hb_ot_var_get_axes (face, 0, NULL, NULL);
+  hb_ot_var_get_axis_infos (face, 0, NULL, NULL);
   hb_ot_var_normalize_variations (face, NULL, 0, NULL, 0);
   hb_ot_var_normalize_coords (face, 0, NULL, NULL);
 
commit b2d803cef6974519d5892af2c9efeb8dfba87618
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Nov 20 11:42:25 2018 -0500

    Remove newly-added -hb_ot_var_axis_get_flags()

diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 47c2516f..0bf9d10d 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -131,12 +131,6 @@ struct fvar
     return true;
   }
 
-  inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const
-  {
-    const AxisRecord &axis = get_axes ()[index];
-    return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags;
-  }
-
   inline unsigned int get_axis_infos (unsigned int      start_offset,
 				      unsigned int     *axes_count /* IN/OUT */,
 				      hb_ot_var_axis_t *axes_array /* OUT */) const
diff --git a/src/hb-ot-var.cc b/src/hb-ot-var.cc
index 9ad2f861..279e8723 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -104,18 +104,6 @@ hb_ot_var_find_axis (hb_face_t        *face,
   return face->table.fvar->find_axis (axis_tag, axis_index, axis_info);
 }
 
-/**
- * hb_ot_var_axis_get_flags:
- *
- * Since: REPLACEME
- **/
-hb_ot_var_axis_flags_t
-hb_ot_var_axis_get_flags (hb_face_t    *face,
-			  unsigned int  axis_index)
-{
-  return face->table.fvar->get_axis_flags (axis_index);
-}
-
 /*
  * Named instances.
  */
diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index 676be9f7..0114e5c9 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -103,10 +103,6 @@ typedef enum { /*< flags >*/
   _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/
 } hb_ot_var_axis_flags_t;
 
-HB_EXTERN hb_ot_var_axis_flags_t
-hb_ot_var_axis_get_flags (hb_face_t    *face,
-			  unsigned int  axis_index);
-
 
 /*
  * Named instances.
commit 736897d7a1410fd281fbcedc084b85bf4ba1410c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Nov 20 11:40:43 2018 -0500

    [var] Make sure hb_ot_var_axis_flags_t is int-sized

diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index 997be77f..676be9f7 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -98,7 +98,9 @@ hb_ot_var_find_axis (hb_face_t        *face,
  * Since: REPLACEME
  */
 typedef enum { /*< flags >*/
-  HB_OT_VAR_AXIS_FLAG_HIDDEN	= 0x0001u,
+  HB_OT_VAR_AXIS_FLAG_HIDDEN	= 0x00000001u,
+
+  _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= 0x7FFFFFFFu, /*< skip >*/
 } hb_ot_var_axis_flags_t;
 
 HB_EXTERN hb_ot_var_axis_flags_t
commit eab5d15f6156e771cb606b760dd170b96c5cd398
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Nov 20 11:33:33 2018 -0500

    [var] Move code

diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index 79ce7d72..997be77f 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -47,19 +47,6 @@ HB_BEGIN_DECLS
  * fvar / avar
  */
 
-/**
- * hb_ot_var_axis_t:
- *
- * Since: 1.4.2
- */
-typedef struct hb_ot_var_axis_t {
-  hb_tag_t tag;
-  hb_ot_name_id_t name_id;
-  float min_value;
-  float default_value;
-  float max_value;
-} hb_ot_var_axis_t;
-
 HB_EXTERN hb_bool_t
 hb_ot_var_has_data (hb_face_t *face);
 
@@ -78,6 +65,20 @@ hb_ot_var_has_data (hb_face_t *face);
 HB_EXTERN unsigned int
 hb_ot_var_get_axis_count (hb_face_t *face);
 
+/**
+ * hb_ot_var_axis_t:
+ *
+ * Since: 1.4.2
+ */
+typedef struct hb_ot_var_axis_t
+{
+  hb_tag_t tag;
+  hb_ot_name_id_t name_id;
+  float min_value;
+  float default_value;
+  float max_value;
+} hb_ot_var_axis_t;
+
 HB_EXTERN unsigned int
 hb_ot_var_get_axes (hb_face_t        *face,
 		    unsigned int      start_offset,
commit 064f703c7ac5a28803a8221720e922ea6dbd2505
Merge: be1828da 82951182
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Nov 20 16:29:30 2018 -0500

    Merge pull request #1397 from harfbuzz/small-emoji-table
    
    Shrink the emoji table by merging adjacent ranges

commit 82951182799772a642d32195dd87e6f0c116f545
Author: David Corbett <corbett.dav at husky.neu.edu>
Date:   Tue Nov 20 15:41:45 2018 -0500

    Shrink the emoji table by merging adjacent ranges

diff --git a/src/gen-emoji-table.py b/src/gen-emoji-table.py
index 278e0b2d..9afe747d 100755
--- a/src/gen-emoji-table.py
+++ b/src/gen-emoji-table.py
@@ -12,7 +12,7 @@ if len (sys.argv) != 2:
 f = open(sys.argv[1])
 header = [f.readline () for _ in range(10)]
 
-sets = OrderedDict()
+ranges = OrderedDict()
 for line in f.readlines():
 	line = line.strip()
 	if not line or line[0] == '#':
@@ -25,9 +25,12 @@ for line in f.readlines():
 	else:
 		start = end = rang[0]
 
-	if typ not in sets:
-		sets[typ] = set()
-	sets[typ].add((start, end))
+	if typ not in ranges:
+		ranges[typ] = []
+	if ranges[typ] and ranges[typ][-1][1] == start - 1:
+		ranges[typ][-1] = (ranges[typ][-1][0], end)
+	else:
+		ranges[typ].append((start, end))
 
 
 
@@ -49,7 +52,7 @@ print ()
 print ('#include "hb-unicode.hh"')
 print ()
 
-for typ,s in sets.items():
+for typ,s in ranges.items():
 	if typ != "Extended_Pictographic": continue
 	print()
 	print("static const struct hb_unicode_range_t _hb_unicode_emoji_%s_table[] =" % typ)
diff --git a/src/hb-unicode-emoji-table.hh b/src/hb-unicode-emoji-table.hh
index 41199de5..1dd0b321 100644
--- a/src/hb-unicode-emoji-table.hh
+++ b/src/hb-unicode-emoji-table.hh
@@ -47,38 +47,9 @@ static const struct hb_unicode_range_t _hb_unicode_emoji_Extended_Pictographic_t
   {0x25FB, 0x25FE},
   {0x2600, 0x2605},
   {0x2607, 0x2612},
-  {0x2614, 0x2615},
-  {0x2616, 0x2617},
-  {0x2618, 0x2618},
-  {0x2619, 0x2619},
-  {0x261A, 0x266F},
-  {0x2670, 0x2671},
-  {0x2672, 0x267D},
-  {0x267E, 0x267F},
-  {0x2680, 0x2685},
-  {0x2690, 0x2691},
-  {0x2692, 0x269C},
-  {0x269D, 0x269D},
-  {0x269E, 0x269F},
-  {0x26A0, 0x26A1},
-  {0x26A2, 0x26B1},
-  {0x26B2, 0x26B2},
-  {0x26B3, 0x26BC},
-  {0x26BD, 0x26BF},
-  {0x26C0, 0x26C3},
-  {0x26C4, 0x26CD},
-  {0x26CE, 0x26CE},
-  {0x26CF, 0x26E1},
-  {0x26E2, 0x26E2},
-  {0x26E3, 0x26E3},
-  {0x26E4, 0x26E7},
-  {0x26E8, 0x26FF},
-  {0x2700, 0x2700},
-  {0x2701, 0x2704},
-  {0x2705, 0x2705},
-  {0x2708, 0x2709},
-  {0x270A, 0x270B},
-  {0x270C, 0x2712},
+  {0x2614, 0x2685},
+  {0x2690, 0x2705},
+  {0x2708, 0x2712},
   {0x2714, 0x2714},
   {0x2716, 0x2716},
   {0x271D, 0x271D},
@@ -105,163 +76,33 @@ static const struct hb_unicode_range_t _hb_unicode_emoji_Extended_Pictographic_t
   {0x303D, 0x303D},
   {0x3297, 0x3297},
   {0x3299, 0x3299},
-  {0x1F000, 0x1F02B},
-  {0x1F02C, 0x1F02F},
-  {0x1F030, 0x1F093},
-  {0x1F094, 0x1F09F},
-  {0x1F0A0, 0x1F0AE},
-  {0x1F0AF, 0x1F0B0},
-  {0x1F0B1, 0x1F0BE},
-  {0x1F0BF, 0x1F0BF},
-  {0x1F0C0, 0x1F0C0},
-  {0x1F0C1, 0x1F0CF},
-  {0x1F0D0, 0x1F0D0},
-  {0x1F0D1, 0x1F0DF},
-  {0x1F0E0, 0x1F0F5},
-  {0x1F0F6, 0x1F0FF},
+  {0x1F000, 0x1F0FF},
   {0x1F10D, 0x1F10F},
   {0x1F12F, 0x1F12F},
-  {0x1F16C, 0x1F16F},
-  {0x1F170, 0x1F171},
-  {0x1F17E, 0x1F17E},
-  {0x1F17F, 0x1F17F},
+  {0x1F16C, 0x1F171},
+  {0x1F17E, 0x1F17F},
   {0x1F18E, 0x1F18E},
   {0x1F191, 0x1F19A},
   {0x1F1AD, 0x1F1E5},
-  {0x1F201, 0x1F202},
-  {0x1F203, 0x1F20F},
+  {0x1F201, 0x1F20F},
   {0x1F21A, 0x1F21A},
   {0x1F22F, 0x1F22F},
   {0x1F232, 0x1F23A},
   {0x1F23C, 0x1F23F},
-  {0x1F249, 0x1F24F},
-  {0x1F250, 0x1F251},
-  {0x1F252, 0x1F25F},
-  {0x1F260, 0x1F265},
-  {0x1F266, 0x1F2FF},
-  {0x1F300, 0x1F320},
-  {0x1F321, 0x1F32C},
-  {0x1F32D, 0x1F32F},
-  {0x1F330, 0x1F335},
-  {0x1F336, 0x1F336},
-  {0x1F337, 0x1F37C},
-  {0x1F37D, 0x1F37D},
-  {0x1F37E, 0x1F37F},
-  {0x1F380, 0x1F393},
-  {0x1F394, 0x1F39F},
-  {0x1F3A0, 0x1F3C4},
-  {0x1F3C5, 0x1F3C5},
-  {0x1F3C6, 0x1F3CA},
-  {0x1F3CB, 0x1F3CE},
-  {0x1F3CF, 0x1F3D3},
-  {0x1F3D4, 0x1F3DF},
-  {0x1F3E0, 0x1F3F0},
-  {0x1F3F1, 0x1F3F7},
-  {0x1F3F8, 0x1F3FA},
-  {0x1F400, 0x1F43E},
-  {0x1F43F, 0x1F43F},
-  {0x1F440, 0x1F440},
-  {0x1F441, 0x1F441},
-  {0x1F442, 0x1F4F7},
-  {0x1F4F8, 0x1F4F8},
-  {0x1F4F9, 0x1F4FC},
-  {0x1F4FD, 0x1F4FE},
-  {0x1F4FF, 0x1F4FF},
-  {0x1F500, 0x1F53D},
-  {0x1F546, 0x1F54A},
-  {0x1F54B, 0x1F54F},
-  {0x1F550, 0x1F567},
-  {0x1F568, 0x1F579},
-  {0x1F57A, 0x1F57A},
-  {0x1F57B, 0x1F5A3},
-  {0x1F5A4, 0x1F5A4},
-  {0x1F5A5, 0x1F5FA},
-  {0x1F5FB, 0x1F5FF},
-  {0x1F600, 0x1F600},
-  {0x1F601, 0x1F610},
-  {0x1F611, 0x1F611},
-  {0x1F612, 0x1F614},
-  {0x1F615, 0x1F615},
-  {0x1F616, 0x1F616},
-  {0x1F617, 0x1F617},
-  {0x1F618, 0x1F618},
-  {0x1F619, 0x1F619},
-  {0x1F61A, 0x1F61A},
-  {0x1F61B, 0x1F61B},
-  {0x1F61C, 0x1F61E},
-  {0x1F61F, 0x1F61F},
-  {0x1F620, 0x1F625},
-  {0x1F626, 0x1F627},
-  {0x1F628, 0x1F62B},
-  {0x1F62C, 0x1F62C},
-  {0x1F62D, 0x1F62D},
-  {0x1F62E, 0x1F62F},
-  {0x1F630, 0x1F633},
-  {0x1F634, 0x1F634},
-  {0x1F635, 0x1F640},
-  {0x1F641, 0x1F642},
-  {0x1F643, 0x1F644},
-  {0x1F645, 0x1F64F},
-  {0x1F680, 0x1F6C5},
-  {0x1F6C6, 0x1F6CF},
-  {0x1F6D0, 0x1F6D0},
-  {0x1F6D1, 0x1F6D2},
-  {0x1F6D3, 0x1F6D4},
-  {0x1F6D5, 0x1F6DF},
-  {0x1F6E0, 0x1F6EC},
-  {0x1F6ED, 0x1F6EF},
-  {0x1F6F0, 0x1F6F3},
-  {0x1F6F4, 0x1F6F6},
-  {0x1F6F7, 0x1F6F8},
-  {0x1F6F9, 0x1F6F9},
-  {0x1F6FA, 0x1F6FF},
+  {0x1F249, 0x1F3FA},
+  {0x1F400, 0x1F53D},
+  {0x1F546, 0x1F64F},
+  {0x1F680, 0x1F6FF},
   {0x1F774, 0x1F77F},
-  {0x1F7D5, 0x1F7D8},
-  {0x1F7D9, 0x1F7FF},
+  {0x1F7D5, 0x1F7FF},
   {0x1F80C, 0x1F80F},
   {0x1F848, 0x1F84F},
   {0x1F85A, 0x1F85F},
   {0x1F888, 0x1F88F},
   {0x1F8AE, 0x1F8FF},
-  {0x1F90C, 0x1F90F},
-  {0x1F910, 0x1F918},
-  {0x1F919, 0x1F91E},
-  {0x1F91F, 0x1F91F},
-  {0x1F920, 0x1F927},
-  {0x1F928, 0x1F92F},
-  {0x1F930, 0x1F930},
-  {0x1F931, 0x1F932},
-  {0x1F933, 0x1F93A},
-  {0x1F93C, 0x1F93E},
-  {0x1F93F, 0x1F93F},
-  {0x1F940, 0x1F945},
-  {0x1F947, 0x1F94B},
-  {0x1F94C, 0x1F94C},
-  {0x1F94D, 0x1F94F},
-  {0x1F950, 0x1F95E},
-  {0x1F95F, 0x1F96B},
-  {0x1F96C, 0x1F970},
-  {0x1F971, 0x1F972},
-  {0x1F973, 0x1F976},
-  {0x1F977, 0x1F979},
-  {0x1F97A, 0x1F97A},
-  {0x1F97B, 0x1F97B},
-  {0x1F97C, 0x1F97F},
-  {0x1F980, 0x1F984},
-  {0x1F985, 0x1F991},
-  {0x1F992, 0x1F997},
-  {0x1F998, 0x1F9A2},
-  {0x1F9A3, 0x1F9AF},
-  {0x1F9B0, 0x1F9B9},
-  {0x1F9BA, 0x1F9BF},
-  {0x1F9C0, 0x1F9C0},
-  {0x1F9C1, 0x1F9C2},
-  {0x1F9C3, 0x1F9CF},
-  {0x1F9D0, 0x1F9E6},
-  {0x1F9E7, 0x1F9FF},
-  {0x1FA00, 0x1FA5F},
-  {0x1FA60, 0x1FA6D},
-  {0x1FA6E, 0x1FFFD},
+  {0x1F90C, 0x1F93A},
+  {0x1F93C, 0x1F945},
+  {0x1F947, 0x1FFFD},
 };
 
 #endif /* HB_UNICODE_EMOJI_TABLE_HH */


More information about the HarfBuzz mailing list