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

Behdad Esfahbod behdad at kemper.freedesktop.org
Fri Oct 1 16:09:38 PDT 2010


 src/hb-open-type-private.hh        |   12 ++++++------
 src/hb-ot-head-private.hh          |    7 +++++++
 src/hb-ot-layout-common-private.hh |    2 +-
 src/hb-ot-layout-gdef-private.hh   |   10 +++++-----
 src/hb-ot-layout-gpos-private.hh   |    6 +++---
 src/hb-ot-layout-private.hh        |    6 +++---
 6 files changed, 25 insertions(+), 18 deletions(-)

New commits:
commit ac0c1663fa6e93a5a94c88fc7497bc11ca17f0a1
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Oct 1 19:09:23 2010 -0400

    Avoid div-by-zero, validate upem

diff --git a/src/hb-ot-head-private.hh b/src/hb-ot-head-private.hh
index a3e87a9..56a5861 100644
--- a/src/hb-ot-head-private.hh
+++ b/src/hb-ot-head-private.hh
@@ -42,12 +42,19 @@ struct head
 {
   static const hb_tag_t Tag	= HB_OT_TAG_head;
 
+  inline unsigned int get_upem (void) const {
+    unsigned int upem = unitsPerEm;
+    /* If no valid head table found, assume 1000, which matches typicaly Type1 usage. */
+    return 16 <= upem && upem <= 16384 ? upem : 1000;
+  }
+
   inline bool sanitize (hb_sanitize_context_t *c) {
     TRACE_SANITIZE ();
     /* Shall we check for magicNumber here?  Who cares? */
     return c->check_struct (this) && likely (version.major == 1);
   }
 
+  private:
   FixedVersion	version;		/* Version of the head table--currently
 					 * 0x00010000 for version 1.0. */
   FixedVersion	fontRevision;		/* Set by font manufacturer. */
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 8e041ba..c1ae99f 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -77,9 +77,9 @@ struct hb_ot_layout_context_t
   } info;
 
   /* Convert from font-space to user-space */
-  /* XXX div-by-zero / speed up */
-  inline hb_position_t scale_x (int16_t v) { return (int64_t) this->font->x_scale * v / this->face->head_table->unitsPerEm; }
-  inline hb_position_t scale_y (int16_t v) { return (int64_t) this->font->y_scale * v / this->face->head_table->unitsPerEm; }
+  /* XXX speed up */
+  inline hb_position_t scale_x (int16_t v) { return (int64_t) this->font->x_scale * v / this->face->head_table->get_upem (); }
+  inline hb_position_t scale_y (int16_t v) { return (int64_t) this->font->y_scale * v / this->face->head_table->get_upem (); }
 };
 
 
commit 7f97d2cd904ea999c099c73c52187c5d65aeec67
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Oct 1 18:58:50 2010 -0400

    Pedantic

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 62a7c88..b83a2e3 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -126,7 +126,7 @@ static const void *_NullPool[64 / sizeof (void *)];
 
 /* Generic nul-content Null objects. */
 template <typename Type>
