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

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Nov 19 18:16:54 UTC 2018


 docs/harfbuzz-sections.txt  |    2 ++
 src/hb-buffer.h             |    2 ++
 src/hb-dsalgs.hh            |    6 ++++++
 src/hb-ot-var-fvar-table.hh |   37 ++++++++++++++++++++++---------------
 src/hb-ot-var.cc            |   12 ++++++++++++
 src/hb-ot-var.h             |   15 ++++++++++++++-
 6 files changed, 58 insertions(+), 16 deletions(-)

New commits:
commit 56c9238d3da8c034336cf80ba37e03e33c493718
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 19 13:09:53 2018 -0500

    [fvar] Rewrite sanitize

diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index b4fdd5fa..99d2fd5c 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -101,12 +101,10 @@ struct fvar
     return_trace (version.sanitize (c) &&
 		  likely (version.major == 1) &&
 		  c->check_struct (this) &&
+		  axisSize == 20 && /* Assumed in our code. */
 		  instanceSize >= axisCount * 4 + 4 &&
-		  axisSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */
-		  instanceSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */
-		  c->check_range (this, firstAxis) &&
-		  c->check_range (&StructAtOffset<char> (this, firstAxis),
-				  axisCount * axisSize + instanceCount * instanceSize));
+		  get_axes ().sanitize (c) &&
+		  c->check_range (get_first_instance (), instanceCount, instanceSize));
   }
 
   inline unsigned int get_axis_count (void) const
commit 4a6a692e3ea4fab632a0162c6d513dc151054d8f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 19 13:04:43 2018 -0500

    [fvar] Use hb_array_t for axes

diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 7a207f5d..8e59fdee 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -573,6 +573,10 @@ struct hb_array_t
 
   inline unsigned int get_size (void) const { return len * sizeof (Type); }
 
+  template <typename hb_sanitize_context_t>
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  { return c->check_array (arrayZ, len); }
+
   template <typename T> inline operator  T * (void) const { return arrayZ; }
 
   inline Type * operator & (void) const { return arrayZ; }
@@ -598,6 +602,8 @@ struct hb_array_t
   Type *arrayZ;
   unsigned int len;
 };
+template <typename T>
+hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> (array, len); }
 
 
 struct HbOpOr
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 66618a5a..b4fdd5fa 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -114,9 +114,6 @@ struct fvar
 
   inline bool get_axis (unsigned int index, hb_ot_var_axis_t *info) const
   {
-    if (unlikely (index >= axisCount))
-      return false;
-
     if (info)
     {
       const AxisRecord &axis = get_axes ()[index];
@@ -133,9 +130,6 @@ struct fvar
 
   inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const
   {
-    if (unlikely (index >= axisCount))
-      return (hb_ot_var_axis_flags_t) 0;
-
     const AxisRecord &axis = get_axes ()[index];
     return (hb_ot_var_axis_flags_t) (unsigned int) axis.flags;
   }
@@ -195,11 +189,11 @@ struct fvar
   }
 
   protected:
-  inline const AxisRecord * get_axes (void) const
-  { return &(this+firstAxis); }
+  inline hb_array_t<const AxisRecord> get_axes (void) const
+  { return hb_array (&(this+firstAxis), axisCount); }
 
-  inline const InstanceRecord * get_instances (void) const
-  { return &StructAtOffset<InstanceRecord> (get_axes () + axisCount, 0); }
+  inline const InstanceRecord * get_first_instance (void) const
+  { return &StructAfter<InstanceRecord> (get_axes ()); }
 
   protected:
   FixedVersion<>version;	/* Version of the fvar table
commit e0097396010c40cf62641cd12ceb12dd5d79c9c7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 19 12:53:53 2018 -0500

    [fvar] Minor

diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 3c8a3da4..66618a5a 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -104,8 +104,8 @@ struct fvar
 		  instanceSize >= axisCount * 4 + 4 &&
 		  axisSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */
 		  instanceSize <= 1024 && /* Arbitrary, just to simplify overflow checks. */
-		  c->check_range (this, things) &&
-		  c->check_range (&StructAtOffset<char> (this, things),
+		  c->check_range (this, firstAxis) &&
+		  c->check_range (&StructAtOffset<char> (this, firstAxis),
 				  axisCount * axisSize + instanceCount * instanceSize));
   }
 
@@ -196,7 +196,7 @@ struct fvar
 
   protected:
   inline const AxisRecord * get_axes (void) const
-  { return &StructAtOffset<AxisRecord> (this, things); }
+  { return &(this+firstAxis); }
 
   inline const InstanceRecord * get_instances (void) const
   { return &StructAtOffset<InstanceRecord> (get_axes () + axisCount, 0); }
@@ -204,7 +204,8 @@ struct fvar
   protected:
   FixedVersion<>version;	/* Version of the fvar table
 				 * initially set to 0x00010000u */
-  Offset16	things;		/* Offset in bytes from the beginning of the table
+  OffsetTo<AxisRecord>
+		firstAxis;	/* Offset in bytes from the beginning of the table
 				 * to the start of the AxisRecord array. */
   HBUINT16	reserved;	/* This field is permanently reserved. Set to 2. */
   HBUINT16	axisCount;	/* The number of variation axes in the font (the
commit 1a2eb108b857de9c5e84cc5de0c12c7657e04498
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 19 12:36:56 2018 -0500

    [ot-var] Add hb_ot_var_axis_get_flags()
    
    Part of https://github.com/harfbuzz/harfbuzz/issues/1241
    
    New API:
    +hb_ot_var_axis_flags_t
    +hb_ot_var_axis_get_flags

diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 6a498e94..63594cfc 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -587,6 +587,8 @@ 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_normalize_variations
 hb_ot_var_normalize_coords
 </SECTION>
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index 99e01716..f989d25d 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -90,6 +90,8 @@ typedef struct hb_glyph_info_t
  * 				   the reshaping to a small piece around the
  * 				   breaking point only.
  * @HB_GLYPH_FLAG_DEFINED: All the currently defined flags.
+ *
+ * Since: 1.5.0
  */
 typedef enum { /*< flags >*/
   HB_GLYPH_FLAG_UNSAFE_TO_BREAK		= 0x00000001,
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 659eb1b6..3c8a3da4 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -131,6 +131,15 @@ struct fvar
     return true;
   }
 
+  inline hb_ot_var_axis_flags_t get_axis_flags (unsigned int index) const
+  {
+    if (unlikely (index >= axisCount))
+      return (hb_ot_var_axis_flags_t) 0;
+
+    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 c97e9c49..14c73cfd 100644
--- a/src/hb-ot-var.cc
+++ b/src/hb-ot-var.cc
@@ -104,6 +104,18 @@ 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);
+}
+
 
 /**
  * hb_ot_var_normalize_variations:
diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index 0c0f61dd..d535a078 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -85,6 +85,19 @@ hb_ot_var_find_axis (hb_face_t        *face,
 		     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.
+ *
+ * Since: REPLACEME
+ */
+typedef enum { /*< flags >*/
+  HB_OT_VAR_AXIS_FLAG_HIDDEN	= 0x0001u,
+} 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);
 
 HB_EXTERN void
 hb_ot_var_normalize_variations (hb_face_t            *face,
commit bd6b2ba1d3910cc259db7abeb6c9bd7ed9494857
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 19 11:34:56 2018 -0500

    [ot-var] Add flags
    
    Unfortunate that we don't have room in hb_ot_var_axis_t to expose flags :(.

diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 6d229c38..659eb1b6 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -52,7 +52,7 @@ struct InstanceRecord
   protected:
   NameID	subfamilyNameID;/* The name ID for entries in the 'name' table
 				 * that provide subfamily names for this instance. */
-  HBUINT16	reserved;	/* Reserved for future use — set to 0. */
+  HBUINT16	flags;		/* Reserved for future use — set to 0. */
   UnsizedArrayOf<Fixed>
 		coordinatesZ;	/* The coordinates array for this instance. */
   //NameID	postScriptNameIDX;/*Optional. The name ID for entries in the 'name'
@@ -65,6 +65,11 @@ struct InstanceRecord
 
 struct AxisRecord
 {
+  enum
+  {
+    AXIS_FLAG_HIDDEN	= 0x0001,
+  };
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
@@ -76,7 +81,7 @@ struct AxisRecord
   Fixed		minValue;	/* The minimum coordinate value for the axis. */
   Fixed		defaultValue;	/* The default coordinate value for the axis. */
   Fixed		maxValue;	/* The maximum coordinate value for the axis. */
-  HBUINT16	reserved;	/* Reserved for future use — set to 0. */
+  HBUINT16	flags;		/* Axis flags. */
   NameID	axisNameID;	/* The name ID for entries in the 'name' table that
 				 * provide a display name for this axis. */
 
commit c076c7b85ce4d069ae8b2b04143aca4c4f052ae9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Nov 19 11:30:40 2018 -0500

    [ot-var] Use hb_ot_name_id_t

diff --git a/src/hb-ot-var.h b/src/hb-ot-var.h
index a2c0c5f2..0c0f61dd 100644
--- a/src/hb-ot-var.h
+++ b/src/hb-ot-var.h
@@ -54,7 +54,7 @@ HB_BEGIN_DECLS
  */
 typedef struct hb_ot_var_axis_t {
   hb_tag_t tag;
-  unsigned int name_id;
+  hb_ot_name_id_t name_id;
   float min_value;
   float default_value;
   float max_value;


More information about the HarfBuzz mailing list