-static inline const Type& Null () {
+static inline const Type& Null (void) {
   ASSERT_STATIC (Type::min_size <= sizeof (_NullPool));
   return *CastP<Type> (_NullPool);
 }
@@ -135,7 +135,7 @@ static inline const Type& Null () {
 #define DEFINE_NULL_DATA(Type, data) \
 static const char _Null##Type[Type::min_size + 1] = data; /* +1 is for nul-termination in data */ \
 template <> \
-inline const Type& Null<Type> () { \
+inline const Type& Null<Type> (void) { \
   return *CastP<Type> (_Null##Type); \
 } /* The following line really exists such that we end in a place needing semicolon */ \
 ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type))
@@ -373,7 +373,7 @@ class BEInt<Type, 2>
 {
   public:
   inline void set (Type i) { hb_be_uint16_put (v,i); }
-  inline operator Type () const { return hb_be_uint16_get (v); }
+  inline operator Type (void) const { return hb_be_uint16_get (v); }
   inline bool operator == (const BEInt<Type, 2>& o) const { return hb_be_uint16_cmp (v, o.v); }
   inline bool operator != (const BEInt<Type, 2>& o) const { return !(*this == o); }
   private: uint8_t v[2];
@@ -383,7 +383,7 @@ class BEInt<Type, 4>
 {
   public:
   inline void set (Type i) { hb_be_uint32_put (v,i); }
-  inline operator Type () const { return hb_be_uint32_get (v); }
+  inline operator Type (void) const { return hb_be_uint32_get (v); }
   inline bool operator == (const BEInt<Type, 4>& o) const { return hb_be_uint32_cmp (v, o.v); }
   inline bool operator != (const BEInt<Type, 4>& o) const { return !(*this == o); }
   private: uint8_t v[4];
@@ -571,7 +571,7 @@ struct GenericArrayOf
     if (unlikely (i >= len)) return Null(Type);
     return array[i];
   }
-  inline unsigned int get_size () const
+  inline unsigned int get_size (void) const
   { return len.static_size + len * Type::static_size; }
 
   inline bool sanitize (hb_sanitize_context_t *c) {
@@ -677,7 +677,7 @@ struct HeadlessArrayOf
     if (unlikely (i >= len || !i)) return Null(Type);
     return array[i-1];
   }
-  inline unsigned int get_size () const
+  inline unsigned int get_size (void) const
   { return len.static_size + (len ? len - 1 : 0) * Type::static_size; }
 
   inline bool sanitize_shallow (hb_sanitize_context_t *c) {
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index e3adfe8..6ea2d0e 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -566,7 +566,7 @@ struct Device
     return delta;
   }
 
-  inline unsigned int get_size () const
+  inline unsigned int get_size (void) const
   {
     unsigned int f = deltaFormat;
     if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::static_size;
diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh
index 549e4b7..52d528a 100644
--- a/src/hb-ot-layout-gdef-private.hh
+++ b/src/hb-ot-layout-gdef-private.hh
@@ -333,22 +333,22 @@ struct GDEF
     ComponentGlyph	= 4
   };
 
-  inline bool has_glyph_classes () const { return glyphClassDef != 0; }
+  inline bool has_glyph_classes (void) 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 bool has_mark_attachment_types () const { return markAttachClassDef != 0; }
+  inline bool has_mark_attachment_types (void) 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 bool has_attach_points () const { return attachList != 0; }
+  inline bool has_attach_points (void) const { return attachList != 0; }
   inline unsigned int get_attach_points (hb_codepoint_t glyph_id,
 					 unsigned int start_offset,
 					 unsigned int *point_count /* IN/OUT */,
 					 unsigned int *point_array /* OUT */) const
   { return (this+attachList).get_attach_points (glyph_id, start_offset, point_count, point_array); }
 
-  inline bool has_lig_carets () const { return ligCaretList != 0; }
+  inline bool has_lig_carets (void) const { return ligCaretList != 0; }
   inline unsigned int get_lig_carets (hb_ot_layout_context_t *c,
 				      hb_codepoint_t glyph_id,
 				      unsigned int start_offset,
@@ -356,7 +356,7 @@ struct GDEF
 				      int *caret_array /* OUT */) const
   { return (this+ligCaretList).get_lig_carets (c, glyph_id, start_offset, caret_count, caret_array); }
 
-  inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
+  inline bool has_mark_sets (void) const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
   inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
   { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
 
diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 4969997..1860b09 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -84,9 +84,9 @@ struct ValueFormat : USHORT
 					 * PosTable (may be NULL) */
 #endif
 
-  inline unsigned int get_len () const
+  inline unsigned int get_len (void) const
   { return _hb_popcount32 ((unsigned int) *this); }
-  inline unsigned int get_size () const
+  inline unsigned int get_size (void) const
   { return get_len () * Value::static_size; }
 
   void apply_value (hb_ot_layout_context_t       *layout,
@@ -154,7 +154,7 @@ struct ValueFormat : USHORT
 
   public:
 
-  inline bool has_device () const {
+  inline bool has_device (void) const {
     unsigned int format = *this;
     return (format & devices) != 0;
   }



More information about the HarfBuzz mailing list