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

2018-11-27 Thread Behdad Esfahbod
 .codecov.yml |7 +++
 src/hb-machinery.hh  |6 ++
 test/shaping/data/in-house/tests/macos.tests |3 +--
 3 files changed, 14 insertions(+), 2 deletions(-)

New commits:
commit 987f4187722a05e3f360b85c66309a351fc5d6ad
Merge: 1042d9fb 4e2a03b6
Author: Behdad Esfahbod 
Date:   Tue Nov 27 17:40:32 2018 -0500

Merge pull request #1398 from Adenilson/bigInt01

Optimize harfbuzz big integer conversions

commit 4e2a03b6b6e0c0d1c4edea10dc1aae63eeb6c581
Author: Behdad Esfahbod 
Date:   Tue Nov 27 17:40:09 2018 -0500

Comment

diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index c3848415..0e75c824 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -692,8 +692,10 @@ struct BEInt
   inline operator Type (void) const
   {
 #if defined(__GNUC__) || defined(__clang__)
+/* Spoon-feed the compiler a big-endian integer with alignment 1.
+ * https://github.com/harfbuzz/harfbuzz/pull/1398 */
 struct __attribute__((packed)) packed_uint16_t { uint16_t v; };
-return __builtin_bswap16(((packed_uint16_t *) this)->v);
+return __builtin_bswap16 (((packed_uint16_t *) this)->v);
 #endif
 return (v[0] <<  8)
  + (v[1]  );
commit 4a719a7f4c997ea7e47588bc0288c97706dae015
Author: Adenilson Cavalcanti 
Date:   Tue Nov 20 14:41:19 2018 -0800

Optimize harfbuzz big integer conversions

Profiling showed that type conversions were adding considerable cycles in 
time
spent doing text shaping.

The idea is to optimize it using native processor instructions to help Blink
layout performance.

Doing further investigation revelead that compilers may not use the
proper instruction on ARM 32bits builds (i.e. REV16).

One way to insure that the generated ASM was ideal for both gcc/clang
was using __builtin_bswap16.

Added bonus is that we no longer need to test for CPU architecture.

diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 3c11243f..c3848415 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -691,6 +691,10 @@ struct BEInt
   }
   inline operator Type (void) const
   {
+#if defined(__GNUC__) || defined(__clang__)
+struct __attribute__((packed)) packed_uint16_t { uint16_t v; };
+return __builtin_bswap16(((packed_uint16_t *) this)->v);
+#endif
 return (v[0] <<  8)
  + (v[1]  );
   }
commit 1042d9fbc05aff9d51f15c2824a8521e963d0acd
Author: Ebrahim Byagowi 
Date:   Mon Nov 26 18:58:39 2018 +0330

[ci] Add .codecov.yml

Similar to 
https://github.com/GoogleChrome/lighthouse/blob/master/.codecov.yml

No strong preference on commenting, feel free to enable it again

diff --git a/.codecov.yml b/.codecov.yml
new file mode 100644
index ..e9b8ab48
--- /dev/null
+++ b/.codecov.yml
@@ -0,0 +1,7 @@
+comment: off
+
+coverage:
+  status:
+project:
+  default:
+threshold: 1%
commit 97eaedca5de76c74534bab41562aee130098558a
Author: Ebrahim Byagowi 
Date:   Mon Nov 26 16:58:58 2018 +0330

[test][aat] Enable Tamil MN test (#1414)

diff --git a/test/shaping/data/in-house/tests/macos.tests 
b/test/shaping/data/in-house/tests/macos.tests
index 05dafd19..9f1f9fa1 100644
--- a/test/shaping/data/in-house/tests/macos.tests
+++ b/test/shaping/data/in-house/tests/macos.tests
@@ -18,8 +18,7 @@
 
/System/Library/Fonts/LucidaGrande.ttc@63ba1b1de4709bd832ca76bd62368dd99fc34269::U+006D,U+0300:[mgrave=0+1912]
 
/System/Library/Fonts/Times.ttc@896098b6979306ad84355025459f7c68b029139c::U+0066,U+0069:[fi=0+1139]
 /Library/Fonts/Khmer 
MN.ttc@782ba6cf3fca0512ab348dfe08345a2d5dc5bf2c::U+17A2,U+1780,U+17D2,U+179F,U+179A,U+1781,U+17D2,U+1798,U+17C2,U+179A:[km_qa=0+1025|km_ka=1+1025|km_sa.sub=1+517|km_ro=4+593|km_vs_ae=5+605|km_kha=5+1025|km_mo.sub=5+0|km_ro=9+593]
-# The following is broken https://github.com/harfbuzz/harfbuzz/issues/1410
-#/Library/Fonts/Tamil 
MN.ttc@3de37f3f8f3cb6015b093fbd6e9d323daaf6fb1d::U+0BA4,U+0BCA,U+0B95,U+0BC1,U+0B95,U+0BCD,U+0B95,U+0BAA,U+0BCD,U+0BAA,U+0B9F,U+0BCD,U+0B9F,U+0BC1:[tgm_e=0+1702|tgc_ta=0+1598|tgm_aa=0+1149|tgc_ku=2+1962|tgc_k=4+1592|tgc_ka=6+1592|tgc_p=7+1370|tgc_pa=9+1370|tgc_tt=10+1596|tgc_ttu=12+1833]
+/Library/Fonts/Tamil 
MN.ttc@3de37f3f8f3cb6015b093fbd6e9d323daaf6fb1d::U+0BA4,U+0BCA,U+0B95,U+0BC1,U+0B95,U+0BCD,U+0B95,U+0BAA,U+0BCD,U+0BAA,U+0B9F,U+0BCD,U+0B9F,U+0BC1:[tgm_e=0+1702|tgc_ta=0+1598|tgm_aa=0+1149|tgc_ku=2+1962|tgc_k=4+1592|tgc_ka=6+1592|tgc_p=7+1370|tgc_pa=9+1370|tgc_tt=10+1596|tgc_ttu=12+1833]
 
/System/Library/Fonts/Times.ttc@896098b6979306ad84355025459f7c68b029139c::U+0041,U+0066,U+0300,U+0066,U+0069,U+005A:[A=0+1479|f=1+682|gravecmb=1@-480,588+0|fi=3+1139|Z=5+1251]
 
/System/Library/Fonts/LucidaGrande.ttc@63ba1b1de4709bd832ca76bd62368dd99fc34269::U+05E1,U+05B0:[shevahebrew=0@-7,0+0|samekhhebrew=0+1361]
 /Library/Fonts/Apple 

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

2018-11-12 Thread Behdad Esfahbod
 src/Makefile.am |   31 -
 src/hb-aat-layout-common.hh |8 +--
 src/hb-aat-layout-kerx-table.hh |8 +++
 src/hb-machinery.hh |   42 
 src/hb-open-type.hh |4 ++-
 src/hb-ot-layout-common.hh  |5 ++--
 src/hb-ot-layout-gpos-table.hh  |   11 +++---
 src/hb-ot-var-hvar-table.hh |4 ++-
 src/hb-ot-var-mvar-table.hh |4 ++-
 test/fuzzing/Makefile.am|   39 -
 10 files changed, 73 insertions(+), 83 deletions(-)

New commits:
commit 274f4c726f461f49f54a79557d63bf95d22903cf
Author: Behdad Esfahbod 
Date:   Mon Nov 12 14:24:36 2018 -0500

Rename check_array2() to check_array()

diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index 6e9f3007..f075a270 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -267,7 +267,7 @@ struct KerxSubTableFormat1
unsigned int kern_idx = Format1EntryT::kernActionIndex (entry);
kern_idx = Types::offsetToIndex (kern_idx, >machine, 
kernAction.arrayZ);
const FWORD *actions = [kern_idx];
-   if (!c->sanitizer.check_array2 (actions, depth, tuple_count))
+   if (!c->sanitizer.check_array (actions, depth, tuple_count))
{
  depth = 0;
  return false;
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index fa2c7b3a..ce6c9453 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -343,11 +343,11 @@ struct hb_sanitize_context_t :
   }
 
   template 
-  inline bool check_array2 (const T *base,
-   unsigned int a,
-   unsigned int b) const
+  inline bool check_array (const T *base,
+  unsigned int a,
+  unsigned int b) const
   {
-return this->check_range (base, a * b, T::static_size);
+return this->check_range (base, a, b, T::static_size);
   }
 
   template 
commit e014405a214bceff3a1ce80f0b98273c44078e82
Author: Behdad Esfahbod 
Date:   Mon Nov 12 14:23:31 2018 -0500

Rename check_array(array, a, b) to check_range()

diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 8191df4c..adc7538c 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -557,7 +557,9 @@ struct StateTable
/* Negative states. */
if (unlikely (hb_unsigned_mul_overflows (min_state, num_classes)))
  return_trace (false);
-   if (unlikely (!c->check_array ([min_state * num_classes], 
-min_state, row_stride)))
+   if (unlikely (!c->check_range ([min_state * num_classes],
+  -min_state,
+  row_stride)))
  return_trace (false);
if ((c->max_ops -= state_neg - min_state) < 0)
  return_trace (false);
@@ -574,7 +576,9 @@ struct StateTable
   if (state_pos <= max_state)
   {
/* Positive states. */
-   if (unlikely (!c->check_array (states, max_state + 1, row_stride)))
+   if (unlikely (!c->check_range (states,
+  max_state + 1,
+  row_stride)))
  return_trace (false);
if ((c->max_ops -= max_state - state_pos + 1) < 0)
  return_trace (false);
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 6155c012..fa2c7b3a 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -317,22 +317,37 @@ struct hb_sanitize_context_t :
   }
 
   template 
+  inline bool check_range (const T *base,
+  unsigned int a,
+  unsigned int b) const
+  {
+return !hb_unsigned_mul_overflows (a, b) &&
+  this->check_range (base, a * b);
+  }
+
+  template 
+  inline bool check_range (const T *base,
+  unsigned int a,
+  unsigned int b,
+  unsigned int c) const
+  {
+return !hb_unsigned_mul_overflows (a, b) &&
+  this->check_range (base, a * b, c);
+  }
+
+  template 
   inline bool check_array (const T *base,
-  unsigned int len,
-  unsigned int record_size = T::static_size) const
+  unsigned int len) const
   {
-return !hb_unsigned_mul_overflows (len, record_size) &&
-  this->check_range (base, len * record_size);
+return this->check_range (base, len, T::static_size);
   }
 
   template 
   inline bool check_array2 (const T *base,
unsigned int a,
-   unsigned int b,
-   unsigned int record_size = T::static_size) const
+   unsigned int b) const
   {
-return !hb_unsigned_mul_overflows (a, b) &&
-  this->check_array (base, a * b, record_size);
+return this->check_range (base, a * b, 

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

2018-11-10 Thread Behdad Esfahbod
 src/hb-blob.cc   |   12 
 src/hb-blob.hh   |1 -
 src/hb-font.cc   |2 +-
 src/hb-shape-plan.cc |   30 +++---
 src/hb-shape-plan.hh |3 +--
 5 files changed, 5 insertions(+), 43 deletions(-)

New commits:
commit 925b7a214f06b83b6f2278052656dabc4ebdd6b7
Author: Behdad Esfahbod 
Date:   Sun Nov 11 00:17:30 2018 -0500

Comment

diff --git a/src/hb-font.cc b/src/hb-font.cc
index b24995b1..ca710a6f 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1306,7 +1306,7 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
   0, /* num_coords */
   nullptr, /* coords */
 
-  const_cast (&_hb_Null_hb_font_funcs_t), /* klass */
+  const_cast (&_hb_Null_hb_font_funcs_t),
   nullptr, /* user_data */
   nullptr, /* destroy */
 
commit dcb63868333ba8e229fd8756377151440dd9fd23
Author: Behdad Esfahbod 
Date:   Sun Nov 11 00:16:17 2018 -0500

[shape-plan] Remove use of custom null object

diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index 644c1b6b..8fcc038f 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -103,30 +103,6 @@ hb_shape_plan_plan (hb_shape_plan_t*shape_plan,
  * hb_shape_plan_t
  */
 
-DEFINE_NULL_INSTANCE (hb_shape_plan_t) =
-{
-  HB_OBJECT_HEADER_STATIC,
-
-  nullptr, /* face */
-  false, /* custom_shaper_list */
-  HB_SEGMENT_PROPERTIES_DEFAULT, /* props */
-
-  nullptr, /* shaper_func */
-  nullptr, /* shaper_name */
-
-  nullptr, /* user_features */
-  0,/* num_user_featurs */
-
-  nullptr, /* coords */
-  0,/* num_coords */
-
-  {
-#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT 
(HB_SHAPER_DATA_INVALID),
-#include "hb-shaper-list.hh"
-#undef HB_SHAPER_IMPLEMENT
-  },
-};
-
 
 /**
  * hb_shape_plan_create: (Xconstructor)
diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh
index fea3e10c..891b9957 100644
--- a/src/hb-shape-plan.hh
+++ b/src/hb-shape-plan.hh
@@ -50,7 +50,6 @@ struct hb_shape_plan_t
 
   struct hb_shaper_data_t shaper_data;
 };
-DECLARE_NULL_INSTANCE (hb_shape_plan_t);
 
 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \
, const hb_feature_t *user_features \
commit 109891d49876de4de14a91adefbdf681c2b9acc2
Author: Behdad Esfahbod 
Date:   Sun Nov 11 00:15:08 2018 -0500

[shape-plan] Make null object all zeros

To remove custom null object next..

diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index f2f21019..644c1b6b 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -107,8 +107,8 @@ DEFINE_NULL_INSTANCE (hb_shape_plan_t) =
 {
   HB_OBJECT_HEADER_STATIC,
 
-  true, /* default_shaper_list */
   nullptr, /* face */
+  false, /* custom_shaper_list */
   HB_SEGMENT_PROPERTIES_DEFAULT, /* props */
 
   nullptr, /* shaper_func */
@@ -196,7 +196,7 @@ hb_shape_plan_create2 (hb_face_t *face,
   assert (props->direction != HB_DIRECTION_INVALID);
 
   hb_face_make_immutable (face);
-  shape_plan->default_shaper_list = !shaper_list;
+  shape_plan->custom_shaper_list = shaper_list;
   shape_plan->face_unsafe = face;
   shape_plan->props = *props;
   shape_plan->num_user_features = num_user_features;
@@ -382,7 +382,7 @@ static unsigned int
 hb_shape_plan_hash (const hb_shape_plan_t *shape_plan)
 {
   return hb_segment_properties_hash (_plan->props) +
-shape_plan->default_shaper_list ? 0 : (intptr_t) 
shape_plan->shaper_func;
+shape_plan->custom_shaper_list ? (intptr_t) shape_plan->shaper_func : 
0;
 }
 #endif
 
@@ -436,7 +436,7 @@ hb_shape_plan_matches (const hb_shape_plan_t  
*shape_plan,
   return hb_segment_properties_equal (_plan->props, >props) &&
 hb_shape_plan_user_features_match (shape_plan, proposal) &&
 hb_shape_plan_coords_match (shape_plan, proposal) &&
-((shape_plan->default_shaper_list && !proposal->shaper_list) ||
+((!shape_plan->custom_shaper_list && !proposal->shaper_list) ||
  (shape_plan->shaper_func == proposal->shaper_func));
 }
 
diff --git a/src/hb-shape-plan.hh b/src/hb-shape-plan.hh
index 403c3ebd..fea3e10c 100644
--- a/src/hb-shape-plan.hh
+++ b/src/hb-shape-plan.hh
@@ -35,8 +35,8 @@ struct hb_shape_plan_t
 {
   hb_object_header_t header;
 
-  hb_bool_t default_shaper_list;
   hb_face_t *face_unsafe; /* We don't carry a reference to face. */
+  bool custom_shaper_list;
   hb_segment_properties_t props;
 
   hb_shape_func_t *shaper_func;
commit 34185ff3bc7ece5620145fc05da07c79da950f34
Author: Behdad Esfahbod 
Date:   Sun Nov 11 00:12:30 2018 -0500

[blob] Use default null object

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index efca833e..26c0d143 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -53,18 +53,6 @@
  **/
 
 
-DEFINE_NULL_INSTANCE (hb_blob_t) =
-{
-  HB_OBJECT_HEADER_STATIC,
-
-  nullptr, /* data */
-  0, /* length */
-  HB_MEMORY_MODE_DUPLICATE, /* mode */
-
-  nullptr, /* user_data */
-  nullptr  /* destroy */
-};
-
 /**
  * hb_blob_create: (skip)
  * @data: Pointer to blob data.
diff --git a/src/hb-blob.hh b/src/hb-blob.hh
index 

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

2018-11-09 Thread Behdad Esfahbod
 src/hb-dsalgs.hh   
|   15 +++-
 src/hb-ot-glyf-table.hh
|2 
 src/hb-ot-post-table.hh
|   34 --
 
test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968
 |binary
 4 files changed, 27 insertions(+), 24 deletions(-)

New commits:
commit 3a9fa8c026bf28bf87e20ec95327f74fd7070b74
Author: Behdad Esfahbod 
Date:   Sat Nov 10 01:56:37 2018 -0500

[qsort] Fix O(N^2) behavior if all array elements are the same

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11327

Reported as https://github.com/noporpoise/sort_r/issues/7

diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 9ccd7f25..ffa43870 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -356,7 +356,12 @@ hb_bsearch_r (const void *key, const void *base,
 }
 
 
-/* From https://github.com/noporpoise/sort_r */
+/* From https://github.com/noporpoise/sort_r
+ * With following modifications:
+ *
+ * 10 November 2018:
+ * https://github.com/noporpoise/sort_r/issues/7
+ */
 
 /* Isaac Turner 29 April 2014 Public Domain */
 
@@ -412,7 +417,7 @@ static inline void sort_r_simple(void *base, size_t nel, 
size_t w,
 
 /* Use median of first, middle and last items as pivot */
 char *x, *y, *xend, ch;
-char *pl, *pr;
+char *pl, *pm, *pr;
 char *last = b+w*(nel-1), *tmp;
 char *l[3];
 l[0] = b;
@@ -434,13 +439,15 @@ static inline void sort_r_simple(void *base, size_t nel, 
size_t w,
 pr = last;
 
 while(pl < pr) {
-  for(; pl < pr; pl += w) {
+  pm = pl+((pr-pl+1)>>1);
+  for(; pl < pm; pl += w) {
 if(sort_r_cmpswap(pl, pr, w, compar, arg)) {
   pr -= w; /* pivot now at pl */
   break;
 }
   }
-  for(; pl < pr; pr -= w) {
+  pm = pl+((pr-pl)>>1);
+  for(; pm < pr; pr -= w) {
 if(sort_r_cmpswap(pl, pr, w, compar, arg)) {
   pl += w; /* pivot now at pr */
   break;
diff --git 
a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968
 
b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968
new file mode 100644
index ..c63bcc58
Binary files /dev/null and 
b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968
 differ
commit b308aaccf0773e252880b9b887f3d3d1dec00168
Author: Behdad Esfahbod 
Date:   Sat Nov 10 00:37:17 2018 -0500

[post] Minor

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index bbde8d83..77eef3f5 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -77,11 +77,11 @@ struct post
   {
 unsigned int post_prime_length;
 hb_blob_t *post_blob = 
hb_sanitize_context_t().reference_table(plan->source);
-hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, 
post::static_size);
+hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, 
post::min_size);
 post *post_prime = (post *) hb_blob_get_data_writable (post_prime_blob, 
_prime_length);
 hb_blob_destroy (post_blob);
 
-if (unlikely (!post_prime || post_prime_length != post::static_size))
+if (unlikely (!post_prime || post_prime_length != post::min_size))
 {
   hb_blob_destroy (post_prime_blob);
   DEBUG_MSG(SUBSET, nullptr, "Invalid source post table with length %d.", 
post_prime_length);
@@ -109,7 +109,7 @@ struct post
   if (version != 0x0002)
 return;
 
-  const postV2Tail  = StructAfter (*table);
+  const postV2Tail  = table->v2;
 
   glyphNameIndex = 
   pool =  (v2.glyphNameIndex);
@@ -255,14 +255,10 @@ struct post
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
 TRACE_SANITIZE (this);
-if (unlikely (!c->check_struct (this)))
-  return_trace (false);
-if (version.to_int () == 0x0002)
-{
-  const postV2Tail  = StructAfter (*this);
-  return_trace (v2.sanitize (c));
-}
-return_trace (true);
+return_trace (likely (c->check_struct (this) &&
+ (version.to_int () == 0x0001 ||
+  (version.to_int () == 0x0002 && v2.sanitize (c)) 
||
+  version.to_int () == 0x0003)));
   }
 
   public:
@@ -297,8 +293,8 @@ struct post
 * is downloaded as a Type 1 font. */
   HBUINT32 maxMemType1;/* Maximum memory usage when an 
OpenType font
 * is downloaded as a Type 1 font. */
-/*postV2Tail   v2[VAR];*/
-  DEFINE_SIZE_STATIC (32);
+  postV2Tail   v2;
+  DEFINE_SIZE_MIN (32);
 };
 
 struct post_accelerator_t : post::accelerator_t {};
commit 4111c3b8cd1b1c44f722877614ec1ee25111e78c
Author: Behdad Esfahbod 
Date:   Sat Nov 10 00:26:36 2018 -0500

[post] Move sanitize close to data fields

diff 

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

2018-11-08 Thread Behdad Esfahbod
 .circleci/config.yml   |1 
 src/Makefile.sources   |1 
 src/hb-aat-layout-common.hh|   57 +
 src/hb-aat-layout-just-table.hh|  417 +
 src/hb-aat-layout-trak-table.hh|   12 
 src/hb-aat-layout.cc   |1 
 src/hb-open-type.hh|   11 
 test/shaping/data/text-rendering-tests/DISABLED|1 
 test/shaping/data/text-rendering-tests/Makefile.sources|2 
 test/shaping/data/text-rendering-tests/tests/MORX-31.tests |   16 
 10 files changed, 504 insertions(+), 15 deletions(-)

New commits:
commit 9fae611740f514e5fc101a18c4551a20b4a47b59
Author: Behdad Esfahbod 
Date:   Thu Nov 8 12:17:09 2018 -0500

[test/text-rendering-tests] Update from upstream

diff --git a/test/shaping/data/text-rendering-tests/DISABLED 
b/test/shaping/data/text-rendering-tests/DISABLED
index ef987a4d..b0719043 100644
--- a/test/shaping/data/text-rendering-tests/DISABLED
+++ b/test/shaping/data/text-rendering-tests/DISABLED
@@ -1,3 +1,4 @@
+tests/MORX-31.tests
 tests/MORX-41.tests
 
 # Non-Unicode cmap
diff --git a/test/shaping/data/text-rendering-tests/Makefile.sources 
b/test/shaping/data/text-rendering-tests/Makefile.sources
index 136a14d3..052a6123 100644
--- a/test/shaping/data/text-rendering-tests/Makefile.sources
+++ b/test/shaping/data/text-rendering-tests/Makefile.sources
@@ -51,7 +51,6 @@ TESTS = \
tests/MORX-29.tests \
tests/MORX-2.tests \
tests/MORX-30.tests \
-   tests/MORX-31.tests \
tests/MORX-32.tests \
tests/MORX-33.tests \
tests/MORX-34.tests \
@@ -74,6 +73,7 @@ TESTS = \
 
 DISBALED_TESTS = \
tests/CMAP-3.tests \
+   tests/MORX-31.tests \
tests/MORX-41.tests \
tests/SHARAN-1.tests \
tests/SHBALI-1.tests \
diff --git a/test/shaping/data/text-rendering-tests/tests/MORX-31.tests 
b/test/shaping/data/text-rendering-tests/tests/MORX-31.tests
index 6cc40b6e..ac09e27b 100644
--- a/test/shaping/data/text-rendering-tests/tests/MORX-31.tests
+++ b/test/shaping/data/text-rendering-tests/tests/MORX-31.tests
@@ -1,8 +1,8 @@
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0041,U+005A,U+005A:[X|X@364,0|I@728,0|N@1558,0|S@2388,0|A@3218,0|Y@4048,0|Y@4380,0|A@4712,0|Z@5542,0|Z@5864,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0042,U+0059,U+0059:[X|X@364,0|A@728,0|I@1558,0|N@2388,0|S@3218,0|Y@4048,0|Y@4380,0|B@4712,0|Y@5542,0|Y@5874,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+0058,U+0058,U+0042,U+0059,U+0059,U+0041,U+005A,U+005A:[X|X@364,0|I@728,0|N@1558,0|S@2388,0|B@3218,0|Y@4048,0|Y@4380,0|A@4712,0|Z@5542,0|Z@5864,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+0058,U+0058,U+0042,U+0059,U+0059,U+0042,U+005A,U+005A:[X|X@364,0|B@728,0|I@1558,0|N@2388,0|S@3218,0|Y@4048,0|Y@4380,0|B@4712,0|Z@5542,0|Z@5864,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0041,U+0058,U+0059,U+005A,U+0041:[I|N@830,0|S@1660,0|M@2490,0|P@3320,0|Q@3653,0|R@4019,0|I@4370,0|N@5200,0|S@6030,0|A@6860,0|X@7690,0|Y@8054,0|Z@8386,0|A@8708,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0041,U+0058,U+0059,U+005A,U+0042:[I|N@830,0|S@1660,0|M@2490,0|P@3320,0|Q@3653,0|R@4019,0|A@4370,0|I@5200,0|N@6030,0|S@6860,0|X@7690,0|Y@8054,0|Z@8386,0|B@8708,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0042,U+0058,U+0059,U+005A,U+0041:[M|I@830,0|N@1660,0|S@2490,0|P@3320,0|Q@3653,0|R@4019,0|I@4370,0|N@5200,0|S@6030,0|B@6860,0|X@7690,0|Y@8054,0|Z@8386,0|A@8708,0]
-../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0042,U+0058,U+0059,U+005A,U+0042:[M|I@830,0|N@1660,0|S@2490,0|P@3320,0|Q@3653,0|R@4019,0|B@4370,0|I@5200,0|N@6030,0|S@6860,0|X@7690,0|Y@8054,0|Z@8386,0|B@8708,0]
+../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 
--font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0041,U+005A,U+005A:[I|N@830,0|I@1660,0|N@2490,0|S@3320,0|S@4150,0|X@4980,0|X@5344,0|A@5708,0|Y@6538,0|Y@6870,0|A@7202,0|Z@8032,0|Z@8354,0]
+../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned 
--remove-default-ignorables 

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

2018-11-07 Thread Behdad Esfahbod
 src/hb-ft.cc|6 +++---
 src/hb-ot-post-table.hh |   15 ++-
 2 files changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 9d5027696e418b7c2a5ccbc18faafe6b9290d08b
Author: Behdad Esfahbod 
Date:   Wed Nov 7 09:16:53 2018 -0500

[post] Return true on truncation

Client can check that buffer was completely filled out and reallocate.

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index b29096f1..18f9976b 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -148,10 +148,9 @@ struct post
 return false;
   if (!buf_len)
return true;
-  if (buf_len <= s.len) /* What to do with truncation? Returning false for 
now. */
-return false;
-  strncpy (buf, s.arrayZ, s.len);
-  buf[s.len] = '\0';
+  unsigned int len = MIN (buf_len - 1, s.len);
+  strncpy (buf, s.arrayZ, len);
+  buf[len] = '\0';
   return true;
 }
 
commit 7d91f07edf29c4923716af6cee8eb94f948ac91f
Author: Behdad Esfahbod 
Date:   Wed Nov 7 09:14:42 2018 -0500

[post] Protect against huge empty tables

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 00bd1bcb..b29096f1 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -128,7 +128,9 @@ struct post
   pool =  (v2.glyphNameIndex);
 
   const uint8_t *end = (uint8_t *) table + table_length;
-  for (const uint8_t *data = pool; data < end && data + *data < end; data 
+= 1 + *data)
+  for (const uint8_t *data = pool;
+  index_to_offset.len < 65535 && data < end && data + *data < end;
+  data += 1 + *data)
index_to_offset.push (data - pool);
 }
 inline void fini (void)
commit 5ed816ab5900ac4ff7feca3d98cbd92e62fd1754
Author: Behdad Esfahbod 
Date:   Wed Nov 7 09:13:51 2018 -0500

[post] Minor

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 1772a10c..00bd1bcb 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -49,12 +49,15 @@ namespace OT {
 
 struct postV2Tail
 {
+  friend struct post;
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
 TRACE_SANITIZE (this);
 return_trace (glyphNameIndex.sanitize (c));
   }
 
+  protected:
   ArrayOfglyphNameIndex; /* This is not an offset, but is the
 * ordinal number of the glyph in 'post'
 * string tables. */
@@ -62,6 +65,7 @@ struct postV2Tail
namesX; /* Glyph names with length bytes 
[variable]
 * (a Pascal string). */
 
+  public:
   DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
 };
 
commit 64f0becd89cc2b0136c7dc1609abc9f957525cf8
Author: Behdad Esfahbod 
Date:   Wed Nov 7 09:10:55 2018 -0500

[post] Fix bound checking

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index b15a459b..1772a10c 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -124,7 +124,7 @@ struct post
   pool =  (v2.glyphNameIndex);
 
   const uint8_t *end = (uint8_t *) table + table_length;
-  for (const uint8_t *data = pool; data < end && data + *data <= end; data 
+= 1 + *data)
+  for (const uint8_t *data = pool; data < end && data + *data < end; data 
+= 1 + *data)
index_to_offset.push (data - pool);
 }
 inline void fini (void)
commit 7ec694ddf25a313483044256f7ed88b644432e15
Author: HinTak 
Date:   Wed Nov 7 13:19:36 2018 +

Use non-GRID-fitted values for metrics (#1363)

* Use non-GRID-fitted values for metrics

See freetype/src/base/ftobjs.c:ft_recompute_scaled_metrics() and
the usage of GRID_FIT_METRICS inside.

Fixes https://github.com/behdad/harfbuzz/issues/1262

* Update hb-ft.cc

diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 8b80b960..9b9d787d 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -466,9 +466,9 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED,
   const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
   hb_lock_t lock (ft_font->lock);
   FT_Face ft_face = ft_font->ft_face;
-  metrics->ascender = ft_face->size->metrics.ascender;
-  metrics->descender = ft_face->size->metrics.descender;
-  metrics->line_gap = ft_face->size->metrics.height - 
(ft_face->size->metrics.ascender - ft_face->size->metrics.descender);
+  metrics->ascender = FT_MulFix(ft_face->ascender, 
ft_face->size->metrics.y_scale);
+  metrics->descender = FT_MulFix(ft_face->descender, 
ft_face->size->metrics.y_scale);
+  metrics->line_gap = FT_MulFix( ft_face->height, 
ft_face->size->metrics.y_scale ) - (metrics->ascender - metrics->descender);
   if (font->y_scale < 0)
   {
 metrics->ascender = -metrics->ascender;
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2018-11-03 Thread Behdad Esfahbod
 src/hb-blob.cc 
|   12 
 src/hb-blob.hh 
|2 
 src/hb-face.cc 
|   16 
 src/hb-face.hh 
|2 
 src/hb-font.cc 
|   46 
 src/hb-font.hh 
|4 
 src/hb-ft.cc   
|2 
 src/hb-object.hh   
|   19 
 src/hb-ot-kern-table.hh
|6 
 src/hb-ot-layout-base-table.hh 
|  610 --
 src/hb-ot-layout.cc
|   65 +
 src/hb-ot-layout.h 
|   16 
 src/hb-unicode.cc  
|   11 
 src/hb-unicode.hh  
|2 
 test/api/Makefile.am   
|1 
 test/api/fonts/base.ttf
|binary
 test/api/test-baseline.c   
|   58 
 
test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5735679418433536
 |binary
 18 files changed, 437 insertions(+), 435 deletions(-)

New commits:
commit 0589787ff55bff9bd5849c4443229e926cc574a5
Author: Behdad Esfahbod 
Date:   Sat Nov 3 14:58:54 2018 -0400

[kern] Fix access violation in Format3

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11245

diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 9f8a0115..28ea9526 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -417,7 +417,11 @@ struct KernSubTableFormat3
 hb_array_t rightClass = StructAfter > (leftClass).as_array (glyphCount);
 hb_array_t kernIndex = StructAfter > (rightClass).as_array (leftClassCount * 
rightClassCount);
 
-unsigned int i = leftClass[left] * rightClassCount + rightClass[right];
+unsigned int leftC = leftClass[left];
+unsigned int rightC = rightClass[right];
+if (unlikely (leftC >= leftClassCount || rightC >= rightClassCount))
+  return 0;
+unsigned int i = leftC * rightClassCount + rightC;
 return kernValue[kernIndex[i]];
   }
 
commit 5570c87f21f061cc197e02bd0526ab44c63ed6f1
Author: Behdad Esfahbod 
Date:   Sat Nov 3 14:51:38 2018 -0400

Port objects to use header.writable instead of immutable

Saves 4 or 8 bytes per object on 64bit archs.

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 51f22ce4..4b036e80 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -57,8 +57,6 @@ DEFINE_NULL_INSTANCE (hb_blob_t) =
 {
   HB_OBJECT_HEADER_STATIC,
 
-  true, /* immutable */
-
   nullptr, /* data */
   0, /* length */
   HB_MEMORY_MODE_READONLY, /* mode */
@@ -299,12 +297,10 @@ hb_blob_get_user_data (hb_blob_t  *blob,
 void
 hb_blob_make_immutable (hb_blob_t *blob)
 {
-  if (hb_object_is_inert (blob))
-return;
-  if (blob->immutable)
+  if (hb_object_is_immutable (blob))
 return;
 
-  blob->immutable = true;
+  hb_object_make_immutable (blob);
 }
 
 /**
@@ -320,7 +316,7 @@ hb_blob_make_immutable (hb_blob_t *blob)
 hb_bool_t
 hb_blob_is_immutable (hb_blob_t *blob)
 {
-  return blob->immutable;
+  return hb_object_is_immutable (blob);
 }
 
 
@@ -454,7 +450,7 @@ hb_blob_t::try_make_writable_inplace (void)
 bool
 hb_blob_t::try_make_writable (void)
 {
-  if (this->immutable)
+  if (hb_object_is_immutable (this))
 return false;
 
   if (this->mode == HB_MEMORY_MODE_WRITABLE)
diff --git a/src/hb-blob.hh b/src/hb-blob.hh
index 0181e94a..1f7499fb 100644
--- a/src/hb-blob.hh
+++ b/src/hb-blob.hh
@@ -70,8 +70,6 @@ struct hb_blob_t
   public:
   hb_object_header_t header;
 
-  bool immutable;
-
   const char *data;
   unsigned int length;
   hb_memory_mode_t mode;
diff --git a/src/hb-face.cc b/src/hb-face.cc
index 7ca4b1ba..50ab10e3 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -82,8 +82,6 @@ DEFINE_NULL_INSTANCE (hb_face_t) =
 {
   HB_OBJECT_HEADER_STATIC,
 
-  true, /* immutable */
-
   nullptr, /* reference_table_func */
   nullptr, /* user_data */
   nullptr, /* destroy */
@@ -336,12 +334,10 @@ hb_face_get_user_data (const hb_face_t*face,
 void
 hb_face_make_immutable (hb_face_t *face)
 {
-  if (unlikely (hb_object_is_inert (face)))
-return;
-  if (face->immutable)
+  if (hb_object_is_immutable (face))
 return;
 
-  face->immutable = true;
+  hb_object_make_immutable (face);
 }
 
 /**
@@ -357,7 +353,7 @@ 

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

2018-10-30 Thread Behdad Esfahbod
 .circleci/config.yml   |2 +-
 CMakeLists.txt |   19 ++-
 src/hb-ot-layout-common.hh |1 +
 test/shaping/run-tests.py  |   32 
 util/hb-shape.cc   |   30 ++
 util/options.cc|6 ++
 util/options.hh|8 ++--
 7 files changed, 62 insertions(+), 36 deletions(-)

New commits:
commit 422debb830fe150c26e1628f77531f41f0871325
Author: Behdad Esfahbod 
Date:   Tue Oct 30 00:51:43 2018 -0700

[test/shaping] Spawn one hb-shape per test file

Speeds up runnings in-house tests from over 20s to 2s.

diff --git a/test/shaping/run-tests.py b/test/shaping/run-tests.py
index f77a17c3..99c0a59f 100755
--- a/test/shaping/run-tests.py
+++ b/test/shaping/run-tests.py
@@ -2,16 +2,13 @@
 
 from __future__ import print_function, division, absolute_import
 
-import sys, os, subprocess, tempfile
-
+import sys, os, subprocess
 
 def cmd(command):
-   # https://stackoverflow.com/a/4408409
-   with tempfile.TemporaryFile() as tempf:
-   p = subprocess.Popen (command, stdout=tempf, stderr=sys.stdout)
-   p.wait ()
-   tempf.seek(0)
-   return tempf.read().decode ("utf-8").strip (), p.returncode
+   global process
+   process.stdin.write (' '.join (command) + '\n')
+   process.stdin.flush ()
+   return process.stdout.readline().decode ("utf-8").strip ()
 
 args = sys.argv[1:]
 if not args or sys.argv[1].find('hb-shape') == -1 or not os.path.exists 
(sys.argv[1]):
@@ -19,6 +16,11 @@ if not args or sys.argv[1].find('hb-shape') == -1 or not 
os.path.exists (sys.arg
sys.exit (1)
 hb_shape, args = args[0], args[1:]
 
+process = subprocess.Popen ([hb_shape, '--batch'],
+   stdin=subprocess.PIPE,
+   stdout=subprocess.PIPE,
+   stderr=sys.stdout)
+
 fails = 0
 
 reference = False
@@ -60,24 +62,14 @@ for filename in args:
print ("%s %s %s %s --unicodes %s" %
 (hb_shape, fontfile, ' 
'.join(extra_options), options, unicodes))
 
-   glyphs1, returncode = cmd ([hb_shape, "--font-funcs=ft",
+   glyphs1 = cmd ([hb_shape, "--font-funcs=ft",
fontfile] + extra_options + ["--unicodes",
unicodes] + (options.split (' ') if options else []))
 
-   if returncode:
-   print ("ERROR: hb-shape --font-funcs=ft failed.") # 
file=sys.stderr
-   fails = fails + 1
-   #continue
-
-   glyphs2, returncode = cmd ([hb_shape, "--font-funcs=ot",
+   glyphs2 = cmd ([hb_shape, "--font-funcs=ot",
fontfile] + extra_options + ["--unicodes",
unicodes] + (options.split (' ') if options else []))
 
-   if returncode:
-   print ("ERROR: hb-shape --font-funcs=ot failed.") # 
file=sys.stderr
-   fails = fails + 1
-   #continue
-
if glyphs1 != glyphs2 and glyphs_expected != '*':
print ("FT funcs: " + glyphs1) # file=sys.stderr
print ("OT funcs: " + glyphs2) # file=sys.stderr
commit 58e20f53bf61244e3eef09be8ebed60aaf52fb11
Author: Behdad Esfahbod 
Date:   Tue Oct 30 00:50:18 2018 -0700

[util] Add hb-shape --batch

diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index 337cd431..6c727d01 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -160,6 +160,36 @@ struct output_buffer_t
 int
 main (int argc, char **argv)
 {
+  if (argc == 2 && !strcmp (argv[1], "--batch"))
+  {
+unsigned int ret = 0;
+char *buf = nullptr;
+size_t len;
+while (getline (, , stdin) > 0)
+{
+  size_t l = strlen (buf);
+  if (l && buf[l - 1] == '\n') buf[l - 1] = '\0';
+  main_font_text_t, FONT_SIZE_UPEM, 0> 
driver;
+  char *args[32];
+  argc = 0;
+  char *p = buf, *e;
+  args[argc++] = p;
+  while ((e = strchr (p, ' ')) && argc < (int) (int) ARRAY_LENGTH (args))
+  {
+   *e++ = '\0';
+   while (*e == ' ')
+ e++;
+   args[argc++] = p = e;
+  }
+  ret |= driver.main (argc, args);
+  fflush (stdout);
+
+  if (ret)
+break;
+}
+free (buf);
+return ret;
+  }
   main_font_text_t, FONT_SIZE_UPEM, 0> 
driver;
   return driver.main (argc, argv);
 }
commit 6131fb6283cff87333db14b9b32e92be6139c3d6
Author: Behdad Esfahbod 
Date:   Tue Oct 30 00:38:01 2018 -0700

[util] Don't close stdin/stdout

diff --git a/util/options.cc b/util/options.cc
index 5661cd05..4815770f 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -758,7 +758,10 @@ text_options_t::get_line (unsigned int *len)
   fail (true, "At least one of text or text-file must be set");
 
 if (0 != strcmp (text_file, "-"))
+

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

2018-10-24 Thread Behdad Esfahbod
 appveyor.yml |   18 ++
 src/gen-vowel-constraints.py |9 +++--
 src/hb-ot-shape-complex-vowel-constraints.cc |9 +++--
 3 files changed, 24 insertions(+), 12 deletions(-)

New commits:
commit ae9e8f292b2ad79b01776ae5785a94afbfc4b3e4
Author: Behdad Esfahbod 
Date:   Wed Oct 24 16:46:07 2018 -0700

[vowel-constraints] Reset continuation on all dottedcircles

One of the was missed before.  Not intentional.

diff --git a/src/gen-vowel-constraints.py b/src/gen-vowel-constraints.py
index 19629abe..02a338fa 100755
--- a/src/gen-vowel-constraints.py
+++ b/src/gen-vowel-constraints.py
@@ -104,7 +104,7 @@ class ConstraintSet (object):
s.append ('{}{{\n'.format (indent))
for i in range (len (self._c)):
s.append ('{}buffer->next_glyph 
();\n'.format (self._indent (depth + 1)))
-   s.append ('{}buffer->output_glyph 
(0x25CCu);\n'.format (self._indent (depth + 1)))
+   s.append ('{}_output_dotted_circle 
(buffer);\n'.format (self._indent (depth + 1)))
s.append ('{}}}\n'.format (indent))
else:
s.append ('{}switch (buffer->cur 
({}).codepoint)\n'.format(indent, index or ''))
@@ -161,11 +161,16 @@ print ()
 print ('#include "hb-ot-shape-complex-vowel-constraints.hh"')
 print ()
 print ('static void')
-print ('_output_with_dotted_circle (hb_buffer_t *buffer)')
+print ('_output_dotted_circle (hb_buffer_t *buffer)')
 print ('{')
 print ('  hb_glyph_info_t  = buffer->output_glyph (0x25CCu);')
 print ('  _hb_glyph_info_reset_continuation ();')
+print ('}')
 print ()
+print ('static void')
+print ('_output_with_dotted_circle (hb_buffer_t *buffer)')
+print ('{')
+print ('  _output_dotted_circle (buffer);')
 print ('  buffer->next_glyph ();')
 print ('}')
 print ()
diff --git a/src/hb-ot-shape-complex-vowel-constraints.cc 
b/src/hb-ot-shape-complex-vowel-constraints.cc
index e5023392..aae5936a 100644
--- a/src/hb-ot-shape-complex-vowel-constraints.cc
+++ b/src/hb-ot-shape-complex-vowel-constraints.cc
@@ -16,11 +16,16 @@
 #include "hb-ot-shape-complex-vowel-constraints.hh"
 
 static void
-_output_with_dotted_circle (hb_buffer_t *buffer)
+_output_dotted_circle (hb_buffer_t *buffer)
 {
   hb_glyph_info_t  = buffer->output_glyph (0x25CCu);
   _hb_glyph_info_reset_continuation ();
+}
 
+static void
+_output_with_dotted_circle (hb_buffer_t *buffer)
+{
+  _output_dotted_circle (buffer);
   buffer->next_glyph ();
 }
 
@@ -83,7 +88,7 @@ _hb_preprocess_text_vowel_constraints (const 
hb_ot_shape_plan_t *plan,
{
  buffer->next_glyph ();
  buffer->next_glyph ();
- buffer->output_glyph (0x25CCu);
+ _output_dotted_circle (buffer);
}
break;
}
commit d2b20ba18dfe3fe507ee7cb64fd73e3f1e1e5ae0
Author: Khaled Hosny 
Date:   Wed Oct 24 11:37:09 2018 +0200

[appveyor] Build on Cygwin and msys2 in parallel

diff --git a/appveyor.yml b/appveyor.yml
index c097c3e2..0bc1f310 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -57,10 +57,10 @@ build_script:
   - 'if "%compiler%"=="msvc" if not "%platform%"=="ARM" ctest 
--output-on-failure -C %configuration%'
 
   - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "curl 
https://raw.githubusercontent.com/mirror/mingw-w64/023eb04c396d4e8d8fcf604cfababc53dae13398/mingw-w64-headers/include/dwrite_1.h
 > %MINGW_PREFIX%/%MINGW_CHOST%/include/dwrite_1.h"'
-  - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "cd 
$APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; ./autogen.sh 
--with-uniscribe --with-freetype --with-glib --with-gobject --with-cairo 
--with-icu --with-graphite2 --with-directwrite --build=%MINGW_CHOST% 
--host=%MINGW_CHOST% --prefix=%MINGW_PREFIX%; make; make check || .ci/fail.sh"'
+  - 'if "%compiler%"=="msys2" C:\msys64\usr\bin\bash -lc "cd 
$APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; ./autogen.sh 
--with-uniscribe --with-freetype --with-glib --with-gobject --with-cairo 
--with-icu --with-graphite2 --with-directwrite --build=%MINGW_CHOST% 
--host=%MINGW_CHOST% --prefix=%MINGW_PREFIX%; make -j check || .ci/fail.sh"'
 
   - 'if "%compiler%"=="cygwin" curl 
https://raw.githubusercontent.com/mirror/mingw-w64/023eb04c396d4e8d8fcf604cfababc53dae13398/mingw-w64-headers/include/dwrite_1.h
 -o %CYGWIN_PREFIX%\usr\include\dwrite_1.h'
-  - 'if "%compiler%"=="cygwin" %CYGWIN_PREFIX%\bin\bash -lc "cd 
$APPVEYOR_BUILD_FOLDER; ./autogen.sh --with-uniscribe --with-freetype 
--with-glib --with-gobject --with-cairo --with-icu --with-graphite2 
--with-directwrite; make; make check || .ci/fail.sh"'
+  - 'if "%compiler%"=="cygwin" %CYGWIN_PREFIX%\bin\bash -lc "cd 
$APPVEYOR_BUILD_FOLDER; ./autogen.sh --with-uniscribe --with-freetype 
--with-glib --with-gobject --with-cairo 

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

2018-10-05 Thread Behdad Esfahbod
 src/hb-aat-layout-common.hh |4 
 src/hb-face.cc  |2 
 src/hb-machinery.hh |2 
 src/hb-ot-cmap-table.hh |2 
 src/hb-ot-post-table.hh |2 
 src/hb-ot-shape.cc  |4 
 src/hb-set.hh   |4 
 src/hb-subset.cc|2 
 src/hb-vector.hh|  100 
++
 test/shaping/data/text-rendering-tests/DISABLED |3 
 test/shaping/data/text-rendering-tests/Makefile.sources |2 
 test/shaping/data/text-rendering-tests/fonts/TestMORXThirtyfive.ttf |binary
 test/shaping/data/text-rendering-tests/fonts/TestMORXThirtysix.ttf  |binary
 test/shaping/data/text-rendering-tests/tests/MORX-35.tests  |2 
 test/shaping/data/text-rendering-tests/tests/MORX-36.tests  |1 
 15 files changed, 84 insertions(+), 46 deletions(-)

New commits:
commit 341206eb609202e4b2f0d03d29cb577ebe8390b9
Author: Behdad Esfahbod 
Date:   Fri Oct 5 18:39:48 2018 +0200

[vector] Make hb_vector_t relocatable / nestable

Ugly, but...
Fixes https://github.com/harfbuzz/harfbuzz/issues/1227

diff --git a/src/hb-face.cc b/src/hb-face.cc
index 3916a4e2..bba1ee3f 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -634,7 +634,7 @@ _hb_face_builder_data_reference_blob 
(hb_face_builder_data_t *data)
   unsigned int face_length = table_count * 16 + 12;
 
   for (unsigned int i = 0; i < table_count; i++)
-face_length += hb_ceil_to_4 (hb_blob_get_length 
(data->tables.arrayZ[i].blob));
+face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables[i].blob));
 
   char *buf = (char *) malloc (face_length);
   if (unlikely (!buf))
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index f80cfdb2..9c73df2c 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -591,7 +591,7 @@ struct Supplier
   }
   inline Supplier (const hb_vector_t *v)
   {
-head = v->arrayZ;
+head = v->arrayZ();
 len = v->len;
 stride = sizeof (Type);
   }
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 3f5fa01f..52b4db6a 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -495,7 +495,7 @@ struct CmapSubtableLongSegmented
   {
 TRACE_SERIALIZE (this);
 if (unlikely (!c->extend_min (*this))) return_trace (false);
-Supplier supplier (group_data.arrayZ, 
group_data.len);
+Supplier supplier (group_data.arrayZ(), 
group_data.len);
 if (unlikely (!groups.serialize (c, supplier, group_data.len))) 
return_trace (false);
 return true;
   }
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index f81de37d..bd049f9a 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -242,7 +242,7 @@ struct post
 
   if (index >= index_to_offset.len)
return hb_bytes_t ();
-  unsigned int offset = index_to_offset.arrayZ[index];
+  unsigned int offset = index_to_offset[index];
 
   const uint8_t *data = pool + offset;
   unsigned int name_length = *data;
diff --git a/src/hb-set.hh b/src/hb-set.hh
index 353403e9..7ca32976 100644
--- a/src/hb-set.hh
+++ b/src/hb-set.hh
@@ -368,8 +368,8 @@ struct hb_set_t
 if (!resize (count))
   return;
 population = other->population;
-memcpy (pages.arrayZ, other->pages.arrayZ, count * sizeof 
(pages.arrayZ[0]));
-memcpy (page_map.arrayZ, other->page_map.arrayZ, count * sizeof 
(page_map.arrayZ[0]));
+memcpy (pages.arrayZ(), other->pages.arrayZ(), count * sizeof 
(pages.arrayZ()[0]));
+memcpy (page_map.arrayZ(), other->page_map.arrayZ(), count * sizeof 
(page_map.arrayZ()[0]));
   }
 
   inline bool is_equal (const hb_set_t *other) const
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 2bed3586..9f14b89b 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -77,7 +77,7 @@ _subset2 (hb_subset_plan_t *plan)
   return false;
 }
   retry:
-hb_serialize_context_t serializer (buf.arrayZ, buf_size);
+hb_serialize_context_t serializer (buf.arrayZ(), buf_size);
 hb_subset_context_t c (plan, );
 result = table->subset ();
 if (serializer.ran_out_of_room)
diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index 27087538..766e5fb8 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -35,35 +35,42 @@ template 
 struct hb_vector_t
 {
   unsigned int len;
+  private:
   unsigned int allocated; /* == 0 means allocation failed. */
-  Type *arrayZ;
+  Type *arrayZ_;
   Type static_array[StaticSize];
+  public:
 
   void init (void)
   {
 len = 0;
 allocated = ARRAY_LENGTH (static_array);
-arrayZ = static_array;
+arrayZ_ = nullptr;
   }
 
+  inline Type * arrayZ 

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

2018-10-03 Thread Behdad Esfahbod
 azure-pipelines.yml   
|2 
 dev/null  
|binary
 src/hb-coretext.cc
|2 
 src/hb-ot-layout.hh   
|5 -
 src/hb-ot-shape.cc
|   48 ++
 test/shaping/data/in-house/fonts/4d4206e30b2dbf1c1ef492a8eae1c9e7829ebad8.ttf 
|binary
 test/shaping/data/in-house/tests/indic-joiner-candrabindu.tests   
|2 
 test/shaping/data/in-house/tests/indic-joiners.tests  
|6 -
 test/shaping/data/in-house/tests/mongolian-variation-selector.tests   
|   17 +++
 9 files changed, 37 insertions(+), 45 deletions(-)

New commits:
commit 95e5f1ae69036108f318b93b11d85b2ebc19109b
Author: Behdad Esfahbod 
Date:   Wed Oct 3 21:11:13 2018 +0200

Unbreak Fitzpatrick

Fixes https://github.com/harfbuzz/harfbuzz/issues/1159

diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh
index ac55459b..921fd810 100644
--- a/src/hb-ot-layout.hh
+++ b/src/hb-ot-layout.hh
@@ -214,7 +214,7 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, 
hb_buffer_t *buffer)
 {
   hb_unicode_funcs_t *unicode = buffer->unicode;
   unsigned int u = info->codepoint;
-  unsigned int gen_cat = (unsigned int) unicode->general_category (u);
+  unsigned int gen_cat = (unsigned int) unicode->modified_general_category (u);
   unsigned int props = gen_cat;
 
   if (u >= 0x80)
commit 03fb6dd4c7d12a98cc0ef325432658c3c76ab208
Author: Behdad Esfahbod 
Date:   Wed Oct 3 21:02:16 2018 +0200

Rewrite grapheme-formation in terms of new work

Also, don't attach ZWNJ to previous cluster.  Closer to Unicode graphemes.

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 8b120aac..ab04d72f 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -626,7 +626,7 @@ _hb_coretext_shape (hb_shape_plan_t*shape_plan,
   CGFloat y_mult = (CGFloat) font->y_scale / ct_font_size;
 
   /* Attach marks to their bases, to match the 'ot' shaper.
-   * Adapted from hb-ot-shape:hb_form_clusters().
+   * Adapted from a very old version of hb-ot-shape:hb_form_clusters().
* Note that this only makes us be closer to the 'ot' shaper,
* but by no means the same.  For example, if there's
* B1 M1 B2 M2, and B1-B2 form a ligature, M2's cluster will
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 9e73e358..8c90e689 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -339,26 +339,12 @@ hb_form_clusters (hb_buffer_t *buffer)
   if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII))
 return;
 
-  /* Loop duplicated in hb_ensure_native_direction(), and in _hb-coretext.cc */
-  unsigned int base = 0;
-  unsigned int count = buffer->len;
-  hb_glyph_info_t *info = buffer->info;
-  for (unsigned int i = 1; i < count; i++)
-  {
-if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK 
(_hb_glyph_info_get_general_category ([i])) &&
-   !_hb_glyph_info_is_joiner ([i])))
-{
-  if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
-   buffer->merge_clusters (base, i);
-  else
-   buffer->unsafe_to_break (base, i);
-  base = i;
-}
-  }
   if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
-buffer->merge_clusters (base, count);
+foreach_grapheme (buffer, start, end)
+  buffer->merge_clusters (start, end);
   else
-buffer->unsafe_to_break (base, count);
+foreach_grapheme (buffer, start, end)
+  buffer->unsafe_to_break (start, end);
 }
 
 static void
@@ -376,25 +362,17 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
   (HB_DIRECTION_IS_VERTICAL   (direction) &&
direction != HB_DIRECTION_TTB))
   {
-/* Same loop as hb_form_clusters().
- * Since form_clusters() merged clusters already, we don't merge. */
-unsigned int base = 0;
-unsigned int count = buffer->len;
-hb_glyph_info_t *info = buffer->info;
-for (unsigned int i = 1; i < count; i++)
-{
-  if (likely (!HB_UNICODE_GENERAL_CATEGORY_IS_MARK 
(_hb_glyph_info_get_general_category ([i]
-  {
-   if (buffer->cluster_level == 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS)
- buffer->merge_clusters (base, i);
-   buffer->reverse_range (base, i);
 
-   base = i;
-  }
-}
 if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS)
-  buffer->merge_clusters (base, count);
-buffer->reverse_range (base, count);
+  foreach_grapheme (buffer, start, end)
+  {
+   buffer->merge_clusters (start, end);
+   buffer->reverse_range (start, end);
+  }
+else
+  foreach_grapheme (buffer, start, end)
+   /* form_clusters() merged clusters already, we don't merge. */
+   buffer->reverse_range (start, end);
 
 

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

2018-10-03 Thread Behdad Esfahbod
 src/Makefile.am  |   12 +
 src/gen-emoji-table.py   |   64 +
 src/gen-os2-unicode-ranges.py|2 
 src/hb-ot-os2-table.hh   |2 
 src/hb-ot-os2-unicode-ranges.hh  |   49 +++
 src/hb-ot-shape-complex-indic.cc |   14 +-
 src/hb-unicode-emoji-table.hh|  269 +++
 src/hb-unicode.cc|   16 ++
 src/hb-unicode.hh|   37 +
 test/api/test-multithread.c  |2 
 10 files changed, 433 insertions(+), 34 deletions(-)

New commits:
commit 45e55f70801e2ccd28e1ee30bdf5341b1ac6efe5
Author: Behdad Esfahbod 
Date:   Wed Oct 3 18:07:49 2018 +0200

[indic] Fix clang everything

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index d169b2b3..dfb3d54d 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -412,9 +412,15 @@ preprocess_text_indic (const hb_ot_shape_plan_t *plan,
bool matched = false;
switch (buffer->cur().codepoint)
{
- case 0x0985u: matched = 0x09BE == buffer->cur(1).codepoint; break;
- case 0x098Bu: matched = 0x09C3 == buffer->cur(1).codepoint; break;
- case 0x098Cu: matched = 0x09E2 == buffer->cur(1).codepoint; break;
+ case 0x0985u:
+   matched = 0x09BE == buffer->cur(1).codepoint;
+   break;
+ case 0x098Bu:
+   matched = 0x09C3 == buffer->cur(1).codepoint;
+   break;
+ case 0x098Cu:
+   matched = 0x09E2 == buffer->cur(1).codepoint;
+   break;
}
buffer->next_glyph ();
if (matched) { buffer->output_glyph (0x25CCu); buffer->next_glyph (); }
@@ -475,7 +481,7 @@ preprocess_text_indic (const hb_ot_shape_plan_t *plan,
}
break;
  case 0x0AC5u:
-   matched = 0x0ABE == buffer->cur(1).codepoint; break;
+   matched = 0x0ABE == buffer->cur(1).codepoint;
break;
}
buffer->next_glyph ();
commit 4df02e3240ada0734748a47572baa2fc1c6afbd1
Author: Behdad Esfahbod 
Date:   Wed Oct 3 17:54:09 2018 +0200

Minor

diff --git a/src/hb-ot-os2-unicode-ranges.hh b/src/hb-ot-os2-unicode-ranges.hh
index 8fa21dfb..19780088 100644
--- a/src/hb-ot-os2-unicode-ranges.hh
+++ b/src/hb-ot-os2-unicode-ranges.hh
@@ -53,7 +53,7 @@ struct OS2Range
 };
 
 /* Note: The contents of this array was generated using 
gen-os2-unicode-ranges.py. */
-static OS2Range _hb_os2_unicode_ranges[] =
+static const OS2Range _hb_os2_unicode_ranges[] =
 {
   { 0x0, 0x7F,   0}, // Basic Latin
   {0x80, 0xFF,   1}, // Latin-1 Supplement
commit 1e8f195b96765480007808da60789de9ac501c3b
Author: Behdad Esfahbod 
Date:   Wed Oct 3 17:46:48 2018 +0200

[emoji] Add emoji Extended_Pictographic table and function

Part of https://github.com/harfbuzz/harfbuzz/issues/1159

.

diff --git a/src/Makefile.am b/src/Makefile.am
index 9e7fd299..73631992 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -289,13 +289,15 @@ harfbuzz-gobject.def: $(HB_GOBJECT_headers)
 
 GENERATORS = \
gen-arabic-table.py \
+   gen-def.py \
+   gen-emoji-table.py \
gen-indic-table.py \
+   gen-os2-unicode-ranges.py \
gen-use-table.py \
-   gen-def.py \
$(NULL)
 EXTRA_DIST += $(GENERATORS)
 
-unicode-tables: arabic-table indic-table use-table
+unicode-tables: arabic-table indic-table use-table emoji-table
 
 arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
$(AM_V_GEN) $(builddir)/$^ > 
$(srcdir)/hb-ot-shape-complex-arabic-table.hh \
@@ -309,9 +311,13 @@ use-table: gen-use-table.py IndicSyllabicCategory.txt 
IndicPositionalCategory.tx
$(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-ot-shape-complex-use-table.cc 
\
|| ($(RM) $(srcdir)/hb-ot-shape-complex-use-table.cc; false)
 
+emoji-table: gen-emoji-table.py emoji-data.txt
+   $(AM_V_GEN) $(builddir)/$^ > $(srcdir)/hb-unicode-emoji-table.hh \
+   || ($(RM) $(srcdir)/hb-unicode-emoji-table.hh; false)
+
 built-sources: $(BUILT_SOURCES)
 
-.PHONY: unicode-tables arabic-table indic-table use-table built-sources
+.PHONY: unicode-tables arabic-table indic-table use-table emoji-table 
built-sources
 
 RAGEL_GENERATED = \
$(patsubst %,$(srcdir)/%,$(HB_BASE_RAGEL_GENERATED_sources)) \
diff --git a/src/gen-emoji-table.py b/src/gen-emoji-table.py
new file mode 100755
index ..278e0b2d
--- /dev/null
+++ b/src/gen-emoji-table.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+from __future__ import print_function, division, absolute_import
+import sys
+import os.path
+from collections import OrderedDict
+
+if len (sys.argv) != 2:
+   print("usage: ./gen-emoji-table.py emoji-data.txt", file=sys.stderr)
+   sys.exit (1)
+
+f = open(sys.argv[1])
+header = [f.readline () for _ in range(10)]
+
+sets = OrderedDict()
+for line in f.readlines():
+   line = line.strip()
+   if not line or line[0] == '#':

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

2018-09-28 Thread Behdad Esfahbod
 test/api/test-multithread.c |   75 ++--
 1 file changed, 45 insertions(+), 30 deletions(-)

New commits:
commit 7e6e094abd27fd022fe9aea1872ef82f6a0cdcec
Author: Behdad Esfahbod 
Date:   Fri Sep 28 08:45:57 2018 -0400

[test-multithread] Install ot funcs before filling ref buffer

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 2dbecc9b..a75feffa 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -147,12 +147,13 @@ main (int argc, char **argv)
   hb_face_t *face = hb_face_create (blob, 0);
   font = hb_font_create (face);
 
+  hb_ot_font_set_funcs (font);
+
   ref_buffer = hb_buffer_create ();
   fill_the_buffer (ref_buffer);
 
-  hb_ft_font_set_funcs (font);
   test_body ();
-  hb_ot_font_set_funcs (font);
+  hb_ft_font_set_funcs (font);
   test_body ();
 
   hb_buffer_destroy (ref_buffer);
commit 21fbee831e0eab2c2f4513825c939158f4578156
Author: Behdad Esfahbod 
Date:   Fri Sep 28 08:43:37 2018 -0400

[test-multithread] Take num-threads and num-iters from command-line

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 898f19a0..2dbecc9b 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -134,6 +134,11 @@ test_body ()
 int
 main (int argc, char **argv)
 {
+  if (argc > 1)
+num_threads = atoi (argv[1]);
+  if (argc > 2)
+num_iters = atoi (argv[2]);
+
   // Dummy call to alleviate _guess_segment_properties thread safety-ness
   // https://github.com/harfbuzz/harfbuzz/issues/1191
   hb_language_get_default ();
commit 598be3bb38fd11a288f8155b8c27ffef4ebdd8b9
Author: Behdad Esfahbod 
Date:   Fri Sep 28 08:33:26 2018 -0400

Minor

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 6881a00f..898f19a0 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -135,6 +135,7 @@ int
 main (int argc, char **argv)
 {
   // Dummy call to alleviate _guess_segment_properties thread safety-ness
+  // https://github.com/harfbuzz/harfbuzz/issues/1191
   hb_language_get_default ();
 
   hb_blob_t *blob = hb_blob_create_from_file (path);
commit c09bf3d50589c8eb95b322ef3e4eb8a288dacebe
Author: Ebrahim Byagowi 
Date:   Fri Sep 28 16:13:01 2018 +0330

test-multithread, check the results on every iteration (#1194)

diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 65718825..6881a00f 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -43,9 +43,11 @@ const char *path =
"/Library/Fonts/Tahoma.ttf";
 #endif
 
+int num_threads = 30;
 int num_iters = 200;
 
 hb_font_t *font;
+hb_buffer_t *ref_buffer;
 
 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -57,6 +59,29 @@ fill_the_buffer (hb_buffer_t *buffer)
   hb_shape (font, buffer, NULL, 0);
 }
 
+static void
+validity_check (hb_buffer_t *buffer) {
+  if (hb_buffer_diff (ref_buffer, buffer, (hb_codepoint_t) -1, 0))
+  {
+fprintf (stderr, "One of the buffers was different from the reference.\n");
+char out[255];
+
+hb_buffer_serialize_glyphs (buffer, 0, hb_buffer_get_length (ref_buffer),
+   out, sizeof (out), NULL,
+   font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
+   HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
+fprintf (stderr, "Actual: %s\n", out);
+
+hb_buffer_serialize_glyphs (ref_buffer, 0, hb_buffer_get_length 
(ref_buffer),
+   out, sizeof (out), NULL,
+   font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
+   HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
+fprintf (stderr, "Expected: %s\n", out);
+
+exit (1);
+  }
+}
+
 static void *
 thread_func (void *data)
 {
@@ -70,6 +95,7 @@ thread_func (void *data)
   {
 hb_buffer_clear_contents (buffer);
 fill_the_buffer (buffer);
+validity_check (buffer);
   }
 
   return 0;
@@ -95,38 +121,12 @@ test_body ()
   /* Let them loose! */
   pthread_mutex_unlock ();
 
-  hb_buffer_t *ref_buffer = hb_buffer_create ();
-  fill_the_buffer (ref_buffer);
-
   for (i = 0; i < num_threads; i++)
   {
 pthread_join (threads[i], NULL);
-hb_buffer_t *buffer = buffers[i];
-hb_buffer_diff_flags_t diff = hb_buffer_diff (ref_buffer, buffer, 
(hb_codepoint_t) -1, 0);
-if (diff)
-{
-  fprintf (stderr, "One of the buffers (%d) was different from the 
reference.\n", i);
-  char out[255];
-
-  hb_buffer_serialize_glyphs (buffer, 0, hb_buffer_get_length (ref_buffer),
- out, sizeof (out), NULL,
- font, HB_BUFFER_SERIALIZE_FORMAT_TEXT,
- HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
-  fprintf (stderr, "Actual: %s\n", out);
-
-  hb_buffer_serialize_glyphs (ref_buffer, 0, hb_buffer_get_length 
(ref_buffer),
- out, sizeof (out), NULL,
-

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

2018-09-24 Thread Behdad Esfahbod
 .circleci/config.yml  |4 ++--
 src/check-static-inits.sh |4 ++--
 src/check-symbols.sh  |2 +-
 test/api/Makefile.am  |2 ++
 4 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit aec0d3cbc923a8801c5bd9e9ae05801a31a7260c
Author: Behdad Esfahbod 
Date:   Mon Sep 24 13:12:15 2018 -0400

[ubsan] Re-enable now that it passes locally

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 9721dbb1..66489e87 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -251,7 +251,7 @@ workflows:
   - clang-asan
   #- clang-msan
   - clang-tsan
-  #- clang-ubsan
+  - clang-ubsan
   - fedora-outoftreebuild
 
   # cmake based builds
commit 4839807340cc73d5ba826dff4b4ba358775a213d
Author: Behdad Esfahbod 
Date:   Mon Sep 24 13:11:34 2018 -0400

[check-static-inits.sh] Allow some if ubsan is in effect

diff --git a/src/check-static-inits.sh b/src/check-static-inits.sh
index 71551cbd..def25c70 100755
--- a/src/check-static-inits.sh
+++ b/src/check-static-inits.sh
@@ -7,7 +7,6 @@ test -z "$srcdir" && srcdir=.
 test -z "$libs" && libs=.libs
 stat=0
 
-
 if which objdump 2>/dev/null >/dev/null; then
:
 else
@@ -31,7 +30,8 @@ done
 
 echo "Checking that no object file has lazy static C++ 
constructors/destructors or other such stuff"
 for obj in $OBJS; do
-   if objdump -t "$obj" | grep '__cxa_'; then
+   if objdump -t "$obj" | grep -q '__cxa_' && ! objdump -t "$obj" | grep 
-q __ubsan_handle; then
+   objdump -t "$obj" | grep '__cxa_'
echo "Ouch, $obj has lazy static C++ constructors/destructors 
or other such stuff"
stat=1
fi
commit e45ba31dc723988150ef766758fa89fecd50ca03
Author: Behdad Esfahbod 
Date:   Mon Sep 24 13:04:48 2018 -0400

[check-symbols.sh] Allow weak objects "V"

ubsan generates these.

diff --git a/src/check-symbols.sh b/src/check-symbols.sh
index 6e9382b1..cea86848 100755
--- a/src/check-symbols.sh
+++ b/src/check-symbols.sh
@@ -26,7 +26,7 @@ for soname in harfbuzz harfbuzz-subset harfbuzz-icu 
harfbuzz-gobject; do
symprefix=
if test $suffix = dylib; then symprefix=_; fi
 
-   EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRSTV] .' | grep -v 
" $symprefix\\($IGNORED_SYMBOLS\\>\\)" | cut -d' ' -f3 | c++filt`"
+   EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRST] .' | grep -v " 
$symprefix\\($IGNORED_SYMBOLS\\>\\)" | cut -d' ' -f3 | c++filt`"
 
prefix=$symprefix`basename "$so" | sed 's/libharfbuzz/hb/; 
s/-/_/g; s/[.].*//'`
 
commit d07f3111b4bc38798e16a2459b80a16d7a9f9ff1
Author: Behdad Esfahbod 
Date:   Mon Sep 24 13:01:35 2018 -0400

Link API test programs with C++ linker

Needed to make ubsan work.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1174

diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index a2033449..d92e9669 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -16,6 +16,8 @@ EXTRA_DIST += CMakeLists.txt
 
 EXTRA_DIST += fonts
 
+LINK = $(CXXLINK)
+
 if HAVE_GLIB
 AM_CPPFLAGS = -DSRCDIR="\"$(srcdir)\"" -I$(top_srcdir)/src/ 
-I$(top_builddir)/src/ $(GLIB_CFLAGS)
 LDADD = $(top_builddir)/src/libharfbuzz.la $(GLIB_LIBS)
commit a96508cfc9bd9013d24b18547fcd9c03e08fe2f2
Author: Behdad Esfahbod 
Date:   Mon Sep 24 12:52:42 2018 -0400

[msan] Add MSAN_OPTIONS=exitcode=42

Default exit value is 77, which causes autotools to "skip" test.

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 7baebb1c..9721dbb1 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -101,7 +101,7 @@ jobs:
   - run: pip install fonttools
   - run: CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory" 
CC=clang-6.0 CXX=clang++-6.0 ./autogen.sh --with-freetype --with-glib 
--with-cairo --with-icu --with-graphite2
   - run: make
-  - run: make check || .ci/fail.sh
+  - run: MSAN_OPTIONS=exitcode=42 make check || .ci/fail.sh
 
   clang-tsan:
 docker:
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2018-06-29 Thread Behdad Esfahbod
 .circleci/config.yml |3 ++-
 src/hb-blob.cc   |   42 --
 2 files changed, 26 insertions(+), 19 deletions(-)

New commits:
commit 25970a93aa6596d50ae538c6274625f95153572c
Author: Ebrahim Byagowi 
Date:   Thu Jun 28 14:32:36 2018 +0430

armcc compatibility, don't use EINTR if doesn't exist

Fixes #1081

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index d29c6b2c..10db0978 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -617,7 +617,9 @@ fail_without_close:
 unsigned long addition = fread (data + len, 1, allocated - len, fp);
 
 int err = ferror (fp);
+#ifdef EINTR // armcc doesn't have it
 if (unlikely (err == EINTR)) continue;
+#endif
 if (unlikely (err)) goto fread_fail;
 
 len += addition;
commit 8a51f91b7035bbfaf39af1b962faf1613d2ea3b7
Author: Ebrahim Byagowi 
Date:   Thu Jun 28 13:22:21 2018 +0430

Minor on hb_blob_create_from_file, reuse ferror result

Oops

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index d17627ff..d29c6b2c 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -618,7 +618,7 @@ fail_without_close:
 
 int err = ferror (fp);
 if (unlikely (err == EINTR)) continue;
-if (unlikely (ferror (fp))) goto fread_fail;
+if (unlikely (err)) goto fread_fail;
 
 len += addition;
   }
commit 71971800ed1c0501a58e6ff7730e3cebec2ef2f8
Author: Ebrahim Byagowi 
Date:   Wed Jun 27 18:14:52 2018 +0430

[ci] Don't fail on apt update and revive clang-O3-O0

diff --git a/.circleci/config.yml b/.circleci/config.yml
index de130b50..012873e2 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -68,7 +68,8 @@ jobs:
   - image: multiarch/crossbuild
 steps:
   - checkout
-  - run: apt update && apt install -y ragel libfreetype6-dev 
libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip
+  - run: apt update || true
+  - run: apt install -y ragel libfreetype6-dev libglib2.0-dev 
libcairo2-dev libicu-dev libgraphite2-dev python python-pip
   - run: pip install fonttools
   - run: wget 
http://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.bz2 && tar 
xf freetype-2.9.tar.bz2 && cd freetype-2.9 && ./autogen.sh && ./configure && 
make -j4 && cd ..
   - run: CFLAGS="-O3" CXXFLAGS="-O3" CC=clang CXX=clang++ ./autogen.sh 
--with-freetype --with-glib --with-cairo --with-icu --with-graphite2
commit 7b4099f35f766d33d483a4b9d0805ef16020ea23
Author: Ebrahim Byagowi 
Date:   Wed Jun 27 16:54:44 2018 +0430

Minor, rename blob to data on blob_from_file

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 918a479c..d17627ff 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -593,10 +593,10 @@ fail_without_close:
 #endif
 
   // The following tries to read a file without knowing its size beforehand
-  // It's used for systems without mmap concept or to read from pipes
+  // It's used as a fallback for systems without mmap or to read from pipes
   unsigned long len = 0, allocated = BUFSIZ * 16;
-  char *blob = (char *) malloc (allocated);
-  if (unlikely (blob == nullptr)) return hb_blob_get_empty ();
+  char *data = (char *) malloc (allocated);
+  if (unlikely (data == nullptr)) return hb_blob_get_empty ();
 
   FILE *fp = fopen (file_name, "rb");
   if (unlikely (fp == nullptr)) goto fread_fail_without_close;
@@ -609,12 +609,12 @@ fail_without_close:
   // Don't allocate and go more than ~536MB, our mmap reader still
   // can cover files like that but lets limit our fallback reader
   if (unlikely (allocated > (2 << 28))) goto fread_fail;
-  char *new_blob = (char *) realloc (blob, allocated);
-  if (unlikely (new_blob == nullptr)) goto fread_fail;
-  blob = new_blob;
+  char *new_data = (char *) realloc (data, allocated);
+  if (unlikely (new_data == nullptr)) goto fread_fail;
+  data = new_data;
 }
 
-unsigned long addition = fread (blob + len, 1, allocated - len, fp);
+unsigned long addition = fread (data + len, 1, allocated - len, fp);
 
 int err = ferror (fp);
 if (unlikely (err == EINTR)) continue;
@@ -623,12 +623,12 @@ fail_without_close:
 len += addition;
   }
 
-  return hb_blob_create (blob, len, HB_MEMORY_MODE_WRITABLE, blob,
+  return hb_blob_create (data, len, HB_MEMORY_MODE_WRITABLE, data,
  (hb_destroy_func_t) free);
 
 fread_fail:
   fclose (fp);
 fread_fail_without_close:
-  free (blob);
+  free (data);
   return hb_blob_get_empty ();
 }
commit fa090ed4d47df12b2e611c9a667c398742f7e4ba
Author: Ebrahim Byagowi 
Date:   Wed Jun 27 14:13:26 2018 +0430

Minor touches on hb_blob_create_from_file (#1079)

* Handle EINTR on fallback reader
* Increase fallback reader limitation size limitation to 2 << 28
* Ensure _O_BINARY does exist if MMAP is used on Windows
  (maybe superfluous but makes me more confident)

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 155c2e6b..918a479c 100644
--- a/src/hb-blob.cc
+++ 

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

2018-06-26 Thread Behdad Esfahbod
 .circleci/config.yml   
 |6 
 src/hb-blob.cc 
 |  152 --
 
test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560 
|binary
 test/subset/run-tests.py   
 |  101 +++---
 util/options.cc
 |   27 -
 5 files changed, 134 insertions(+), 152 deletions(-)

New commits:
commit 7db2e9ea38329b9393c9e8cc905b180735c9b0f4
Author: Ebrahim Byagowi 
Date:   Tue Jun 26 10:46:10 2018 +0430

Minor on hb_blob_create_from_file

Add one more "unlikely" annotation and use explicit nullptr check for more 
consistency.

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 37a6d8cb..155c2e6b 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -597,7 +597,7 @@ fail_without_close:
   int len = 0;
   int allocated = BUFSIZ * 16;
   char *blob = (char *) malloc (allocated);
-  if (blob == nullptr) return hb_blob_get_empty ();
+  if (unlikely (blob == nullptr)) return hb_blob_get_empty ();
 
   FILE *fp = fopen (file_name, "rb");
   if (unlikely (fp == nullptr)) goto fread_fail_without_close;
@@ -611,7 +611,7 @@ fail_without_close:
   // can cover files like that but lets limit our fallback reader
   if (unlikely (allocated > 2)) goto fread_fail;
   char *new_blob = (char *) realloc (blob, allocated);
-  if (unlikely (!new_blob)) goto fread_fail;
+  if (unlikely (new_blob == nullptr)) goto fread_fail;
   blob = new_blob;
 }
 
commit 4f8753464ae44dfb60bee81ede10448175db7b90
Author: Garret Rieger 
Date:   Fri Jun 22 15:29:34 2018 -0700

[subset] Add fuzzer test case that caused a timeout to the corpus.

diff --git 
a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560
 
b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560
new file mode 100644
index ..d622c256
Binary files /dev/null and 
b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560
 differ
commit 35ce8f31d37cf7c2a1f8265d36ba4c2c9a3efb2c
Author: Ebrahim Byagowi 
Date:   Mon Jun 25 22:23:43 2018 +0430

Unify our pipe reader with the fallback reader (#1068)

And assign one bot to use the path always using NOMMAPFILEREADER token.

It's limited to 200mb so no more fun with using /dev/zero on hb-view!

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 55820005..de130b50 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -40,14 +40,14 @@ jobs:
   - run: rm -rf harfbuzz-*
   - run: make distdir && cd harfbuzz-* && cmake -DHB_CHECK=ON -Bbuild -H. 
-GNinja && ninja -Cbuild && CTEST_OUTPUT_ON_FAILURE=1 ninja -Cbuild test && 
ninja -Cbuild install
 
-  alpine-O3:
+  alpine-O3-NOMMAP:
 docker:
   - image: alpine
 steps:
   - checkout
   - run: apk update && apk add ragel make pkgconfig libtool autoconf 
automake gettext gcc g++ glib-dev freetype-dev cairo-dev
   # C??FLAGS are not needed for a regular build
-  - run: CFLAGS="-O3" CXXFLAGS="-O3" ./autogen.sh
+  - run: CFLAGS="-O3" CXXFLAGS="-O3 -DNOMMAPFILEREADER" ./autogen.sh
   - run: make
   - run: make check || .ci/fail.sh
 
@@ -196,7 +196,7 @@ workflows:
   - distcheck
 
   # autotools based builds
-  - alpine-O3
+  - alpine-O3-NOMMAP
   - archlinux-debug-O0-py3
   - clang-O3-O0
   - fedora-outoftreebuild
diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index 77dbc715..37a6d8cb 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -499,36 +499,6 @@ hb_blob_t::try_make_writable (void)
 # define MAP_NORESERVE 0
 #endif
 
-static hb_blob_t *
-_fread_to_end (FILE *file)
-{
-  int allocated = BUFSIZ * 16;
-  char *blob = (char *) malloc (allocated);
-  if (blob == nullptr) return hb_blob_get_empty ();
-
-  int len = 0;
-  while (!feof (file))
-  {
-if (allocated - len < BUFSIZ)
-{
-  allocated *= 2;
-  char *new_blob = (char *) realloc (blob, allocated);
-  if (unlikely (!new_blob)) goto fail;
-  blob = new_blob;
-}
-
-len += fread (blob + len, 1, allocated - len, file);
-if (ferror (file)) goto fail;
-  }
-
-  return hb_blob_create (blob, len, HB_MEMORY_MODE_WRITABLE, blob,
-(hb_destroy_func_t) free);
-
-fail:
-  free (blob);
-  return hb_blob_get_empty ();
-}
-
 struct hb_mapped_file_t
 {
   char *contents;
@@ -547,7 +517,7 @@ _hb_mapped_file_destroy (hb_mapped_file_t *file)
   UnmapViewOfFile (file->contents);
   CloseHandle (file->mapping);
 #else
-  free (file->contents);
+  assert (0); // If we don't have mmap we shouldn't reach here
 #endif
 
   free (file);
@@ -566,87 +536,95 @@ hb_blob_create_from_file (const char *file_name)
 {
   // Adopted from glib's gmappedfile.c with Matthias Clasen and
   // Allison Lortie permission but changed a lot to suit our 

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

2018-06-01 Thread Behdad Esfahbod
 src/dump-fon.cc  |   12 
 src/hb-buffer-deserialize-json.hh|  758 +--
 src/hb-buffer-deserialize-json.rl|2 
 src/hb-buffer-deserialize-text.hh|  510 +++
 src/hb-buffer-deserialize-text.rl|2 
 src/hb-buffer-private.hh |2 
 src/hb-buffer.cc |   24 -
 src/hb-map-private.hh|   13 
 src/hb-map.cc|   14 
 src/hb-ot-layout-gsubgpos-private.hh |4 
 src/hb-ot-layout.cc  |2 
 src/hb-ot-shape-complex-hangul.cc|8 
 src/hb-ot-shape-complex-indic.cc |4 
 src/hb-ot-shape-complex-khmer.cc |4 
 src/hb-ot-shape-complex-myanmar.cc   |2 
 src/hb-ot-shape-complex-thai.cc  |4 
 src/hb-ot-shape-complex-use.cc   |4 
 src/hb-ot-shape-normalize.cc |   12 
 src/hb-ot-shape-private.hh   |2 
 src/hb-ot-shape.cc   |2 
 src/hb-private.hh|   10 
 src/hb-set-private.hh|   31 -
 src/hb-set.cc|   12 
 src/main.cc  |2 
 24 files changed, 713 insertions(+), 727 deletions(-)

New commits:
commit a7dd90f519fb7ab046e92ea3b7101c21d5040bbc
Author: Behdad Esfahbod 
Date:   Fri Jun 1 16:07:55 2018 -0700

Revert "Remove HB_DISALLOW_COPY_AND_ASSIGN"

This reverts commit ff92de766bf775bfdd3a01bda94de699180ff86a.

Revert that and remove ASSERT_POD. Let's see which bots are
unhappy with this configuration...

diff --git a/src/hb-map-private.hh b/src/hb-map-private.hh
index 46634465..cad6f0e2 100644
--- a/src/hb-map-private.hh
+++ b/src/hb-map-private.hh
@@ -98,7 +98,6 @@ struct hb_map_t
   };
 
   hb_object_header_t header;
-  ASSERT_POD ();
   bool successful; /* Allocations successful */
   unsigned int population; /* Not including tombstones. */
   unsigned int occupancy; /* Including tombstones. */
@@ -252,7 +251,7 @@ struct hb_map_t
   }
 
   private:
-  HB_DISALLOW_ASSIGN (hb_map_t);
+  HB_DISALLOW_COPY_AND_ASSIGN (hb_map_t);
 };
 
 
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index a540e6af..c217af0c 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -99,7 +99,7 @@ struct hb_ot_shape_planner_t
   }
 
   private:
-  HB_DISALLOW_ASSIGN (hb_ot_shape_planner_t);
+  HB_DISALLOW_COPY_AND_ASSIGN (hb_ot_shape_planner_t);
 };
 
 
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 53dfd808..05f0adbe 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -537,7 +537,11 @@ _hb_ceil_to_4 (unsigned int v)
  */
 
 #define HB_DISALLOW_ASSIGN(TypeName) \
-  void operator=(const TypeName&)
+  void operator=(const TypeName&) = delete
+
+#define HB_DISALLOW_COPY_AND_ASSIGN(TypeName) \
+  TypeName(const TypeName&) = delete; \
+  void operator=(const TypeName&) = delete
 
 /*
  * Static pools
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 0129af87..323c6f4b 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -180,7 +180,6 @@ struct hb_set_t
   static_assert (page_t::PAGE_BITS == sizeof (page_t) * 8, "");
 
   hb_object_header_t header;
-  ASSERT_POD ();
   bool successful; /* Allocations successful */
   mutable unsigned int population;
   hb_vector_t page_map;
@@ -679,7 +678,7 @@ struct hb_set_t
   inline hb_codepoint_t major_start (unsigned int major) const { return major 
* page_t::PAGE_BITS; }
 
   private:
-  HB_DISALLOW_ASSIGN (hb_set_t);
+  HB_DISALLOW_COPY_AND_ASSIGN (hb_set_t);
 };
 
 
commit 7b50bf52f274f75f0b41008e0eab150124ae928a
Author: Behdad Esfahbod 
Date:   Thu May 31 20:20:17 2018 -0700

Use NullPool for _hb_set_nil and _hb_map_nil

diff --git a/src/hb-map.cc b/src/hb-map.cc
index 49c7ecce..079fffbc 100644
--- a/src/hb-map.cc
+++ b/src/hb-map.cc
@@ -50,16 +50,6 @@ hb_map_create (void)
   return map;
 }
 
-static const hb_map_t _hb_map_nil = {
-  HB_OBJECT_HEADER_STATIC,
-  false, /* successful */
-  0, /* population */
-  0, /* occupancy */
-  0, /* mask */
-  0, /* prime */
-  nullptr /* items */
-};
-
 /**
  * hb_map_get_empty:
  *
@@ -70,7 +60,7 @@ static const hb_map_t _hb_map_nil = {
 hb_map_t *
 hb_map_get_empty (void)
 {
-  return const_cast (&_hb_map_nil);
+  return const_cast ((hb_map_t));
 }
 
 /**
diff --git a/src/hb-private.hh b/src/hb-private.hh
index b751cadb..53dfd808 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -545,7 +545,7 @@ _hb_ceil_to_4 (unsigned int v)
 
 /* Global nul-content Null pool.  Enlarge as necessary. */
 
-#define HB_NULL_POOL_SIZE 264
+#define HB_NULL_POOL_SIZE 384
 static_assert (HB_NULL_POOL_SIZE % sizeof (void *) == 0, "Align 
HB_NULL_POOL_SIZE.");
 
 #ifdef HB_NO_VISIBILITY
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 605267e5..b5753222 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -50,12 +50,6 @@ hb_set_create (void)
   return set;
 }
 
-static const hb_set_t _hb_set_nil = {
-  HB_OBJECT_HEADER_STATIC,
-  false, 

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

2018-02-20 Thread Behdad Esfahbod
 .circleci/config.yml|   14 --
 src/dev-run.sh  |   46 +++---
 src/hb-ot-cmap-table.hh |2 +-
 3 files changed, 40 insertions(+), 22 deletions(-)

New commits:
commit d1f16fce963092404bf0b59e449a3215ca031b54
Author: Behdad Esfahbod 
Date:   Tue Feb 20 10:32:09 2018 -0800

Don't use %zu

Some of our bots / compilers don't like it. Wasn't caught by bots because 
this
is only in debug code.


https://github.com/harfbuzz/harfbuzz/pull/809/commits/825ad378e0f0e6e6bb690894a0d5d25f198be21b

diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 8d9ade43..4593152b 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -604,7 +604,7 @@ struct cmap
+ 12 * groups.len; // SequentialMapGroup records
 void *dest = calloc (dest_sz, 1);
 if (unlikely (!dest)) {
-  DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %zu for cmap subset output", 
dest_sz);
+  DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for cmap subset output", 
(unsigned long) dest_sz);
   return false;
 }
 
commit c7e834a2fc5f8fb81f5316447e4075902d58d8a3
Author: Ebrahim Byagowi 
Date:   Tue Feb 20 17:59:04 2018 +0330

[dev-run] minor

diff --git a/src/dev-run.sh b/src/dev-run.sh
index 8589f62d..5a7ae102 100755
--- a/src/dev-run.sh
+++ b/src/dev-run.sh
@@ -33,6 +33,6 @@ if [[ "$answer" = "y" ]]; then
if [[ $CMAKENINJA ]]; then
CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=5 ninja -Cbuild 
test
else
-   make -j5 check && .ci/fail.sh
+   make -Cbuild -j5 check && .ci/fail.sh
fi
 fi
commit 975c35214f8c8f0d90a8b114e1a8c06d5ecdecfd
Author: Ebrahim Byagowi 
Date:   Tue Feb 20 17:49:29 2018 +0330

[dev-run] Support autotools builds

diff --git a/src/dev-run.sh b/src/dev-run.sh
index 2c50dc58..8589f62d 100755
--- a/src/dev-run.sh
+++ b/src/dev-run.sh
@@ -1,22 +1,38 @@
 #!/bin/bash
-
-for cmd in cmake ninja entr; do
-command -v $cmd >/dev/null 2>&1 || { echo >&2 "This script needs $cmd be 
installed"; exit 1; }
-done
+# Suggested setup to use the script:
+#  (on the root of the project)
+#  $ NOCONFIGURE=1 ./autogen.sh --with-freetype --with-glib --with-gobject 
--with-cairo
+#  $ mkdir build && cd build && ../configure && make -j5 && cd ..
+#  $ src/dev-run.sh [FONT-FILE] [TEXT]
+#
+# Or, using cmake:
+#  $ cmake -DHB_CHECK=ON -Bbuild -H. -GNinja && ninja -Cbuild
+#  $ src/dev-run.sh [FONT-FILE] [TEXT]
+#
 
 [ $# = 0 ] && echo Usage: "src/dev-run.sh [FONT-FILE] [TEXT]" && exit
+command -v entr >/dev/null 2>&1 || { echo >&2 "This script needs `entr` be 
installed"; exit 1; }
 
-cmake -DHB_CHECK=ON -DHB_DISABLE_TEST_PROGS=ON -Bbuild -H. -GNinja
-ninja -Cbuild
-
+[ -f 'build/build.ninja' ] && CMAKENINJA=TRUE
 # or "fswatch -0 . -e build/ -e .git"
-find src/ | entr printf '\0' | while read -d "" event; do
-clear
-ninja -Cbuild
-build/hb-shape $@
-build/hb-view $@
+find src/ | entr printf '\0' | while read -d ""; do
+   clear
+   if [[ $CMAKENINJA ]]; then
+   ninja -Cbuild hb-shape hb-view
+   build/hb-shape $@
+   build/hb-view $@
+   else
+   make -Cbuild/src -j5 -s lib
+   build/util/hb-shape $@
+   build/util/hb-view $@
+   fi
 done
 
-cmake -DHB_CHECK=ON -DHB_DISABLE_TEST_PROGS=OFF -Bbuild -H. -GNinja
-ninja -Cbuild
-CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=8 ninja -Cbuild test
+read -n 1 -p "Run the tests (y/n)? " answer
+if [[ "$answer" = "y" ]]; then
+   if [[ $CMAKENINJA ]]; then
+   CTEST_OUTPUT_ON_FAILURE=1 CTEST_PARALLEL_LEVEL=5 ninja -Cbuild 
test
+   else
+   make -j5 check && .ci/fail.sh
+   fi
+fi
commit 25136d9b7265d8920a78f3f832f1c69da4ef1f5b
Author: Dominik Röttsches 
Date:   Tue Feb 20 10:26:07 2018 +0200

Use %zu format specifier for size_t to fix cross platform build

Fixes Chromium Android builds, compare

https://ci.chromium.org/buildbot/tryserver.chromium.android/linux_android_rel_ng/491787

diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 284b62cd..8d9ade43 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -604,7 +604,7 @@ struct cmap
+ 12 * groups.len; // SequentialMapGroup records
 void *dest = calloc (dest_sz, 1);
 if (unlikely (!dest)) {
-  DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %ld for cmap subset output", 
dest_sz);
+  DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %zu for cmap subset output", 
dest_sz);
   return false;
 }
 
commit 53cf61b0299775f94c625de1bb0a7979b3b0c379
Author: Ebrahim Byagowi 
Date:   Tue Feb 20 10:53:10 2018 +0330

Change Alpine and ArchLinux bot to test O3 and O0 on gcc, #801

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 

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

2018-02-18 Thread Behdad Esfahbod
 CMakeLists.txt
|   24 
 src/Makefile.sources  
|1 
 src/dev-run.sh
|   22 
 src/hb-aat-layout-kerx-table.hh   
|  377 ++
 src/hb-aat-layout.cc  
|1 
 src/hb-ot-layout-gpos-table.hh
|5 
 src/hb-ot-layout-private.hh   
|2 
 test/api/CMakeLists.txt   
|2 
 test/shaping/data/in-house/fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf 
|binary
 test/shaping/data/in-house/tests/use.tests
|1 
 10 files changed, 422 insertions(+), 13 deletions(-)

New commits:
commit 1c50a88623a881a9e2b2b0f1f6a783962626f03a
Author: Behdad Esfahbod 
Date:   Sun Feb 18 15:57:09 2018 -0800

Readjust mark attachment heuristic a bit more

Previously adjusted logic could fail if nothing around was ligated,
and something moved.  This should take care of that.

CC https://github.com/harfbuzz/harfbuzz/issues/740

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 5b1bc6ab..4e1a10d7 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1079,7 +1079,10 @@ struct MarkBasePosFormat1
  0 == _hb_glyph_info_get_lig_comp (>info[skippy_iter.idx]) ||
  (skippy_iter.idx == 0 ||
   _hb_glyph_info_get_lig_id (>info[skippy_iter.idx]) !=
-  _hb_glyph_info_get_lig_id (>info[skippy_iter.idx - 1])))
+  _hb_glyph_info_get_lig_id (>info[skippy_iter.idx - 1]) ||
+  _hb_glyph_info_get_lig_comp (>info[skippy_iter.idx]) !=
+  _hb_glyph_info_get_lig_comp (>info[skippy_iter.idx - 1]) + 1
+  ))
break;
   skippy_iter.reject ();
 } while (1);
commit 246e280d88b6b26757297a349f01e52c15eaec53
Author: Behdad Esfahbod 
Date:   Sun Feb 18 15:42:25 2018 -0800

[test] Add test for https://github.com/harfbuzz/harfbuzz/issues/740

diff --git 
a/test/shaping/data/in-house/fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf 
b/test/shaping/data/in-house/fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf
new file mode 100644
index ..2fc9e9cf
Binary files /dev/null and 
b/test/shaping/data/in-house/fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf 
differ
diff --git a/test/shaping/data/in-house/tests/use.tests 
b/test/shaping/data/in-house/tests/use.tests
index f83f6f9a..172946c4 100644
--- a/test/shaping/data/in-house/tests/use.tests
+++ b/test/shaping/data/in-house/tests/use.tests
@@ -2,3 +2,4 @@
 
../fonts/4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf::U+1A48,U+1A58,U+1A25,U+1A48,U+1A58,U+1A25,U+1A6E,U+1A63:[uni1A48=0+1212|uni1A25=0+1912|uni1A58=0+0|uni1A48=3+1212|uni1A6E=3+0|uni1A25=3+1912|uni1A58=3+0|uni1A63=3+1212]
 
../fonts/f518eb6f6b5eec2946c9fbbbde44e45d46f5e2ac.ttf::U+1A48,U+1A58,U+1A25,U+1A48,U+1A58,U+1A25,U+1A6E,U+1A63:[uni1A48=0+1212|uni1A25=0+1912|uni1A58=0+0|uni1A48=3+1212|uni1A6E=3+1211|uni1A25=3+1912|uni1A58=3+0|uni1A63=3+1212]
 
../fonts/6ff0fbead4462d9f229167b4e6839eceb8465058.ttf:--font-funcs=ot:U+11103,U+11128:[u11103=0+837|u11128=0+0]
+../fonts/573d3a3177c9a8646e94c8a0d7b224334340946a.ttf:--font-funcs=ft:U+11410,U+11442,U+11411,U+11440,U+11443,U+11410,U+11442,U+11411,U+11441,U+11443:[E_dv.alt=0+275|Ga.icd=0+367|Gha.diag=0@100,0+386|AA_dv.alt=0+208|Candrabindu=0@17,-8+0|E_dv.alt=5+275|Ga.icd=5+367|Gha.diag=5@100,0+386|AU_dv_part.alt=5+213|Candrabindu.sm=5@-52,179+0]
commit 79756c9039a628b0df441228ca1ea20b8a91e3e8
Author: Ebrahim Byagowi 
Date:   Mon Feb 19 03:17:44 2018 +0330

[aat] First dig on 'kerx' (#704)

diff --git a/src/Makefile.sources b/src/Makefile.sources
index ec60ec0a..3a73bc00 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -82,6 +82,7 @@ HB_FALLBACK_sources = \
 HB_OT_sources = \
hb-aat-layout.cc \
hb-aat-layout-common-private.hh \
+   hb-aat-layout-kerx-table.hh \
hb-aat-layout-morx-table.hh \
hb-aat-layout-private.hh \
hb-ot-font.cc \
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
new file mode 100644
index ..4a40d1c2
--- /dev/null
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -0,0 +1,377 @@
+/*
+ * Copyright © 2018  Google, Inc.
+ * Copyright © 2018  Ebrahim Byagowi
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of 

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

2018-02-07 Thread Behdad Esfahbod
 src/hb-open-file-private.hh |6 +-
 src/hb-ot-glyf-table.hh |   26 
 src/hb-subset-glyf.cc   |   93 
 src/hb-subset.cc|   37 -
 4 files changed, 133 insertions(+), 29 deletions(-)

New commits:
commit c9acab3cfbe4a21e86ad309ebb452f103b1c1b04
Author: Behdad Esfahbod 
Date:   Wed Feb 7 17:12:55 2018 -0600

Whitespace

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 1e5676e8..762783f3 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -64,9 +64,9 @@ typedef struct TableRecord
 
   Tag  tag;/* 4-byte identifier. */
   CheckSum checkSum;   /* CheckSum for this table. */
-  HBUINT32 offset; /* Offset from beginning of TrueType 
font
+  HBUINT32 offset; /* Offset from beginning of TrueType font
 * file. */
-  HBUINT32 length; /* Length of this table. */
+  HBUINT32 length; /* Length of this table. */
   public:
   DEFINE_SIZE_STATIC (16);
 } OpenTypeTable;
@@ -81,7 +81,7 @@ typedef struct OffsetTable
   {
 return tables[i];
   }
-  inline unsigned int get_table_tags (unsigned int start_offset,
+  inline unsigned int get_table_tags (unsigned int  start_offset,
  unsigned int *table_count, /* IN/OUT */
  hb_tag_t *table_tags /* OUT */) const
   {
commit 7fd0b61dee18380c302009f8be9cd68dadab7308
Author: Behdad Esfahbod 
Date:   Wed Feb 7 16:44:52 2018 -0600

[subset] Create new face and copy all tables to it

test-subset fails now because subset-face does not know how to compile 
itself.

diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index a1c6833e..61f38a0a 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -194,10 +194,9 @@ hb_subset_face_add_table (hb_face_t *face, hb_tag_t tag, 
hb_blob_t *blob)
 
 /**
  * hb_subset:
+ * @source: font face data to be subset.
  * @profile: profile to use for the subsetting.
  * @input: input to use for the subsetting.
- * @face: font face data to be subset.
- * @result: subsetting result.
  *
  * Subsets a font according to provided profile and input.
  **/
@@ -210,13 +209,32 @@ hb_subset (hb_face_t *source,
 
   hb_subset_plan_t *plan = hb_subset_plan_create (source, profile, input);
 
+  hb_face_t *face = hb_subset_face_create ();
+
+  /* Copy tables to new face. */
+  {
+hb_tag_t table_tags[32];
+unsigned int offset = 0, count;
+do {
+  count == ARRAY_LENGTH (table_tags);
+  hb_face_get_table_tags (source, offset, , table_tags);
+  for (unsigned int i = 0; i < count; i++)
+  {
+   hb_tag_t tag = table_tags[i];
+   hb_blob_t *blob = hb_face_reference_table (source, tag);
+   hb_subset_face_add_table (face, tag, blob);
+   hb_blob_destroy (blob);
+  }
+} while (count == ARRAY_LENGTH (table_tags));
+  }
+
   hb_codepoint_t old_gid = -1;
-  while (hb_set_next(plan->glyphs_to_retain, _gid)) {
+  while (hb_set_next (plan->glyphs_to_retain, _gid)) {
 hb_codepoint_t new_gid;
-if (hb_subset_plan_new_gid_for_old_id(plan, old_gid, _gid)) {
-  DEBUG_MSG(SUBSET, nullptr, "Remap %d : %d", old_gid, new_gid);
+if (hb_subset_plan_new_gid_for_old_id (plan, old_gid, _gid)) {
+  DEBUG_MSG (SUBSET, nullptr, "Remap %d : %d", old_gid, new_gid);
 } else {
-  DEBUG_MSG(SUBSET, nullptr, "Remap %d : DOOM! No new ID", old_gid);
+  DEBUG_MSG (SUBSET, nullptr, "Remap %d : DOOM! No new ID", old_gid);
 }
   }
   // TODO:
@@ -226,16 +244,13 @@ hb_subset (hb_face_t *source,
   //   - copy the table into the output.
   // - Fix header + table directory.
 
-  bool success = true;
-
   hb_blob_t *glyf_prime = nullptr;
   if (hb_subset_glyf (plan, source, _prime)) {
 // TODO: write new glyf to new face.
-  } else {
-success = false;
   }
   hb_blob_destroy (glyf_prime);
 
   hb_subset_plan_destroy (plan);
-  return success ? hb_face_reference (source) : nullptr;
+
+  return face;
 }
commit 4e1abe2ce0b5163c8f8be0e9f7deba5ab2cb
Author: Garret Rieger 
Date:   Wed Feb 7 13:28:11 2018 -0800

Refactor subset glyf to remove multiple calls to glyf.fini()

diff --git a/src/hb-subset-glyf.cc b/src/hb-subset-glyf.cc
index e0ae5d80..6581754b 100644
--- a/src/hb-subset-glyf.cc
+++ b/src/hb-subset-glyf.cc
@@ -74,46 +74,30 @@ write_glyf_prime (const OT::glyf::accelerator_t ,
   return true;
 }
 
-/**
- * hb_subset_glyf:
- * Subsets the glyph table according to a provided plan.
- *
- * Return value: subsetted glyf table.
- *
- * Since: 1.7.5
- **/
 bool
-hb_subset_glyf (hb_subset_plan_t *plan,
-hb_face_t*face,
-hb_blob_t   **glyf_prime /* OUT */)
+_hb_subset_glyf (const OT::glyf::accelerator_t  ,
+ const char 

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

2018-01-30 Thread Behdad Esfahbod
 .travis.yml|2 
 CMakeLists.txt |   40 
++
 src/check-defs.sh  |4 -
 src/check-libstdc++.sh |   13 ++-
 src/hb-aat-layout-common-private.hh|   33 

 test/shaping/data/text-rendering-tests/DISABLED|7 +
 test/shaping/data/text-rendering-tests/Makefile.sources|7 +
 test/shaping/data/text-rendering-tests/fonts/TestMORXEighteen.ttf  |binary
 test/shaping/data/text-rendering-tests/fonts/TestMORXSeventeen.ttf |binary
 test/shaping/data/text-rendering-tests/fonts/TestMORXSixteen.ttf   |binary
 test/shaping/data/text-rendering-tests/fonts/TestMORXTwenty.ttf|binary
 test/shaping/data/text-rendering-tests/fonts/TestMORXTwentyone.ttf |binary
 test/shaping/data/text-rendering-tests/fonts/TestMORXTwentytwo.ttf |binary
 test/shaping/data/text-rendering-tests/tests/MORX-14.tests |1 
 test/shaping/data/text-rendering-tests/tests/MORX-16.tests |1 
 test/shaping/data/text-rendering-tests/tests/MORX-17.tests |1 
 test/shaping/data/text-rendering-tests/tests/MORX-18.tests |4 +
 test/shaping/data/text-rendering-tests/tests/MORX-19.tests |2 
 test/shaping/data/text-rendering-tests/tests/MORX-20.tests |7 +
 test/shaping/data/text-rendering-tests/tests/MORX-21.tests |1 
 test/shaping/data/text-rendering-tests/tests/MORX-22.tests |1 
 21 files changed, 72 insertions(+), 52 deletions(-)

New commits:
commit e89df6e1aee9cb6fe1268643ce19816808baf0c4
Author: Behdad Esfahbod 
Date:   Tue Jan 30 10:58:44 2018 -0800

[aat] Limit number of DontAdvance transitions

Remove the faulty loop-detection logic. Use max-ops for breaking
out of infinite loops or heavy work.

https://twitter.com/behdadesfahbod/status/958065026262183936

diff --git a/src/hb-aat-layout-common-private.hh 
b/src/hb-aat-layout-common-private.hh
index d62bafc5..b5395bba 100644
--- a/src/hb-aat-layout-common-private.hh
+++ b/src/hb-aat-layout-common-private.hh
@@ -615,13 +615,7 @@ struct StateTableDriver
  machine (machine_),
  buffer (buffer_),
  num_glyphs (face_->get_num_glyphs ()),
- last_zero (0),
- dont_advance_set (nullptr) {}
-
-  inline ~StateTableDriver (void)
-  {
-hb_set_destroy (dont_advance_set);
-  }
+ last_zero (0) {}
 
   template 
   inline void drive (context_t *c)
@@ -648,27 +642,7 @@ struct StateTableDriver
   if (unlikely (!c->transition (this, entry)))
 break;
 
-  if (entry->flags & context_t::DontAdvance)
-  {
-if (!last_was_dont_advance)
-   {
- if (dont_advance_set)
-   dont_advance_set->clear ();
- else
-   dont_advance_set = hb_set_create ();
-   }
-
-   unsigned int key = info[buffer->idx].codepoint ^ (state << 16);
-   if (likely (!dont_advance_set->has (key)))
-   {
- dont_advance_set->add (key);
- last_was_dont_advance = true;
-   }
-   else
- last_was_dont_advance = false;
-  }
-  else
-last_was_dont_advance = false;
+  last_was_dont_advance = (entry->flags & context_t::DontAdvance) && 
buffer->max_ops--;
 
   state = entry->newState;
 
@@ -692,9 +666,6 @@ struct StateTableDriver
   hb_buffer_t *buffer;
   unsigned int num_glyphs;
   unsigned int last_zero;
-
-  private:
-  hb_set_t *dont_advance_set; /* Infinite-loop detection */
 };
 
 
commit e00743b47d25a2487b7f232a514a042e2962a089
Author: Behdad Esfahbod 
Date:   Mon Jan 29 10:07:05 2018 -0800

[test/text-rendering-tests] Update from upstream

diff --git a/test/shaping/data/text-rendering-tests/DISABLED 
b/test/shaping/data/text-rendering-tests/DISABLED
index 45b8510a..1439d43f 100644
--- a/test/shaping/data/text-rendering-tests/DISABLED
+++ b/test/shaping/data/text-rendering-tests/DISABLED
@@ -16,6 +16,13 @@ tests/MORX-11.tests
 tests/MORX-12.tests
 tests/MORX-13.tests
 tests/MORX-14.tests
+tests/MORX-16.tests
+tests/MORX-17.tests
+tests/MORX-18.tests
+tests/MORX-19.tests
+tests/MORX-20.tests
+tests/MORX-21.tests
+tests/MORX-22.tests
 
 # Rounding differences
 tests/SHARAN-1.tests
diff --git a/test/shaping/data/text-rendering-tests/Makefile.sources 
b/test/shaping/data/text-rendering-tests/Makefile.sources
index 311812c7..c28487f8 100644
--- a/test/shaping/data/text-rendering-tests/Makefile.sources
+++ b/test/shaping/data/text-rendering-tests/Makefile.sources
@@ -39,6 +39,13 @@ DISBALED_TESTS = \
tests/MORX-12.tests \
tests/MORX-13.tests \
tests/MORX-14.tests \
+   tests/MORX-16.tests \
+   tests/MORX-17.tests \
+   tests/MORX-18.tests \
+   tests/MORX-19.tests \
+   

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

2018-01-22 Thread Behdad Esfahbod
 .circleci/config.yml |   12 ++--
 .travis.yml  |   10 +-
 CMakeLists.txt   |   17 ++---
 src/hb-blob.h|2 +-
 src/hb-buffer.h  |4 ++--
 5 files changed, 28 insertions(+), 17 deletions(-)

New commits:
commit 3d615766060e34a6e716c8737f651b6d6871ae85
Author: Ebrahim Byagowi 
Date:   Mon Jan 22 21:23:19 2018 +0330

[cmake] fix symbol exporting issue on newer gcc (#724)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15d3e93d..f5d9c173 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,7 +269,7 @@ if (HB_HAVE_FREETYPE)
 
   list(APPEND THIRD_PARTY_LIBS ${FREETYPE_LIBRARIES})
   include_directories(AFTER ${FREETYPE_INCLUDE_DIRS})
-  add_definitions(-DHAVE_FREETYPE=1 -DHAVE_FT_FACE_GETCHARVARIANTINDEX=1)
+  add_definitions(-DHAVE_FREETYPE=1)
 
   list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-ft.cc)
   list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-ft.h)
@@ -355,7 +355,7 @@ if (APPLE AND HB_HAVE_CORETEXT)
   if (APPLICATION_SERVICES_FRAMEWORK)
 list(APPEND THIRD_PARTY_LIBS ${APPLICATION_SERVICES_FRAMEWORK})
   endif (APPLICATION_SERVICES_FRAMEWORK)
-  
+
   mark_as_advanced(APPLICATION_SERVICES_FRAMEWORK)
 endif ()
 
@@ -380,7 +380,7 @@ endif ()
 if (HB_HAVE_GOBJECT)
   include (FindPythonInterp)
   include (FindPerl)
-  
+
   # Use the hints from glib-2.0.pc to find glib-mkenums
   find_package(PkgConfig)
   pkg_check_modules(PC_GLIB QUIET glib-2.0)
@@ -530,7 +530,8 @@ if (UNIX OR MINGW)
   ))
 set (CMAKE_CXX_FLAGS "-fno-rtti -fno-exceptions ${CMAKE_CXX_FLAGS}")
   endif ()
-  set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
+  add_definitions(-D__CORRECT_ISO_CPP11_MATH_H_PROTO_FP)
+  set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "c;m") # libc and libm
   set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
   set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C)
 
@@ -790,7 +791,8 @@ endif ()
 ## Tests
 if (UNIX OR MINGW)
   if (BUILD_SHARED_LIBS)
-string(REPLACE ";" " " space_separated_headers "${project_headers}")  
+# generate harfbuzz.def after build completion
+string(REPLACE ";" " " space_separated_headers "${project_headers}")
 add_custom_command(TARGET harfbuzz POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E env "headers=${space_separated_headers}" 
python ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def
   WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src)
@@ -800,13 +802,11 @@ if (UNIX OR MINGW)
   WORKING_DIRECTORY 
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/harfbuzz.dir/src # ugly hack
 )
 add_test(NAME check-libstdc++.sh COMMAND 
${PROJECT_SOURCE_DIR}/src/check-libstdc++.sh)
-set_tests_properties(check-static-inits.sh check-libstdc++.sh PROPERTIES 
ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src")
+add_test(NAME check-symbols.sh COMMAND 
${PROJECT_SOURCE_DIR}/src/check-symbols.sh)
+add_test(NAME check-defs.sh COMMAND 
${PROJECT_SOURCE_DIR}/src/check-defs.sh)
 
-if (APPLE) # doesn't work on Linux it seems
-  add_test(NAME check-symbols.sh COMMAND 
${PROJECT_SOURCE_DIR}/src/check-symbols.sh)
-  add_test(NAME check-defs.sh COMMAND 
${PROJECT_SOURCE_DIR}/src/check-defs.sh)
-  set_tests_properties(check-symbols.sh check-defs.sh PROPERTIES 
ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src")
-endif ()
+set_tests_properties(check-static-inits.sh check-libstdc++.sh 
check-symbols.sh check-defs.sh
+  PROPERTIES ENVIRONMENT "libs=.;srcdir=${PROJECT_SOURCE_DIR}/src")
   endif ()
 
   add_test(NAME check-c-linkage-decls.sh COMMAND ./check-c-linkage-decls.sh)
commit 8b60e7c2c301a24906d591c80c42fd5e506072d2
Author: Ebrahim Byagowi 
Date:   Mon Jan 22 18:37:26 2018 +0330

[ci] minor, less hacks (#722)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index d7ea2567..11ca1d7a 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -4,16 +4,12 @@ jobs:
 
   distcheck:
 docker:
-  - image: dockcross/base
+  - image: ubuntu:17.10
 steps:
   - checkout
-  - run: apt update && apt install -y pkg-config ragel gtk-doc-tools 
libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev
-
-  - run: apt-cache policy libfreetype6-dev && echo  revert 
https://github.com/harfbuzz/harfbuzz/pull/718 when this updated  1>&2
-  - run: wget 
http://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.bz2 && tar 
xf freetype-2.9.tar.bz2 && cd freetype-2.9 && ./autogen.sh && ./configure && 
make -j4 && sudo make install && cd ..
-
-  - run: ./autogen.sh && 
LD_PRELOAD="$PWD/freetype-2.9/objs/.libs/libfreetype.so" make distcheck
-  - run: make distdir && cd harfbuzz-* && cmake -DDHB_CHECK=ON -Bbuild -H. 
-GNinja && ninja -Cbuild && CTEST_OUTPUT_ON_FAILURE=1 ninja -Cbuild test && 
ninja -Cbuild install
+  - run: apt update && apt install -y ninja-build binutils libtool 
autoconf automake make cmake gcc g++ pkg-config ragel 

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

2018-01-10 Thread Behdad Esfahbod
 .circleci/config.yml|4 +-
 CMakeLists.txt  |   53 +++-
 src/hb-aat-layout-common-private.hh |   24 
 src/hb-buffer.h |3 +-
 test/shaping/CMakeLists.txt |   13 ++--
 util/options.cc |4 ++
 6 files changed, 77 insertions(+), 24 deletions(-)

New commits:
commit ff2083c53eecc67c011b96b0b9a58331043e53cf
Author: Behdad Esfahbod 
Date:   Wed Jan 10 13:54:36 2018 +0100

[util] Set stdio files to line buffering

So we can stream lines to hb-shape and read output.

diff --git a/util/options.cc b/util/options.cc
index f6360725..243b49b1 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -780,6 +780,8 @@ text_options_t::get_line (unsigned int *len)
 gs = g_string_new (nullptr);
   }
 
+  setlinebuf (fp);
+
   g_string_set_size (gs, 0);
   char buf[BUFSIZ];
   while (fgets (buf, sizeof (buf), fp)) {
@@ -817,6 +819,8 @@ output_options_t::get_file_handle (void)
 fail (false, "Cannot open output file `%s': %s",
  g_filename_display_name (output_file), strerror (errno));
 
+  setlinebuf (fp);
+
   return fp;
 }
 
commit 80fd5743200cbe221ae3adf057fe0e5ef54a894c
Author: Behdad Esfahbod 
Date:   Wed Jan 10 11:09:53 2018 +0100

[aat] Add Class subtable thingy

From old 'mort' table.

diff --git a/src/hb-aat-layout-common-private.hh 
b/src/hb-aat-layout-common-private.hh
index c3058682..4b96ee6c 100644
--- a/src/hb-aat-layout-common-private.hh
+++ b/src/hb-aat-layout-common-private.hh
@@ -424,6 +424,30 @@ struct Lookup
 };
 
 
+struct Class
+{
+  inline unsigned int get_class (hb_codepoint_t glyph_id) const
+  {
+return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? 
classArrayZ[glyph_id - firstGlyph] : 1;
+  }
+
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+TRACE_SANITIZE (this);
+return_trace (c->check_struct (this) && classArrayZ.sanitize (c, 
glyphCount));
+  }
+
+  protected:
+  GlyphID  firstGlyph; /* First glyph index included in the trimmed 
array. */
+  HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the 
last
+* glyph minus the value of firstGlyph plus 1). 
*/
+  UnsizedArrayOf
+   classArrayZ;/* The class codes (indexed by glyph index minus
+* firstGlyph). */
+  public:
+  DEFINE_SIZE_ARRAY (4, classArrayZ);
+};
+
 } /* namespace AAT */
 
 
commit 71e0ed9cbad8438239dcedf1bcfa8e19b9dfdc89
Author: Ebrahim Byagowi 
Date:   Wed Jan 10 15:45:12 2018 +0330

[cmake] Add header existence tests (#685)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 2a82abaa..8c02624e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -138,8 +138,8 @@ workflows:
   version: 2
   build:
 jobs:
-  - oracledeveloperstudio
-  - fedora-out-of-tree
+  #- oracledeveloperstudio
+  #- fedora-out-of-tree
   - archlinux
   - freebsd9
   - base
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b61d6605..a2599b54 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -89,15 +89,34 @@ include_directories(AFTER
 add_definitions(-DHAVE_OT)
 add_definitions(-DHAVE_FALLBACK)
 
-include(CheckFunctionExists)
-check_function_exists(atexit HAVE_ATEXIT)
-check_function_exists(mprotect HAVE_MPROTECT)
-check_function_exists(sysconf HAVE_SYSCONF)
-check_function_exists(getpagesize HAVE_GETPAGESIZE)
-check_function_exists(mmap HAVE_MMAP)
-check_function_exists(isatty HAVE_ISATTY)
-check_function_exists(newlocale HAVE_NEWLOCALE)
-check_function_exists(strtod_l HAVE_STRTOD_L)
+
+include (CheckFunctionExists)
+include (CheckIncludeFile)
+macro (check_funcs) # Similar to AC_CHECK_FUNCS of autotools
+  foreach (func_name ${ARGN})
+set (RESULT OFF)
+check_function_exists(${func_name} RESULT)
+if (${RESULT})
+  string(TOUPPER ${func_name} definiton_to_add)
+  add_definitions(-DHAVE_${definiton_to_add})
+endif ()
+  endforeach ()
+endmacro ()
+check_funcs(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l)
+
+check_include_file(unistd.h HAVE_UNIST_H)
+if (${HAVE_UNIST_H})
+  add_definitions(-DHAVE_UNIST_H)
+endif ()
+#check_include_file(sys/mman.h HAVE_SYS_MMAN_H) enable this sometime
+#if (${HAVE_SYS_MMAN_H})
+#  add_definitions(-DHAVE_SYS_MMAN_H)
+#endif ()
+check_include_file(xlocale.h HAVE_XLOCALE_H)
+if (${HAVE_XLOCALE_H})
+  add_definitions(-DHAVE_XLOCALE_H)
+endif ()
+
 
 if (MSVC)
   add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS 
-D_CRT_NONSTDC_NO_WARNINGS)
@@ -237,7 +256,7 @@ set (project_headers
 
 ## Find and include needed header folders and libraries
 if (HB_HAVE_FREETYPE)
-  include(FindFreetype)
+  include (FindFreetype)
   if (NOT FREETYPE_FOUND)
 message(FATAL_ERROR "HB_HAVE_FREETYPE was set, but we failed to find it. 
Maybe add a 

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

2017-10-27 Thread Behdad Esfahbod
 src/hb-glib.cc |   36 +-
 src/hb-icu.cc  |   51 ++---
 src/hb-open-type-private.hh|   10 ---
 src/hb-ot-layout.cc|3 ++
 src/hb-ot-shape-complex-arabic.cc  |1 
 src/hb-ot-shape-complex-default.cc |1 
 src/hb-ot-shape-complex-hangul.cc  |1 
 src/hb-ot-shape-complex-hebrew.cc  |1 
 src/hb-ot-shape-complex-indic.cc   |1 
 src/hb-ot-shape-complex-myanmar.cc |2 -
 src/hb-ot-shape-complex-private.hh |2 -
 src/hb-ot-shape-complex-thai.cc|1 
 src/hb-ot-shape-complex-tibetan.cc |1 
 src/hb-ot-shape-complex-use.cc |1 
 src/hb-private.hh  |2 -
 src/hb-ucdn.cc |   37 +-
 src/main.cc|1 
 17 files changed, 106 insertions(+), 46 deletions(-)

New commits:
commit 8864864b624590d95ae5dca61956695cbff1269a
Author: Behdad Esfahbod 
Date:   Fri Oct 27 15:26:45 2017 -0600

[glib/icu/ucdn] Make the funcs object allocated on demand

diff --git a/src/hb-glib.cc b/src/hb-glib.cc
index 5b0a1eb3..c8863ea7 100644
--- a/src/hb-glib.cc
+++ b/src/hb-glib.cc
@@ -364,22 +364,44 @@ hb_glib_unicode_decompose_compatibility 
(hb_unicode_funcs_t *ufuncs HB_UNUSED,
   return utf8_decomposed_len;
 }
 
+static hb_unicode_funcs_t *static_glib_funcs = nullptr;
+
+#ifdef HB_USE_ATEXIT
+static
+void free_static_glib_funcs (void)
+{
+  hb_unicode_funcs_destroy (static_glib_funcs);
+}
+#endif
+
 hb_unicode_funcs_t *
 hb_glib_get_unicode_funcs (void)
 {
-  static const hb_unicode_funcs_t _hb_glib_unicode_funcs = {
-HB_OBJECT_HEADER_STATIC,
+retry:
+  hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get 
(_glib_funcs);
 
-nullptr, /* parent */
-true, /* immutable */
-{
-#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_glib_unicode_##name,
+  if (unlikely (!funcs))
+  {
+funcs = hb_unicode_funcs_create (nullptr);
+
+#define HB_UNICODE_FUNC_IMPLEMENT(name) \
+hb_unicode_funcs_set_##name##_func (funcs, hb_glib_unicode_##name, 
nullptr, nullptr);
   HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
 #undef HB_UNICODE_FUNC_IMPLEMENT
+
+hb_unicode_funcs_make_immutable (funcs);
+
+if (!hb_atomic_ptr_cmpexch (_glib_funcs, nullptr, funcs)) {
+  hb_unicode_funcs_destroy (funcs);
+  goto retry;
 }
+
+#ifdef HB_USE_ATEXIT
+atexit (free_static_glib_funcs); /* First person registers atexit() 
callback. */
+#endif
   };
 
-  return const_cast (&_hb_glib_unicode_funcs);
+  return funcs;
 }
 
 #if GLIB_CHECK_VERSION(2,31,10)
diff --git a/src/hb-icu.cc b/src/hb-icu.cc
index 01d15f48..2550e438 100644
--- a/src/hb-icu.cc
+++ b/src/hb-icu.cc
@@ -345,27 +345,50 @@ hb_icu_unicode_decompose_compatibility 
(hb_unicode_funcs_t *ufuncs HB_UNUSED,
 }
 
 
+static hb_unicode_funcs_t *static_icu_funcs = nullptr;
+
+#ifdef HB_USE_ATEXIT
+static
+void free_static_icu_funcs (void)
+{
+  hb_unicode_funcs_destroy (static_icu_funcs);
+}
+#endif
+
 hb_unicode_funcs_t *
 hb_icu_get_unicode_funcs (void)
 {
-  static const hb_unicode_funcs_t _hb_icu_unicode_funcs = {
-HB_OBJECT_HEADER_STATIC,
+retry:
+  hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get 
(_icu_funcs);
+
+  if (unlikely (!funcs))
+  {
+#if U_ICU_VERSION_MAJOR_NUM >= 49
+if (!hb_atomic_ptr_get ()) {
+  UErrorCode icu_err = U_ZERO_ERROR;
+  /* We ignore failure in getNFCInstace(). */
+  (void) hb_atomic_ptr_cmpexch (, nullptr, 
unorm2_getNFCInstance (_err));
+}
+#endif
 
-nullptr, /* parent */
-true, /* immutable */
-{
-#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_icu_unicode_##name,
+funcs = hb_unicode_funcs_create (nullptr);
+
+#define HB_UNICODE_FUNC_IMPLEMENT(name) \
+hb_unicode_funcs_set_##name##_func (funcs, hb_icu_unicode_##name, nullptr, 
nullptr);
   HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
 #undef HB_UNICODE_FUNC_IMPLEMENT
+
+hb_unicode_funcs_make_immutable (funcs);
+
+if (!hb_atomic_ptr_cmpexch (_icu_funcs, nullptr, funcs)) {
+  hb_unicode_funcs_destroy (funcs);
+  goto retry;
 }
-  };
 
-#if U_ICU_VERSION_MAJOR_NUM >= 49
-  if (!hb_atomic_ptr_get ()) {
-UErrorCode icu_err = U_ZERO_ERROR;
-/* We ignore failure in getNFCInstace(). */
-(void) hb_atomic_ptr_cmpexch (, nullptr, unorm2_getNFCInstance 
(_err));
-  }
+#ifdef HB_USE_ATEXIT
+atexit (free_static_icu_funcs); /* First person registers atexit() 
callback. */
 #endif
-  return const_cast (&_hb_icu_unicode_funcs);
+  };
+
+  return funcs;
 }
diff --git a/src/hb-ucdn.cc b/src/hb-ucdn.cc
index c237ee82..e51f0353 100644
--- a/src/hb-ucdn.cc
+++ b/src/hb-ucdn.cc
@@ -231,22 +231,43 @@ hb_ucdn_decompose_compatibility(hb_unicode_funcs_t 
*ufuncs HB_UNUSED,
 return ucdn_compat_decompose(u, decomposed);
 }
 
+static hb_unicode_funcs_t *static_ucdn_funcs = nullptr;
+
+#ifdef HB_USE_ATEXIT
+static
+void free_static_ucdn_funcs (void)
+{
+  

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

2017-10-04 Thread Behdad Esfahbod
 src/hb-ot-layout-private.hh |2 
 src/hb-ot-shape-complex-arabic.cc   |   75 
++
 src/hb-ot-shape-complex-default.cc  |1 
 src/hb-ot-shape-complex-hangul.cc   |1 
 src/hb-ot-shape-complex-hebrew.cc   |1 
 src/hb-ot-shape-complex-indic.cc|1 
 src/hb-ot-shape-complex-myanmar.cc  |2 
 src/hb-ot-shape-complex-private.hh  |   12 
+
 src/hb-ot-shape-complex-thai.cc |1 
 src/hb-ot-shape-complex-tibetan.cc  |1 
 src/hb-ot-shape-complex-use.cc  |1 
 src/hb-ot-shape-normalize.cc|   72 
+
 src/hb-unicode-private.hh   |6 
 test/shaping/Makefile.am|1 
 test/shaping/fonts/sha1sum/24b8d24d00ae86f49791b746da4c9d3f717a51a8.ttf |binary
 test/shaping/fonts/sha1sum/94a5d6fb15a27521fba9ea4aee9cb39b2d03322a.ttf |binary
 test/shaping/record-test.sh |2 
 test/shaping/tests/arabic-mark-order.tests  |2 
 18 files changed, 147 insertions(+), 34 deletions(-)

New commits:
commit ab8d70ec7023e51ba6fd7267d2b41c5f95ef0787
Author: Behdad Esfahbod 
Date:   Wed Oct 4 14:47:10 2017 +0200

[arabic] Implement Unicode Arabic Mark Ordering Algorithm UTR#53

Fixes https://github.com/behdad/harfbuzz/issues/509

diff --git a/src/hb-ot-shape-complex-arabic.cc 
b/src/hb-ot-shape-complex-arabic.cc
index ed7b3f2d..28dd4e1f 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -613,6 +613,80 @@ postprocess_glyphs_arabic (const hb_ot_shape_plan_t *plan,
   HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
 }
 
+/* http://www.unicode.org/reports/tr53/tr53-1.pdf */
+
+static hb_codepoint_t
+modifier_combining_marks[] =
+{
+  0x0654u, /* ARABIC HAMZA ABOVE */
+  0x0655u, /* ARABIC HAMZA BELOW */
+  0x0658u, /* ARABIC MARK NOON GHUNNA */
+  0x06DCu, /* ARABIC SMALL HIGH SEEN */
+  0x06E3u, /* ARABIC SMALL LOW SEEN */
+  0x06E7u, /* ARABIC SMALL HIGH YEH */
+  0x06E8u, /* ARABIC SMALL HIGH NOON */
+  0x08F3u, /* ARABIC SMALL HIGH WAW */
+};
+
+static inline bool
+info_is_mcm (const hb_glyph_info_t )
+{
+  hb_codepoint_t u = info.codepoint;
+  for (unsigned int i = 0; i < ARRAY_LENGTH (modifier_combining_marks); i++)
+if (u == modifier_combining_marks[i])
+  return true;
+  return false;
+}
+
+static void
+reorder_marks_arabic (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t  *buffer,
+ unsigned int  start,
+ unsigned int  end)
+{
+  hb_glyph_info_t *info = buffer->info;
+
+  unsigned int i = start;
+  for (unsigned int cc = 220; cc <= 230; cc += 10)
+  {
+DEBUG_MSG (ARABIC, buffer, "Looking for %d's starting at %d\n", cc, i);
+while (i < end && info_cc(info[i]) < cc)
+  i++;
+DEBUG_MSG (ARABIC, buffer, "Looking for %d's stopped at %d\n", cc, i);
+
+if (i == end)
+  break;
+
+if (info_cc(info[i]) > cc)
+  continue;
+
+/* Technically we should also check "info_cc(info[j]) == cc"
+ * in the following loop.  But not doing it is safe; we might
+ * end up moving all the 220 MCMs and 230 MCMs together in one
+ * move and be done. */
+unsigned int j = i;
+while (j < end && info_is_mcm (info[j]))
+  j++;
+DEBUG_MSG (ARABIC, buffer, "Found %d's from %d to %d\n", cc, i, j);
+
+if (i == j)
+  continue;
+
+/* Shift it! */
+DEBUG_MSG (ARABIC, buffer, "Shifting %d's: %d %d\n", cc, i, j);
+hb_glyph_info_t temp[HB_OT_SHAPE_COMPLEX_MAX_COMBINING_MARKS];
+assert (j - i <= ARRAY_LENGTH (temp));
+buffer->merge_out_clusters (start, j);
+memmove (temp, [i], (j - i) * sizeof (hb_glyph_info_t));
+memmove ([start + j - i], [start], (i - start) * sizeof 
(hb_glyph_info_t));
+memmove ([start], temp, (j - i) * sizeof (hb_glyph_info_t));
+
+start += j - i;
+
+i = j;
+  }
+}
+
 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
 {
   "arabic",
@@ -627,6 +701,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
   NULL, /* compose */
   setup_masks_arabic,
   NULL, /* disable_otl */
+  reorder_marks_arabic,
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,
   true, /* fallback_position */
 };
diff --git a/src/hb-ot-shape-complex-default.cc 
b/src/hb-ot-shape-complex-default.cc
index 42830ab6..857980cf 100644
--- a/src/hb-ot-shape-complex-default.cc
+++ b/src/hb-ot-shape-complex-default.cc
@@ -41,6 +41,7 @@ 

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

2017-09-01 Thread Behdad Esfahbod
 src/hb-buffer.cc|   16 
+++
 src/hb-ot-shape-complex-indic-private.hh|2 
 src/hb-ot-shape.cc  |2 
 test/shaping/fonts/sha1sum/3d0b77a2360aa6faa1385aaa510509ab70dfbeff.ttf |binary
 test/shaping/run-tests.sh   |4 
-
 test/shaping/tests/indic-syllable.tests |3 
-
 util/options.hh |   21 
+-
 util/view-cairo.hh  |2 
 8 files changed, 28 insertions(+), 22 deletions(-)

New commits:
commit 06cb162cd79cc922b572e5f532ca867223b6dc4c
Author: Behdad Esfahbod 
Date:   Fri Sep 1 10:34:21 2017 -0700

[indic] Treat Consonant_With_Stacker as consonant

Fixes https://github.com/behdad/harfbuzz/issues/528
"Kannada JIHVAMULIYA and UPADHMANIYA insert dotted circles"

diff --git a/src/hb-ot-shape-complex-indic-private.hh 
b/src/hb-ot-shape-complex-indic-private.hh
index 58be4222..c880311e 100644
--- a/src/hb-ot-shape-complex-indic-private.hh
+++ b/src/hb-ot-shape-complex-indic-private.hh
@@ -121,7 +121,7 @@ enum indic_syllabic_category_t {
   INDIC_SYLLABIC_CATEGORY_CONSONANT_PREFIXED   = OT_X, /* Don't care. 
*/
   INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED  = OT_CM,
   INDIC_SYLLABIC_CATEGORY_CONSONANT_SUCCEEDING_REPHA   = OT_N,
-  INDIC_SYLLABIC_CATEGORY_CONSONANT_WITH_STACKER   = OT_Repha, /* TODO */
+  INDIC_SYLLABIC_CATEGORY_CONSONANT_WITH_STACKER   = OT_C,
   INDIC_SYLLABIC_CATEGORY_GEMINATION_MARK  = OT_SM,
   INDIC_SYLLABIC_CATEGORY_INVISIBLE_STACKER= OT_Coeng,
   INDIC_SYLLABIC_CATEGORY_JOINER   = OT_ZWJ,
diff --git 
a/test/shaping/fonts/sha1sum/3d0b77a2360aa6faa1385aaa510509ab70dfbeff.ttf 
b/test/shaping/fonts/sha1sum/3d0b77a2360aa6faa1385aaa510509ab70dfbeff.ttf
new file mode 100644
index ..d7db1de2
Binary files /dev/null and 
b/test/shaping/fonts/sha1sum/3d0b77a2360aa6faa1385aaa510509ab70dfbeff.ttf differ
diff --git a/test/shaping/tests/indic-syllable.tests 
b/test/shaping/tests/indic-syllable.tests
index 26c38b35..37eaadcd 100644
--- a/test/shaping/tests/indic-syllable.tests
+++ b/test/shaping/tests/indic-syllable.tests
@@ -1 +1,2 @@
-fonts/sha1sum/54674a3111d209fb6be0ed31745314b7a8d2c244.ttf::U+0BA4,U+0BCD,U+00B3:[taprehalftamil=0+1509|uni00B3=2+674]
+fonts/sha1sum/3d0b77a2360aa6faa1385aaa510509ab70dfbeff.ttf::U+0CF1:[gid1=0+1129]
+fonts/sha1sum/3d0b77a2360aa6faa1385aaa510509ab70dfbeff.ttf::U+0CF2:[gid2=0+1539]
commit c449d2d8c9e27502380faa0b568a374c838ac9a7
Author: Behdad Esfahbod 
Date:   Wed Aug 30 17:28:22 2017 -0700

[unsafe-to-break] Mark during fraction-slash formation

Fixes tests/automatic-fractions.tests

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index bc536696..54c33a3e 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -394,6 +394,8 @@ hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c)
 HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER)
 end++;
 
+  buffer->unsafe_to_break (start, end);
+
   for (unsigned int j = start; j < i; j++)
 info[j].mask |= pre_mask;
   info[i].mask |= c->plan->frac_mask;
commit b262ebcc9c9539076d17751e9bae06a8fd5001ff
Author: Behdad Esfahbod 
Date:   Wed Aug 30 17:25:10 2017 -0700

[util] Fix cluster sweeping during --verify

If *I* get this wrong in 2017, I have no idea how others get their head 
around
cluster math...

Fixes tests/arabic-fallback-shaping.tests

diff --git a/util/options.hh b/util/options.hh
index 42bb8c46..b24ab0c8 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -366,13 +366,18 @@ struct shape_options_t : option_group_t
   }
   else
   {
-   unsigned int cluster = info[end].cluster;
if (forward)
- while (text_end < num_chars && text[text_end].cluster != cluster)
+   {
+ unsigned int cluster = info[end].cluster;
+ while (text_end < num_chars && text[text_end].cluster < cluster)
text_end++;
+   }
else
- while (text_start && text[text_start - 1].cluster != cluster)
+   {
+ unsigned int cluster = info[end - 1].cluster;
+ while (text_start && text[text_start - 1].cluster >= cluster)
text_start--;
+   }
   }
   assert (text_start < text_end);
 
commit 69d701b02e5ebc3597b0d0576dbab8e1ece51944
Author: Behdad Esfahbod 
Date:   Wed Aug 30 17:07:29 2017 -0700

[util] When --verify fails, return reconstructed shape results

diff --git a/util/options.hh b/util/options.hh
index 9ad2225d..42bb8c46 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -416,11 +416,9 @@ struct shape_options_t : option_group_t
*error = 

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

2016-05-06 Thread Behdad Esfahbod
 BUILD.md   
   |9 +
 src/gen-indic-table.py 
   |1 
 src/hb-ot-shape-complex-indic-machine.rl   
   |3 
 src/hb-ot-shape-complex-indic-private.hh   
   |5 
 src/hb-ot-shape-complex-indic-table.cc 
   |   23 
 src/hb-ot-shape-complex-indic.cc   
   |   54 +++---
 src/hb-ot-shape-complex-private.hh 
   |5 
 
test/shaping/texts/in-tree/shaper-indic/south-east-asian/script-javanese/misc.txt
 |   54 ++
 8 files changed, 86 insertions(+), 68 deletions(-)

New commits:
commit 3c1666cfb589275de96d54eecb95a13a98e3819e
Author: Behdad Esfahbod 
Date:   Fri May 6 16:05:07 2016 +0100

[indic] Remove more unused logic after Javanese is gone

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 9355098..2451078 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -274,11 +274,6 @@ enum blwf_mode_t {
   BLWF_MODE_PRE_AND_POST, /* Below-forms feature applied to pre-base and 
post-base. */
   BLWF_MODE_POST_ONLY /* Below-forms feature applied to post-base only. */
 };
-enum pref_len_t {
-  PREF_LEN_1 = 1,
-  PREF_LEN_2 = 2,
-  PREF_LEN_DONT_CARE = PREF_LEN_2
-};
 struct indic_config_t
 {
   hb_script_t script;
@@ -288,25 +283,24 @@ struct indic_config_t
   reph_position_t reph_pos;
   reph_mode_t reph_mode;
   blwf_mode_t blwf_mode;
-  pref_len_t  pref_len;
 };
 
 static const indic_config_t indic_configs[] =
 {
   /* Default.  Should be first. */
-  {HB_SCRIPT_INVALID,  false,  0,BASE_POS_LAST, 
REPH_POS_BEFORE_POST,REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_1},
-  {HB_SCRIPT_DEVANAGARI,true, 0x094Du,BASE_POS_LAST, 
REPH_POS_BEFORE_POST,REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, 
PREF_LEN_DONT_CARE},
-  {HB_SCRIPT_BENGALI,  true, 0x09CDu,BASE_POS_LAST, REPH_POS_AFTER_SUB,  
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
-  {HB_SCRIPT_GURMUKHI, true, 0x0A4Du,BASE_POS_LAST, REPH_POS_BEFORE_SUB, 
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
-  {HB_SCRIPT_GUJARATI, true, 0x0ACDu,BASE_POS_LAST, 
REPH_POS_BEFORE_POST,REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, 
PREF_LEN_DONT_CARE},
-  {HB_SCRIPT_ORIYA,true, 0x0B4Du,BASE_POS_LAST, REPH_POS_AFTER_MAIN, 
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
-  {HB_SCRIPT_TAMIL,true, 0x0BCDu,BASE_POS_LAST, REPH_POS_AFTER_POST, 
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_2},
-  {HB_SCRIPT_TELUGU,   true, 0x0C4Du,BASE_POS_LAST, REPH_POS_AFTER_POST, 
REPH_MODE_EXPLICIT, BLWF_MODE_POST_ONLY,PREF_LEN_2},
-  {HB_SCRIPT_KANNADA,  true, 0x0CCDu,BASE_POS_LAST, REPH_POS_AFTER_POST, 
REPH_MODE_IMPLICIT, BLWF_MODE_POST_ONLY,PREF_LEN_2},
-  {HB_SCRIPT_MALAYALAM,true, 0x0D4Du,BASE_POS_LAST, 
REPH_POS_AFTER_MAIN, REPH_MODE_LOG_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_2},
+  {HB_SCRIPT_INVALID,  false,  0,BASE_POS_LAST, 
REPH_POS_BEFORE_POST,REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_DEVANAGARI,true, 0x094Du,BASE_POS_LAST, 
REPH_POS_BEFORE_POST,REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_BENGALI,  true, 0x09CDu,BASE_POS_LAST, REPH_POS_AFTER_SUB,  
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_GURMUKHI, true, 0x0A4Du,BASE_POS_LAST, REPH_POS_BEFORE_SUB, 
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_GUJARATI, true, 0x0ACDu,BASE_POS_LAST, 
REPH_POS_BEFORE_POST,REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_ORIYA,true, 0x0B4Du,BASE_POS_LAST, REPH_POS_AFTER_MAIN, 
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_TAMIL,true, 0x0BCDu,BASE_POS_LAST, REPH_POS_AFTER_POST, 
REPH_MODE_IMPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_TELUGU,   true, 0x0C4Du,BASE_POS_LAST, REPH_POS_AFTER_POST, 
REPH_MODE_EXPLICIT, BLWF_MODE_POST_ONLY},
+  {HB_SCRIPT_KANNADA,  true, 0x0CCDu,BASE_POS_LAST, REPH_POS_AFTER_POST, 
REPH_MODE_IMPLICIT, BLWF_MODE_POST_ONLY},
+  {HB_SCRIPT_MALAYALAM,true, 0x0D4Du,BASE_POS_LAST, 
REPH_POS_AFTER_MAIN, REPH_MODE_LOG_REPHA,BLWF_MODE_PRE_AND_POST},
   {HB_SCRIPT_SINHALA,  false,0x0DCAu,BASE_POS_LAST_SINHALA,
-REPH_POS_AFTER_MAIN, 
REPH_MODE_EXPLICIT, BLWF_MODE_PRE_AND_POST, PREF_LEN_DONT_CARE},
-  {HB_SCRIPT_KHMER,false,0x17D2u,BASE_POS_FIRST,REPH_POS_DONT_CARE,  
REPH_MODE_VIS_REPHA,BLWF_MODE_PRE_AND_POST, PREF_LEN_2},
+REPH_POS_AFTER_MAIN, 
REPH_MODE_EXPLICIT, BLWF_MODE_PRE_AND_POST},
+  {HB_SCRIPT_KHMER,false,0x17D2u,BASE_POS_FIRST,REPH_POS_DONT_CARE,  
REPH_MODE_VIS_REPHA,BLWF_MODE_PRE_AND_POST},
 };
 
 
@@ -584,12 +578,8 

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

2016-05-06 Thread Behdad Esfahbod
 src/gen-indic-table.py  |   33 +
 src/hb-common.cc|3 
 src/hb-common.h |   22 -
 src/hb-ot-shape-complex-arabic-table.hh |   56 +--
 src/hb-ot-shape-complex-indic-table.cc  |  591 ++--
 src/hb-ot-shape-complex-private.hh  |9 
 src/hb-ot-shape-complex-use-table.cc|   86 +++-
 src/hb-ot-shape-complex-use.cc  |3 
 8 files changed, 197 insertions(+), 606 deletions(-)

New commits:
commit 01a30a6aa9a5827c93245961e3392a1f361745fe
Author: Behdad Esfahbod 
Date:   Fri May 6 11:50:02 2016 +0100

[indic] Remove data for scripts that don't go thorough this shaper

diff --git a/src/gen-indic-table.py b/src/gen-indic-table.py
index 095888f..cc39481 100755
--- a/src/gen-indic-table.py
+++ b/src/gen-indic-table.py
@@ -6,7 +6,30 @@ if len (sys.argv) != 4:
print >>sys.stderr, "usage: ./gen-indic-table.py 
IndicSyllabicCategory.txt IndicPositionalCategory.txt Blocks.txt"
sys.exit (1)
 
-BLACKLISTED_BLOCKS = ["Thai", "Lao", "Tibetan"]
+ALLOWED_SINGLES = [0x00A0, 0x25CC]
+ALLOWED_BLOCKS = [
+   'Basic Latin',
+   'Latin-1 Supplement',
+   'Devanagari',
+   'Bengali',
+   'Gurmukhi',
+   'Gujarati',
+   'Oriya',
+   'Tamil',
+   'Telugu',
+   'Kannada',
+   'Malayalam',
+   'Sinhala',
+   'Myanmar',
+   'Khmer',
+   'Vedic Extensions',
+   'General Punctuation',
+   'Superscripts and Subscripts',
+   'Devanagari Extended',
+   'Javanese',
+   'Myanmar Extended-B',
+   'Myanmar Extended-A',
+]
 
 files = [file (x) for x in sys.argv[1:]]
 
@@ -50,7 +73,7 @@ for i,d in enumerate (data):
if not u in combined:
combined[u] = list (defaults)
combined[u][i] = v
-combined = {k:v for k,v in combined.items() if v[2] not in BLACKLISTED_BLOCKS}
+combined = {k:v for k,v in combined.items() if k in ALLOWED_SINGLES or v[2] in 
ALLOWED_BLOCKS}
 data = combined
 del combined
 num = len (data)
@@ -61,7 +84,7 @@ for u in [0x17CD, 0x17CE, 0x17CF, 0x17D0, 0x17D3]:
 
 # Move the outliers NO-BREAK SPACE and DOTTED CIRCLE out
 singles = {}
-for u in [0x00A0, 0x25CC]:
+for u in ALLOWED_SINGLES:
singles[u] = data[u]
del data[u]
 
diff --git a/src/hb-ot-shape-complex-indic-table.cc 
b/src/hb-ot-shape-complex-indic-table.cc
index cc350de..36157c0 100644
--- a/src/hb-ot-shape-complex-indic-table.cc
+++ b/src/hb-ot-shape-complex-indic-table.cc
@@ -2,7 +2,7 @@
 /*
  * The following table is generated by running:
  *
- *   ./gen-indic-table.py IndicSyllabicCategory.txt IndicMatraCategory.txt 
Blocks.txt
+ *   ./gen-indic-table.py IndicSyllabicCategory.txt 
IndicPositionalCategory.txt Blocks.txt
  *
  * on files with these headers:
  *
@@ -312,37 +312,9 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table[] = {
   /* 1090 */ _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), 
_(Nd,x),
   /* 1098 */ _(Nd,x), _(Nd,x), _(TM,R), _(TM,R),  _(M,R),  _(M,T),  _(x,x),  
_(x,x),
 
-#define indic_offset_0x1700u 1496
+#define indic_offset_0x1780u 1496
 
 
-  /* Tagalog */
-
-  /* 1700 */ _(VI,x), _(VI,x), _(VI,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
-  /* 1708 */  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(x,x),  _(C,x),  
_(C,x),
-  /* 1710 */  _(C,x),  _(C,x),  _(M,T),  _(M,B), _(PK,B),  _(x,x),  _(x,x),  
_(x,x),
-  /* 1718 */  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  
_(x,x),
-
-  /* Hanunoo */
-
-  /* 1720 */ _(VI,x), _(VI,x), _(VI,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
-  /* 1728 */  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
-  /* 1730 */  _(C,x),  _(C,x),  _(M,T),  _(M,B), _(PK,B),  _(x,x),  _(x,x),  
_(x,x),
-  /* 1738 */  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  
_(x,x),
-
-  /* Buhid */
-
-  /* 1740 */ _(VI,x), _(VI,x), _(VI,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
-  /* 1748 */  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
-  /* 1750 */  _(C,x),  _(C,x),  _(M,T),  _(M,B),  _(x,x),  _(x,x),  _(x,x),  
_(x,x),
-  /* 1758 */  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  
_(x,x),
-
-  /* Tagbanwa */
-
-  /* 1760 */ _(VI,x), _(VI,x), _(VI,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
-  /* 1768 */  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(x,x),  _(C,x),  
_(C,x),
-  /* 1770 */  _(C,x),  _(x,x),  _(M,T),  _(M,B),  _(x,x),  _(x,x),  _(x,x),  
_(x,x),
-  /* 1778 */  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  
_(x,x),
-
   /* Khmer */
 
   /* 1780 */  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  _(C,x),  
_(C,x),
@@ -360,134 +332,7 @@ static const INDIC_TABLE_ELEMENT_TYPE indic_table[] = {
   /* 17E0 */ _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), _(Nd,x), 
_(Nd,x),
   /* 17E8 */ _(Nd,x), _(Nd,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  _(x,x),  

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

2015-12-30 Thread Behdad Esfahbod
 docs/harfbuzz-docs.xml |   74 +
 docs/harfbuzz-sections.txt |   40 
 src/hb-buffer.cc   |2 -
 src/hb-coretext.cc |4 --
 4 files changed, 115 insertions(+), 5 deletions(-)

New commits:
commit bfdf684f7957645dd016fbf76700c5911c4bee2d
Merge: d7ed6f5 85c2443
Author: Behdad Esfahbod 
Date:   Wed Dec 30 22:20:14 2015 +0100

Merge pull request #205 from khaledhosny/more-docs

More docs

commit d7ed6f50b4ff13a94701131913d931f13a4d1266
Merge: b758e5e a7f0e25
Author: Behdad Esfahbod 
Date:   Wed Dec 30 22:20:00 2015 +0100

Merge pull request #206 from nico/patch-3

Remove unused HB_SHAPER_DATA_ENSURE_DECLARE lines.

commit a7f0e25dafa90bd21b01c38cb0782ade54b75cdc
Author: Nico Weber 
Date:   Wed Dec 30 16:05:52 2015 -0500

Remove unused HB_SHAPER_DATA_ENSURE_DECLARE lines.

The coretext_aat shaper delegates to the regular coretext_..._ensure() 
functions, so coretext_aat_..._ensure() functions defined by these macros are 
unused. The compiler warns about them, which in turn can confuse people to 
think that the coretext_aat_..._ensure() functions weren't called by accident.

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 16a3e65..316d281 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -1128,10 +1128,6 @@ fail:
  * AAT shaper
  */
 
-HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, face)
-HB_SHAPER_DATA_ENSURE_DECLARE(coretext_aat, font)
-
-
 /*
  * shaper face data
  */
commit 85c2443b737335b77c7e9bb6fd6741912f70fcef
Author: Khaled Hosny 
Date:   Wed Dec 30 22:57:04 2015 +0400

[docs] Reduce gtkdoc-check errors

Now it is just reporting one error about “503 undocumented or incomplete
symbols”, that will be the easy part I guess.

diff --git a/docs/harfbuzz-docs.xml b/docs/harfbuzz-docs.xml
index 7d2232f..6c03f39 100644
--- a/docs/harfbuzz-docs.xml
+++ b/docs/harfbuzz-docs.xml
@@ -77,6 +77,8 @@
 
 
 
+
+
 
 
 
@@ -100,6 +102,78 @@
 API Index
 
   
+  
+Index of new symbols in 0.9.2
+
+  
+  
+Index of new symbols in 0.9.5
+
+  
+  
+Index of new symbols in 0.9.7
+
+  
+  
+Index of new symbols in 0.9.8
+
+  
+  
+Index of new symbols in 0.9.10
+
+  
+  
+Index of new symbols in 0.9.11
+
+  
+  
+Index of new symbols in 0.9.20
+
+  
+  
+Index of new symbols in 0.9.22
+
+  
+  
+Index of new symbols in 0.9.28
+
+  
+  
+Index of new symbols in 0.9.30
+
+  
+  
+Index of new symbols in 0.9.31
+
+  
+  
+Index of new symbols in 0.9.38
+
+  
+  
+Index of new symbols in 0.9.39
+
+  
+  
+Index of new symbols in 0.9.41
+
+  
+  
+Index of new symbols in 0.9.42
+
+  
+  
+Index of new symbols in 1.0.5
+
+  
+  
+Index of new symbols in 1.1.2
+
+  
+  
+Index of new symbols in 1.1.3
+
+  
   
 Index of deprecated API
 
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 3ad7be4..153f19e 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -2,6 +2,7 @@
 hb
 
 HB_H_IN
+HB_EXTERN
 
 
 
@@ -25,6 +26,7 @@ hb_memory_mode_t
 
 hb-buffer
 HB_SEGMENT_PROPERTIES_DEFAULT
+HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT
 hb_buffer_create
 hb_buffer_reference
 hb_buffer_get_empty
@@ -38,6 +40,7 @@ hb_buffer_add_codepoints
 hb_buffer_add_utf32
 hb_buffer_add_utf16
 hb_buffer_add_utf8
+hb_buffer_add_latin1
 hb_buffer_set_content_type
 hb_buffer_get_content_type
 hb_buffer_set_direction
@@ -61,8 +64,11 @@ hb_buffer_set_user_data
 hb_buffer_get_user_data
 hb_buffer_get_glyph_infos
 hb_buffer_get_glyph_positions
+hb_buffer_set_replacement_codepoint
+hb_buffer_get_replacement_codepoint
 hb_buffer_normalize_glyphs
 hb_buffer_reverse
+hb_buffer_reverse_range
 hb_buffer_reverse_clusters
 hb_buffer_serialize_glyphs
 hb_buffer_deserialize_glyphs
@@ -71,14 +77,17 @@ hb_buffer_serialize_format_to_string
 hb_buffer_serialize_list_formats
 hb_segment_properties_equal
 hb_segment_properties_hash
+hb_buffer_set_message_func
 hb_buffer_t
 hb_glyph_info_t
 hb_glyph_position_t
 hb_buffer_content_type_t
 hb_buffer_flags_t
+hb_buffer_cluster_level_t
 hb_buffer_serialize_flags_t
 hb_segment_properties_t
 hb_buffer_serialize_format_t
+hb_buffer_message_func_t
 
 
 
@@ -108,6 +117,7 @@ hb_var_int_t
 HB_TAG
 HB_TAG_NONE
 HB_TAG_MAX
+HB_TAG_MAX_SIGNED
 HB_UNTAG
 HB_DIRECTION_REVERSE
 HB_DIRECTION_IS_BACKWARD
@@ -242,14 +252,27 @@ hb_font_set_user_data
 

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

2015-09-01 Thread Behdad Esfahbod
 src/hb-buffer-private.hh|2 
 src/hb-buffer.cc|   25 

 src/hb-ot-shape-complex-arabic-fallback.hh  |6 
-
 src/hb-ot-shape-complex-indic.cc|2 
 src/hb-ot-shape-complex-myanmar.cc  |2 
 src/hb-ot-shape-normalize.cc|6 
-
 src/hb-private.hh   |   54 
--
 test/Makefile.am|4 
 test/api/Makefile.am|4 
 test/shaping/Makefile.am|4 
 test/shaping/fonts/sha1sum/43ef465752be9af900745f72fe29cb853a1401a5.ttf |binary
 test/shaping/fonts/sha1sum/MANIFEST |1 
 test/shaping/tests/cluster.tests|1 
 13 files changed, 69 insertions(+), 42 deletions(-)

New commits:
commit e995d33c10a4bd9404699d01bddb2b69d811e9ed
Author: Behdad Esfahbod 
Date:   Tue Sep 1 16:13:32 2015 +0100

[OT] Merge clusters when reordering marks for normalization

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=541608
and cluster test.

diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 9aa5e7d..7fed738 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -201,6 +201,8 @@ struct hb_buffer_t {
   HB_INTERNAL scratch_buffer_t *get_scratch_buffer (unsigned int *size);
 
   inline void clear_context (unsigned int side) { context_len[side] = 0; }
+
+  HB_INTERNAL void sort (unsigned int start, unsigned int end, 
int(*compar)(const hb_glyph_info_t *, const hb_glyph_info_t *));
 };
 
 
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 1709305..420da82 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -1678,3 +1678,24 @@ hb_buffer_normalize_glyphs (hb_buffer_t *buffer)
 }
   normalize_glyphs_cluster (buffer, start, end, backward);
 }
+
+void
+hb_buffer_t::sort (unsigned int start, unsigned int end, int(*compar)(const 
hb_glyph_info_t *, const hb_glyph_info_t *))
+{
+  assert (!have_positions);
+  for (unsigned int i = start + 1; i < end; i++)
+  {
+unsigned int j = i;
+while (j > start && compar ([j - 1], [i]) > 0)
+  j--;
+if (i == j)
+  continue;
+/* Move item i to occupy place for item j, shift what's in between. */
+merge_clusters (j, i + 1);
+{
+  hb_glyph_info_t t = info[i];
+  memmove ([j + 1], [j], (i - j) * sizeof (hb_glyph_info_t));
+  info[j] = t;
+}
+  }
+}
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index dff7a74..a706461 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -350,7 +350,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
   continue;
 }
 
-hb_stable_sort (buffer->info + i, end - i, compare_combining_class);
+buffer->sort (i, end, compare_combining_class);
 
 i = end;
   }
commit b6d7d161a87b5dde710924e5c557d39c302f5630
Author: Behdad Esfahbod 
Date:   Tue Sep 1 16:12:44 2015 +0100

[tests] Add Hebrew test for normalization under cluster-level=1

Currently fails.
https://bugzilla.gnome.org/show_bug.cgi?id=541608

diff --git 
a/test/shaping/fonts/sha1sum/43ef465752be9af900745f72fe29cb853a1401a5.ttf 
b/test/shaping/fonts/sha1sum/43ef465752be9af900745f72fe29cb853a1401a5.ttf
new file mode 100644
index 000..649c156
Binary files /dev/null and 
b/test/shaping/fonts/sha1sum/43ef465752be9af900745f72fe29cb853a1401a5.ttf differ
diff --git a/test/shaping/fonts/sha1sum/MANIFEST 
b/test/shaping/fonts/sha1sum/MANIFEST
index 1e78f0a..1de86c8 100644
--- a/test/shaping/fonts/sha1sum/MANIFEST
+++ b/test/shaping/fonts/sha1sum/MANIFEST
@@ -4,6 +4,7 @@
 270b89df543a7e48e206a2d830c0e10e5265c630.ttf
 298c9e1d955f10f6f72c6915c3c6ff9bf9695cec.ttf
 37033cc5cf37bb223d7355153016b6ccece93b28.ttf
+43ef465752be9af900745f72fe29cb853a1401a5.ttf
 4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf
 5028afb650b1bb718ed2131e872fbcce57828fff.ttf
 57a9d9f83020155cbb1d2be1f43d82388cbecc88.ttf
diff --git a/test/shaping/tests/cluster.tests b/test/shaping/tests/cluster.tests
index 3a3a397..24f04dd 100644
--- a/test/shaping/tests/cluster.tests
+++ b/test/shaping/tests/cluster.tests
@@ -1 +1,2 @@
 
fonts/sha1sum/6466d38c62e73a39202435a4f73bf5d6acbb73c0.ttf:--cluster-level=2:U+0078,U+030A,U+0058,U+030A:[gid2=0+1083|gid4=1@-555,-8+0|gid1=2+1200|gid4=3@-614,349+0]
+fonts/sha1sum/43ef465752be9af900745f72fe29cb853a1401a5.ttf:--cluster-level=1:U+05D4,U+05B7,U+05E9,U+05BC,U+05C1,U+05B8,U+05DE,U+05B4,U+05DD:[uni05DD=8+1359|uni05B4=7@111,0+0|uni05DE=6+1391|uni05B8=5+0|uni05BC=3+0|uni05C1=3+0|uni05E9=2+1451|uni05B7=1@28,0+0|uni05D4=0+1338]
commit 

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

2015-09-01 Thread Behdad Esfahbod
 src/hb-ot-shape-complex-hangul.cc |2 +-
 src/hb-ot-shape-complex-indic.cc  |   21 -
 src/hb-ot-shape-complex-thai.cc   |2 +-
 src/hb-ot-shape-complex-use.cc|4 ++--
 src/hb-ot-shape.cc|5 +++--
 5 files changed, 23 insertions(+), 11 deletions(-)

New commits:
commit 5828c45d7a816ccd0a7f10a665ea3cf8cfd63b05
Author: Behdad Esfahbod 
Date:   Tue Sep 1 16:26:35 2015 +0100

[indic] Add comments to merge_clusters calls

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 8b55484..00526f3 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -1025,7 +1025,11 @@ initial_reordering_consonant_syllable (const 
hb_ot_shape_plan_t *plan,
  * around like crazy.  In old-spec mode, we move halants around, so in
  * that case merge all clusters after base.  Otherwise, check the sort
  * order and merge as needed.
- * For pre-base stuff, we handle cluster issues in final reordering. */
+ * For pre-base stuff, we handle cluster issues in final reordering.
+ *
+ * We could use buffer->sort() for this, if there was no special
+ * reordering of pre-base stuff happening later...
+ */
 if (indic_plan->is_old_spec || end - base > 127)
   buffer->merge_clusters (base, end);
 else
@@ -1404,12 +1408,17 @@ final_reordering_syllable (const hb_ot_shape_plan_t 
*plan,
if (info[i - 1].indic_position () == POS_PRE_M)
{
  unsigned int old_pos = i - 1;
+ if (old_pos < base && base <= new_pos) /* Shouldn't actually happen. 
*/
+   base--;
+
  hb_glyph_info_t tmp = info[old_pos];
  memmove ([old_pos], [old_pos + 1], (new_pos - old_pos) * 
sizeof (info[0]));
  info[new_pos] = tmp;
- if (old_pos < base && base <= new_pos) /* Shouldn't actually happen. 
*/
-   base--;
+
+ /* Note: this merge_clusters() is intentionally *after* the 
reordering.
+  * Indic matra reordering is special and tricky... */
  buffer->merge_clusters (new_pos, MIN (end, base + 1));
+
  new_pos--;
}
 } else {
@@ -1562,12 +1571,12 @@ final_reordering_syllable (const hb_ot_shape_plan_t 
*plan,
 
 reph_move:
 {
-  buffer->merge_clusters (start, new_reph_pos + 1);
-
   /* Move */
+  buffer->merge_clusters (start, new_reph_pos + 1);
   hb_glyph_info_t reph = info[start];
   memmove ([start], [start + 1], (new_reph_pos - start) * sizeof 
(info[0]));
   info[new_reph_pos] = reph;
+
   if (start < base && base <= new_reph_pos)
base--;
 }
@@ -1640,10 +1649,12 @@ final_reordering_syllable (const hb_ot_shape_plan_t 
*plan,
 
  {
unsigned int old_pos = i;
+
buffer->merge_clusters (new_pos, old_pos + 1);
hb_glyph_info_t tmp = info[old_pos];
memmove ([new_pos + 1], [new_pos], (old_pos - new_pos) * 
sizeof (info[0]));
info[new_pos] = tmp;
+
if (new_pos <= base && base < old_pos)
  base++;
  }
commit bdc8215949a7add742cc800b4fdea6acaa37d152
Author: Behdad Esfahbod 
Date:   Tue Sep 1 16:24:54 2015 +0100

[thai] Respect cluster-level > 0

diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc
index feb7fc7..d4ede20 100644
--- a/src/hb-ot-shape-complex-thai.cc
+++ b/src/hb-ot-shape-complex-thai.cc
@@ -353,7 +353,7 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan,
 {
   /* Since we decomposed, and NIKHAHIT is combining, merge clusters with 
the
* previous cluster. */
-  if (start)
+  if (start && buffer->cluster_level == 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
buffer->merge_out_clusters (start - 1, end);
 }
   }
commit 5b31fe383ead726ec77062501ed3bb24c02842b3
Author: Behdad Esfahbod 
Date:   Tue Sep 1 16:24:34 2015 +0100

[use] Merge /before/ reordering

diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc
index 41eb43f..4b15dee 100644
--- a/src/hb-ot-shape-complex-use.cc
+++ b/src/hb-ot-shape-complex-use.cc
@@ -436,10 +436,10 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int 
start, unsigned int end)
if (info[i].use_category() == USE_H)
  i--;
 
+   buffer->merge_clusters (start, i + 1);
hb_glyph_info_t t = info[start];
memmove ([start], [start + 1], (i - start) * sizeof 
(info[0]));
info[i] = t;
-   buffer->merge_clusters (start, i + 1);
 
break;
   }
@@ -464,10 +464,10 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int 
start, unsigned int end)
 0 == _hb_glyph_info_get_lig_comp ([i]) &&
 j < i)
 {
+  buffer->merge_clusters (j, i + 1);
   hb_glyph_info_t t = info[i];
   memmove ([j + 1], [j], (i - j) * sizeof (info[0]));
   info[j] = t;
-  buffer->merge_clusters (j, i + 1);
 

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

2015-07-23 Thread Behdad Esfahbod
 src/hb-ot-layout-private.hh |9 
+
 src/hb-ot-layout.cc |   22 

 src/hb-ot-map-private.hh|7 
-
 src/hb-ot-map.cc|   10 
++
 src/hb-ot-shape.cc  |   15 
+--
 test/shaping/Makefile.am|2 
 test/shaping/fonts/sha1sum/191826b9643e3f124d865d617ae609db6a2ce203.ttf |binary
 test/shaping/fonts/sha1sum/MANIFEST |1 
 test/shaping/record-test.sh |   47 
--
 test/shaping/run-tests.sh   |9 
+
 test/shaping/tests/MANIFEST |1 
 test/shaping/tests/arabic-fallback-shaping.tests|2 
 test/shaping/tests/arabic-feature-order.tests   |6 
-
 test/shaping/tests/context-matching.tests   |6 
-
 test/shaping/tests/default-ignorables.tests |2 
 test/shaping/tests/hangul-jamo.tests|4 
 test/shaping/tests/indic-joiner-candrabindu.tests   |4 
 test/shaping/tests/indic-old-spec.tests |4 
 test/shaping/tests/indic-pref-blocking.tests|4 
 test/shaping/tests/mongolian-variation-selector.tests   |6 
-
 test/shaping/tests/vertical.tests   |1 
 test/shaping/tests/zero-width-marks.tests   |4 
 22 files changed, 124 insertions(+), 42 deletions(-)

New commits:
commit c81d957a264539dfe3252f9a94ee066c4a44edf4
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 23 12:50:48 2015 +0100

[test] Add tests for improved 'vert' feature

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index c7434a6..22e326e 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -45,6 +45,7 @@ TESTS = \
tests/indic-old-spec.tests \
tests/indic-pref-blocking.tests \
tests/mongolian-variation-selector.tests \
+   tests/vertical.tests \
tests/zero-width-marks.tests \
$(NULL)
 
diff --git 
a/test/shaping/fonts/sha1sum/191826b9643e3f124d865d617ae609db6a2ce203.ttf 
b/test/shaping/fonts/sha1sum/191826b9643e3f124d865d617ae609db6a2ce203.ttf
new file mode 100644
index 000..dbc6e26
Binary files /dev/null and 
b/test/shaping/fonts/sha1sum/191826b9643e3f124d865d617ae609db6a2ce203.ttf differ
diff --git a/test/shaping/fonts/sha1sum/MANIFEST 
b/test/shaping/fonts/sha1sum/MANIFEST
index 0a35ee2..2881f0a 100644
--- a/test/shaping/fonts/sha1sum/MANIFEST
+++ b/test/shaping/fonts/sha1sum/MANIFEST
@@ -1,4 +1,5 @@
 051d92f8bc6ff724511b296c27623f824de256e9.ttf
+191826b9643e3f124d865d617ae609db6a2ce203.ttf
 226bc2deab3846f1a682085f70c67d0421014144.ttf
 270b89df543a7e48e206a2d830c0e10e5265c630.ttf
 37033cc5cf37bb223d7355153016b6ccece93b28.ttf
diff --git a/test/shaping/tests/MANIFEST b/test/shaping/tests/MANIFEST
index 74e7eb2..323ad46 100644
--- a/test/shaping/tests/MANIFEST
+++ b/test/shaping/tests/MANIFEST
@@ -7,4 +7,5 @@ indic-joiner-candrabindu.tests
 indic-old-spec.tests
 indic-pref-blocking.tests
 mongolian-variation-selector.tests
+vertical.tests
 zero-width-marks.tests
diff --git a/test/shaping/tests/vertical.tests 
b/test/shaping/tests/vertical.tests
new file mode 100644
index 000..8276890
--- /dev/null
+++ b/test/shaping/tests/vertical.tests
@@ -0,0 +1 @@
+fonts/sha1sum/191826b9643e3f124d865d617ae609db6a2ce203.ttf:--direction=t:U+300C:[uni300C.vert=0@-512,-578+0,-1024]
commit 8a6a16dbcb1808c7ed50f9ba320384565bbf405a
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 23 12:49:09 2015 +0100

[test] Add recently added test

Ouch.

diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index 70bcdd5..c7434a6 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -39,6 +39,7 @@ TESTS = \
tests/arabic-fallback-shaping.tests \
tests/arabic-feature-order.tests \
tests/context-matching.tests \
+   tests/default-ignorables.tests \
tests/hangul-jamo.tests \
tests/indic-joiner-candrabindu.tests \
tests/indic-old-spec.tests \
commit 895fb31c7f0201f13df5a6866b367476bc4aab2e
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 23 12:14:03 2015 +0100

[test] Support additional options to hb-shape in micro-test suite

diff --git a/test/shaping/record-test.sh b/test/shaping/record-test.sh
index a69157f..691f78d 100755
--- a/test/shaping/record-test.sh
+++ b/test/shaping/record-test.sh
@@ -5,11 +5,42 @@ dir=`mktemp --directory`
 hb_shape=$1
 shift
 fontfile=$1
+if test 

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

2015-04-14 Thread Behdad Esfahbod
 util/options.cc |   29 -
 1 file changed, 16 insertions(+), 13 deletions(-)

New commits:
commit 76d57331117be8e0c2d4a2aee8341969b62b6888
Merge: 89cbd4d 9ee176e
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Apr 13 23:40:35 2015 -0700

Merge pull request #86 from cpfair/hb-shape-output-help-improvement

Improve hb-shape/hb-view's help text w.r.t. output options

commit 9ee176ee978e6668c4faf00028811ce70979122e
Author: Collin Fair c...@cpfx.ca
Date:   Sat Feb 14 09:59:44 2015 -0500

Stop hb-shape docs leaking into hb-view

diff --git a/util/options.cc b/util/options.cc
index fb74b1a..5d03caa 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -444,9 +444,7 @@ output_options_t::add_options (option_parser_t *parser)
   else
   {
 char *items = g_strjoinv (/, const_castchar ** (supported_formats));
-text = g_strdup_printf (Set output serialization format\n\nSupported 
output formats are: %s\n%s, items,
-text: [glyph name or index=glyph cluster index within 
input@horizontal displacement,vertical displacement+horizontal 
advance,vertical advance|...]\n
-json: [{\g\: glyph name or index, \ax\: horizontal 
advance, \ay\: vertical advance, \dx\: horizontal displacement, 
\dy\: vertical displacement, \cl\: glyph cluster index within input}, 
...]);
+text = g_strdup_printf (Set output format\n\nSupported output formats 
are: %s, items);
 g_free (items);
 parser-free_later ((char *) text);
   }
@@ -459,7 +457,7 @@ output_options_t::add_options (option_parser_t *parser)
   };
   parser-add_group (entries,
 output,
-Output detination  format options:,
+Output destination  format options:,
 Options controlling the destination and form of the 
output,
 this);
 }
@@ -706,9 +704,12 @@ format_options_t::add_options (option_parser_t *parser)
 {NULL}
   };
   parser-add_group (entries,
-output-content,
-Output content options (refer to --help-output for output 
syntax):,
-Options controlling the content of the output,
+output-syntax,
+Output syntax:\n
+ text: [glyph name or index=glyph cluster index within 
input@horizontal displacement,vertical displacement+horizontal 
advance,vertical advance|...]\n
+ json: [{\g\: glyph name or index, \ax\: horizontal 
advance, \ay\: vertical advance, \dx\: horizontal displacement, 
\dy\: vertical displacement, \cl\: glyph cluster index within input}, 
...]\n
+ \nOutput syntax options:,
+Options controlling the syntax of the output,
 this);
 }
 
commit 952b8dbdf61da9b4814e09ad3c1b9b76483bef5c
Author: Collin Fair c...@cpfx.ca
Date:   Sat Feb 14 09:44:00 2015 -0500

'All' of the above, not 'each'

diff --git a/util/options.cc b/util/options.cc
index 799ac4f..fb74b1a 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -699,10 +699,10 @@ format_options_t::add_options (option_parser_t *parser)
 {show-text, 0, 0, G_OPTION_ARG_NONE, this-show_text, Prefix each line 
of output with its corresponding input text, NULL},
 {show-unicode, 0, 0, G_OPTION_ARG_NONE, this-show_unicode, Prefix 
each line of output with its corresponding input codepoint(s), NULL},
 {show-line-num, 0, 0, G_OPTION_ARG_NONE, this-show_line_num, Prefix 
each line of output with its corresponding input line number, NULL},
-{verbose, 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) 
parse_verbose, Prefix each line of output with each of the above, NULL},
+{verbose, 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) 
parse_verbose, Prefix each line of output with all of the above, NULL},
 {no-glyph-names, 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, 
this-show_glyph_names, Output glyph indices instead of names, NULL},
 {no-positions, 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, 
this-show_positions, Do not output glyph positions, NULL},
-{no-clusters,0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, 
this-show_clusters, Do not output cluster indices, NULL},
+{no-clusters, 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, 
this-show_clusters, Do not output cluster indices, NULL},
 {NULL}
   };
   parser-add_group (entries,
commit 9e867b64467c46eea5cc9b1d5a9404a1221bbbfc
Author: Collin Fair c...@cpfx.ca
Date:   Sat Feb 14 09:32:04 2015 -0500

Remove reference to --help-output-content in --help-output (as 
--help-output-format's options aren't available in hb-view)

diff --git a/util/options.cc b/util/options.cc
index c5b619d..799ac4f 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -459,7 +459,7 @@ output_options_t::add_options (option_parser_t *parser)
   };
   parser-add_group (entries,
 output,
-Output detination  format options (refer to 

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

2014-10-01 Thread Behdad Esfahbod
 src/Makefile.am   |   43 ++-
 src/check-static-inits.sh |4 ++--
 2 files changed, 24 insertions(+), 23 deletions(-)

New commits:
commit c0b82ba32a1987902a3b9c05b46f8be6b121883a
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Oct 1 14:24:07 2014 -0400

Create ragel-generated files in srcdir

diff --git a/src/Makefile.am b/src/Makefile.am
index 07d957a..71614a4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -290,13 +290,14 @@ built-sources: $(BUILT_SOURCES)
 
 .PHONY: unicode-tables arabic-table indic-table built-sources
 
-BUILT_SOURCES += \
-   hb-buffer-deserialize-json.hh \
-   hb-buffer-deserialize-text.hh \
-   hb-ot-shape-complex-indic-machine.hh \
-   hb-ot-shape-complex-myanmar-machine.hh \
-   hb-ot-shape-complex-sea-machine.hh \
+RAGEL_GENERATED = \
+   $(srcdir)/hb-buffer-deserialize-json.hh \
+   $(srcdir)/hb-buffer-deserialize-text.hh \
+   $(srcdir)/hb-ot-shape-complex-indic-machine.hh \
+   $(srcdir)/hb-ot-shape-complex-myanmar-machine.hh \
+   $(srcdir)/hb-ot-shape-complex-sea-machine.hh \
$(NULL)
+BUILT_SOURCES += $(RAGEL_GENERATED)
 EXTRA_DIST += \
hb-buffer-deserialize-json.rl \
hb-buffer-deserialize-text.rl \
@@ -304,15 +305,9 @@ EXTRA_DIST += \
hb-ot-shape-complex-myanmar-machine.rl \
hb-ot-shape-complex-sea-machine.rl \
$(NULL)
-MAINTAINERCLEANFILES += \
-   hb-buffer-deserialize-json.hh \
-   hb-buffer-deserialize-text.hh \
-   hb-ot-shape-complex-indic-machine.hh \
-   hb-ot-shape-complex-myanmar-machine.hh \
-   hb-ot-shape-complex-sea-machine.hh \
-   $(NULL)
-.rl.hh:
-   $(AM_V_GEN)$(RAGEL) -e -F1 -o $@ $ \
+MAINTAINERCLEANFILES += $(RAGEL_GENERATED)
+$(srcdir)/%.hh: $(srcdir)/%.rl
+   $(AM_V_GEN)(cd $(srcdir)  $(RAGEL) -e -F1 -o $*.hh $*.rl) \
|| ($(RM) $@; false)
 
 noinst_PROGRAMS = \
commit 79bbb10b0da49ace763a50f259c2ea687143f7ea
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Oct 1 13:33:21 2014 -0400

Clean ragel-generated headers in maintainercleanfiles

diff --git a/src/Makefile.am b/src/Makefile.am
index 78566fd..07d957a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -304,6 +304,13 @@ EXTRA_DIST += \
hb-ot-shape-complex-myanmar-machine.rl \
hb-ot-shape-complex-sea-machine.rl \
$(NULL)
+MAINTAINERCLEANFILES += \
+   hb-buffer-deserialize-json.hh \
+   hb-buffer-deserialize-text.hh \
+   hb-ot-shape-complex-indic-machine.hh \
+   hb-ot-shape-complex-myanmar-machine.hh \
+   hb-ot-shape-complex-sea-machine.hh \
+   $(NULL)
 .rl.hh:
$(AM_V_GEN)$(RAGEL) -e -F1 -o $@ $ \
|| ($(RM) $@; false)
commit 8971cac83eb4f06847abfa3eaa15857d27141810
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Oct 1 12:41:03 2014 -0400

Don't use tmp files in Makefile

Useful for code-coverage generation of the ragel-generated files
as they will now contain the correct .hh filename in them.

diff --git a/src/Makefile.am b/src/Makefile.am
index ba07ac5..78566fd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -234,8 +234,8 @@ hb-gobject-enums.%: hb-gobject-enums.%.tmpl $(HBHEADERS)
$(AM_V_GEN) $(GLIB_MKENUMS) \
--identifier-prefix hb_ --symbol-prefix hb_gobject \
--template $^ | \
-   sed 's/_t_get_type/_get_type/g; s/_T (/ (/g'  $@.tmp  \
-   mv $@.tmp $@ || ( $(RM) @.tmp  false )
+   sed 's/_t_get_type/_get_type/g; s/_T (/ (/g'  $@ \
+   || ($(RM) $@; false)
 endif
 EXTRA_DIST += \
harfbuzz-gobject.pc.in \
@@ -251,8 +251,8 @@ EXTRA_DIST += \
-e 's@%libdir%@$(libdir)@g' \
-e 's@%includedir%@$(includedir)@g' \
-e 's@%VERSION%@$(VERSION)@g' \
-   $ \
-$@.tmp  mv $@.tmp $@ || ( $(RM) $@.tmp; false )
+   $  $@ \
+   || ($(RM) $@; false)
 
 CLEANFILES += $(pkgconfig_DATA)
 
@@ -265,8 +265,9 @@ harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS)
sed -e 's/ (.*//' | \
LANG=C sort; \
echo LIBRARY libharfbuzz-$(HB_VERSION_MAJOR).dll; \
-   ) $@.tmp
-   @ ! grep -q hb_ERROR $@.tmp  mv $@.tmp $@ || ($(RM) $@; false)
+   ) $@
+   @ ! grep -q hb_ERROR $@ \
+   || ($(RM) $@; false)
 
 
 GENERATORS = \
@@ -278,14 +279,12 @@ EXTRA_DIST += $(GENERATORS)
 unicode-tables: arabic-table indic-table
 
 indic-table: gen-indic-table.py IndicSyllabicCategory.txt 
IndicMatraCategory.txt Blocks.txt
-   $(AM_V_GEN) $(builddir)/$^  hb-ot-shape-complex-indic-table.cc.tmp  \
-   mv hb-ot-shape-complex-indic-table.cc.tmp 
$(srcdir)/hb-ot-shape-complex-indic-table.cc || \
-   ($(RM) hb-ot-shape-complex-indic-table.cc.tmp; false)
+   $(AM_V_GEN) $(builddir)/$^  hb-ot-shape-complex-indic-table.cc \
+   || ($(RM) hb-ot-shape-complex-indic-table.cc; false)
 
 arabic-table: gen-arabic-table.py ArabicShaping.txt UnicodeData.txt Blocks.txt
-   

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

2014-08-11 Thread Behdad Esfahbod
 src/hb-coretext.cc |  152 ++---
 1 file changed, 100 insertions(+), 52 deletions(-)

New commits:
commit 5a0eed3b50629be4826e4e9428f2c3255195395d
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Aug 11 23:47:16 2014 -0400

[coretext] Implement vertical shaping

Currently doesn't work though, we detect font fallback.  Apparently
matching on ct_font is not safe for this.  Looks like commit
25f4fb9b56bb3f8bec821571c78f8829e40daa54 wasn't enough after all.

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index ee6745b..fc21809 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -685,6 +685,10 @@ retry:
FAIL (CFAttributedStringCreateMutable failed);
   CFAttributedStringReplaceString (attr_string, CFRangeMake (0, 0), 
string_ref);
   CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
+ kCTVerticalFormsAttributeName,
+ HB_DIRECTION_IS_VERTICAL 
(buffer-props.direction) ?
+ kCFBooleanTrue : kCFBooleanFalse);
+  CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
  kCTFontAttributeName, font_data-ct_font);
 
   if (num_features)
@@ -739,6 +743,7 @@ retry:
 
 CFArrayRef glyph_runs = CTLineGetGlyphRuns (line);
 unsigned int num_runs = CFArrayGetCount (glyph_runs);
+DEBUG_MSG (CORETEXT, NULL, Num runs: %d, num_runs);
 
 buffer-len = 0;
 uint32_t status_and = ~0, status_or = 0;
@@ -778,6 +783,8 @@ retry:
if (!matched)
{
  CFRange range = CTRunGetStringRange (run);
+  DEBUG_MSG (CORETEXT, run, Run used fallback font: %ld..%ld,
+range.location, range.location + range.length);
  if (!buffer-ensure_inplace (buffer-len + range.length))
goto resize_and_retry;
  hb_glyph_info_t *info = buffer-info + buffer-len;
@@ -818,54 +825,73 @@ retry:
   if (!buffer-ensure (buffer-len + num_glyphs))
goto resize_and_retry;
 
+  hb_glyph_info_t *run_info = buffer-info + buffer-len;
+
   /* Testing used to indicate that CTRunGetGlyphsPtr, etc (almost?) always
* succeed, and so copying data to our own buffer will be rare.  Reports
* have it that this changed in OS X 10.10 Yosemite, and NULL is returned
* frequently.  At any rate, we can test that codepath by setting USE_PTR
* to false. */
 #define USE_PTR true
-
-  const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : NULL;
-  if (!glyphs) {
-   ALLOCATE_ARRAY (CGGlyph, glyph_buf, num_glyphs, goto resize_and_retry);
-   CTRunGetGlyphs (run, range_all, glyph_buf);
-   glyphs = glyph_buf;
-  }
-
-  const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : NULL;
-  if (!positions) {
-   ALLOCATE_ARRAY (CGPoint, position_buf, num_glyphs, goto 
resize_and_retry);
-   CTRunGetPositions (run, range_all, position_buf);
-   positions = position_buf;
+  {
+   const CGGlyph* glyphs = USE_PTR ? CTRunGetGlyphsPtr (run) : NULL;
+   if (!glyphs) {
+ ALLOCATE_ARRAY (CGGlyph, glyph_buf, num_glyphs, goto 
resize_and_retry);
+ CTRunGetGlyphs (run, range_all, glyph_buf);
+ glyphs = glyph_buf;
+   }
+   const CFIndex* string_indices = USE_PTR ? CTRunGetStringIndicesPtr 
(run) : NULL;
+   if (!string_indices) {
+ ALLOCATE_ARRAY (CFIndex, index_buf, num_glyphs, goto 
resize_and_retry);
+ CTRunGetStringIndices (run, range_all, index_buf);
+ string_indices = index_buf;
+   }
+   hb_glyph_info_t *info = run_info;
+   for (unsigned int j = 0; j  num_glyphs; j++)
+   {
+ info-codepoint = glyphs[j];
+ info-cluster = log_clusters[string_indices[j]];
+ info++;
+   }
   }
-
-  const CFIndex* string_indices = USE_PTR ? CTRunGetStringIndicesPtr (run) 
: NULL;
-  if (!string_indices) {
-   ALLOCATE_ARRAY (CFIndex, index_buf, num_glyphs, goto resize_and_retry);
-   CTRunGetStringIndices (run, range_all, index_buf);
-   string_indices = index_buf;
+  {
+   const CGPoint* positions = USE_PTR ? CTRunGetPositionsPtr (run) : NULL;
+   if (!positions) {
+ ALLOCATE_ARRAY (CGPoint, position_buf, num_glyphs, goto 
resize_and_retry);
+ CTRunGetPositions (run, range_all, position_buf);
+ positions = position_buf;
+   }
+   double run_advance = CTRunGetTypographicBounds (run, range_all, NULL, 
NULL, NULL);
+   DEBUG_MSG (CORETEXT, run, Run advance: %g, run_advance);
+   hb_glyph_info_t *info = run_info;
+   if (HB_DIRECTION_IS_HORIZONTAL (buffer-props.direction))
+   {
+ for (unsigned int j = 0; j  num_glyphs; j++)
+ {
+   double advance = (j + 1  num_glyphs ? positions[j + 1].x : 
positions[0].x + run_advance) - 

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

2014-07-17 Thread Behdad Esfahbod
 src/hb-fallback-shape.cc|   36 
+--
 src/hb-ot-shape-complex-arabic.cc   |  106 
++
 src/hb-ot-shape-complex-indic.cc|   15 
-
 src/hb-ot-shape-complex-myanmar.cc  |7 
 src/hb-ot-shape-complex-sea.cc  |7 
 src/hb-ot-shape-fallback.cc |   30 
+-
 src/hb-ot-shape.cc  |   18 
+
 src/hb-unicode-private.hh   |3 
 test/shaping/Makefile.am|2 
 test/shaping/fonts/sha1sum/813c2f8e5512187fd982417a7fb4286728e6f4a8.ttf |binary
 test/shaping/fonts/sha1sum/8a9fea2a7384f2116e5b84a9b31f83be7850ce21.ttf |binary
 test/shaping/fonts/sha1sum/MANIFEST |4 
 test/shaping/fonts/sha1sum/a919b33197965846f21074b24e30250d67277bce.ttf |binary
 test/shaping/fonts/sha1sum/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf |binary
 test/shaping/record-test.sh |5 
 test/shaping/tests/MANIFEST |1 
 test/shaping/tests/arabic-feature-order.tests   |3 
 test/shaping/tests/mongolian-variation-selector.tests   |1 
 18 files changed, 155 insertions(+), 83 deletions(-)

New commits:
commit 82f4d9d53f348f41b14b877c1ac77c0372c49caa
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 17 15:57:37 2014 -0400

[arabic] Add note re disabled 'cswh'

diff --git a/src/hb-ot-shape-complex-arabic.cc 
b/src/hb-ot-shape-complex-arabic.cc
index 1b4ebc9..b90abfe 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -184,6 +184,15 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
   map-add_global_bool_feature (HB_TAG('c','a','l','t'));
   map-add_gsub_pause (NULL);
 
+  /* The spec includes 'cswh'.  Earlier versions of Windows
+   * used to enable this by default, but testing suggests
+   * that Windows 8 and later do not enable it by default,
+   * and spec now says 'Off by default'.
+   * We disabled this in ae23c24c32.
+   * Note that IranNastaliq uses this feature extensively
+   * to fixup broken glyph sequences.  Oh well...
+   * Test case: U+0643,U+0640,U+0631. */
+  map-add_global_bool_feature (HB_TAG('c','s','w','h'));
   map-add_global_bool_feature (HB_TAG('m','s','e','t'));
 }
 
commit 615d00ea252739da57edbd980ff27e573f88ee7e
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 17 13:36:09 2014 -0400

[arabic] Apply init/medi/isol/fini/... in separate stages

Follows the order of the Arabic/Syriac specs.  Also don't stop
between rlig and calt in non-Arabic scripts.

Micro-tests for Arabic and Mongolian added for the latter.

diff --git a/src/hb-ot-shape-complex-arabic.cc 
b/src/hb-ot-shape-complex-arabic.cc
index 3c59743..1b4ebc9 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -68,31 +68,30 @@ static unsigned int get_joining_type (hb_codepoint_t u, 
hb_unicode_general_categ
 ) ?  JOINING_TYPE_T : JOINING_TYPE_U;
 }
 
+#define FEATURE_IS_SYRIAC(tag) hb_in_rangeunsigned char ((unsigned char) 
(tag), '2', '3')
+
 static const hb_tag_t arabic_features[] =
 {
-  HB_TAG('i','n','i','t'),
-  HB_TAG('m','e','d','i'),
-  HB_TAG('f','i','n','a'),
   HB_TAG('i','s','o','l'),
-  /* Syriac */
-  HB_TAG('m','e','d','2'),
+  HB_TAG('f','i','n','a'),
   HB_TAG('f','i','n','2'),
   HB_TAG('f','i','n','3'),
+  HB_TAG('m','e','d','i'),
+  HB_TAG('m','e','d','2'),
+  HB_TAG('i','n','i','t'),
   HB_TAG_NONE
 };
 
 
 /* Same order as the feature array */
 enum {
-  INIT,
-  MEDI,
-  FINA,
   ISOL,
-
-  /* Syriac */
-  MED2,
+  FINA,
   FIN2,
   FIN3,
+  MEDI,
+  MED2,
+  INIT,
 
   NONE,
 
@@ -145,14 +144,23 @@ collect_features_arabic (hb_ot_shape_planner_t *plan)
 {
   hb_ot_map_builder_t *map = plan-map;
 
-  /* For Language forms (in ArabicOT speak), we do the iso/fina/medi/init 
together,
-   * then rlig and calt each in their own stage.  This makes IranNastaliq's 
ALLAH
-   * ligature work correctly. It's unfortunate though...
+  /* We apply features according to the Arabic spec, with pauses
+   * in between most.
*
-   * This also makes Arial Bold in Windows7 work.  See:
+   * The pause between init/medi/... and rlig is required.  See eg:
* https://bugzilla.mozilla.org/show_bug.cgi?id=644184
*
-   * TODO: Add test cases for these two.
+   * The pauses between init/medi/... themselves are not necessarily
+   * needed as only one of those features is applied to any character.
+   * The only difference it makes is when fonts have contextual
+   * substitutions.  We now follow the order of the spec, which makes
+   * for better experience if that's 

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

2014-07-16 Thread Behdad Esfahbod
 src/hb-buffer-private.hh |1 
 src/hb-buffer.cc |   79 -
 src/hb-buffer.h  |   23 ++
 src/hb-ot-layout-gsubgpos-private.hh |   25 --
 src/hb-utf-private.hh|  306 ++-
 test/api/test-buffer.c   |   65 +++
 6 files changed, 328 insertions(+), 171 deletions(-)

New commits:
commit 976c8f455221eb599d1c446eafd88d51d7d2aa65
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Jul 16 15:34:20 2014 -0400

New API: hb_buffer_[sg]et_replacement_codepoint()

With this change, we now by default replace broken UTF-8/16/32 bits
with U+FFFD.  This can be changed by calling new API on the buffer.
Previously the replacement value used to be (hb_codepoint_t)-1.

Note that hb_buffer_clear_contents() does NOT reset the replacement
character.

See discussion here:


https://github.com/behdad/harfbuzz/commit/6f13b6d62daae4989e3cc2fe4b168e5c59650964

New API:

  hb_buffer_set_replacement_codepoint()
  hb_buffer_get_replacement_codepoint()

diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 3a2b9ab..5eccd3c 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -52,6 +52,7 @@ struct hb_buffer_t {
   hb_unicode_funcs_t *unicode; /* Unicode functions */
   hb_segment_properties_t props; /* Script, language, direction */
   hb_buffer_flags_t flags; /* BOT / EOT / etc. */
+  hb_codepoint_t replacement; /* U+FFFD or something else. */
 
   /* Buffer contents */
 
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 242cded..2377ba4 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -178,6 +178,7 @@ hb_buffer_t::reset (void)
 
   hb_unicode_funcs_destroy (unicode);
   unicode = hb_unicode_funcs_get_default ();
+  replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT;
 
   clear ();
 }
@@ -703,6 +704,7 @@ hb_buffer_get_empty (void)
 const_casthb_unicode_funcs_t * (_hb_unicode_funcs_nil),
 HB_SEGMENT_PROPERTIES_DEFAULT,
 HB_BUFFER_FLAG_DEFAULT,
+HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT,
 
 HB_BUFFER_CONTENT_TYPE_INVALID,
 true, /* in_error */
@@ -1048,6 +1050,42 @@ hb_buffer_get_flags (hb_buffer_t *buffer)
 
 
 /**
+ * hb_buffer_set_replacement_codepoint:
+ * @buffer: a buffer.
+ * @replacement: 
+ *
+ * 
+ *
+ * Since: 1.0
+ **/
+void
+hb_buffer_set_replacement_codepoint (hb_buffer_t*buffer,
+hb_codepoint_t  replacement)
+{
+  if (unlikely (hb_object_is_inert (buffer)))
+return;
+
+  buffer-replacement = replacement;
+}
+
+/**
+ * hb_buffer_get_replacement_codepoint:
+ * @buffer: a buffer.
+ *
+ * 
+ *
+ * Return value: 
+ *
+ * Since: 1.0
+ **/
+hb_codepoint_t
+hb_buffer_get_replacement_codepoint (hb_buffer_t*buffer)
+{
+  return buffer-replacement;
+}
+
+
+/**
  * hb_buffer_reset:
  * @buffer: a buffer.
  *
@@ -1299,6 +1337,7 @@ hb_buffer_add_utf (hb_buffer_t  *buffer,
   int   item_length)
 {
   typedef hb_utf_tT, true utf_t;
+  const hb_codepoint_t replacement = buffer-replacement;
 
   assert (buffer-content_type == HB_BUFFER_CONTENT_TYPE_UNICODE ||
  (!buffer-len  buffer-content_type == 
HB_BUFFER_CONTENT_TYPE_INVALID));
@@ -1330,7 +1369,7 @@ hb_buffer_add_utf (hb_buffer_t  *buffer,
 while (start  prev  buffer-context_len[0]  buffer-CONTEXT_LENGTH)
 {
   hb_codepoint_t u;
-  prev = utf_t::prev (prev, start, u);
+  prev = utf_t::prev (prev, start, u, replacement);
   buffer-context[0][buffer-context_len[0]++] = u;
 }
   }
@@ -1341,7 +1380,7 @@ hb_buffer_add_utf (hb_buffer_t  *buffer,
   {
 hb_codepoint_t u;
 const T *old_next = next;
-next = utf_t::next (next, end, u);
+next = utf_t::next (next, end, u, replacement);
 buffer-add (u, old_next - (const T *) text);
   }
 
@@ -1351,7 +1390,7 @@ hb_buffer_add_utf (hb_buffer_t  *buffer,
   while (next  end  buffer-context_len[1]  buffer-CONTEXT_LENGTH)
   {
 hb_codepoint_t u;
-next = utf_t::next (next, end, u);
+next = utf_t::next (next, end, u, replacement);
 buffer-context[1][buffer-context_len[1]++] = u;
   }
 
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index 777c3d9..7b0c920 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -186,12 +186,25 @@ hb_buffer_flags_t
 hb_buffer_get_flags (hb_buffer_t *buffer);
 
 
+
+#define HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT 0xFFFDu
+
+/* Sets codepoint used to replace invalid UTF-8/16/32 entries.
+ * Default is 0xFFFDu. */
+void
+hb_buffer_set_replacement_codepoint (hb_buffer_t*buffer,
+hb_codepoint_t  replacement);
+
+hb_codepoint_t
+hb_buffer_get_replacement_codepoint (hb_buffer_t*buffer);
+
+
 /* Resets the buffer.  Afterwards it's as if it was just created,
  * except that it has a larger buffer allocated perhaps... */
 void
 hb_buffer_reset (hb_buffer_t *buffer);
 
-/* Like reset, but does NOT 

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

2014-06-18 Thread Behdad Esfahbod
 src/hb-common.cc   |8 
 src/hb-common.h|   27 ++-
 src/hb-ot-shape-complex-private.hh |4 ++
 src/hb-unicode-private.hh  |   66 -
 4 files changed, 54 insertions(+), 51 deletions(-)

New commits:
commit 577ca4814314c374824cac736996b9cdd4f9d11f
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Jun 18 12:29:23 2014 -0400

[unicode7] Update list of Default_Ignorable codepoints

diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh
index 991130f..583a197 100644
--- a/src/hb-unicode-private.hh
+++ b/src/hb-unicode-private.hh
@@ -130,46 +130,39 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
 
   /* Default_Ignorable codepoints:
*
-   * Note that as of Oct 2012 (Unicode 6.2), U+180E MONGOLIAN VOWEL SEPARATOR
-   * is NOT Default_Ignorable, but it really behaves in a way that it should
-   * be.  That has been reported to the Unicode Technical Committee for
-   * consideration.  As such, we include it here, since Uniscribe removes it.
-   * It *is* in Unicode 6.3 however.  U+061C ARABIC LETTER MARK from Unicode
-   * 6.3 is also added manually.  The new Unicode 6.3 bidi formatting
-   * characters are encoded in a block that was Default_Ignorable already.
-   *
* Note: While U+115F, U+1160, U+3164 and U+FFA0 are Default_Ignorable,
* we do NOT want to hide them, as the way Uniscribe has implemented them
* is with regular spacing glyphs, and that's the way fonts are made to work.
* As such, we make exceptions for those four.
*
-   * Gathered from:
-   * 
http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[:DI:]abb=onucd=onesc=on
-   *
-   * Last updated to the page with the following versions:
-   * Version 3.6; ICU version: 50.0.1.0; Unicode version: 6.1.0.0
-   *
-   * 4,167 Code Points
-   *
-   * 
[\u00AD\u034F\u115F\u1160\u17B4\u17B5\u180B-\u180D\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8\U0001D173-\U0001D17A\U000E-\U000E0FFF]
-   *
-   * 00AD ;SOFT HYPHEN
-   * 034F ;COMBINING GRAPHEME JOINER
-   * #115F ;HANGUL CHOSEONG FILLER
-   * #1160 ;HANGUL JUNGSEONG FILLER
-   * 17B4 ;KHMER VOWEL INHERENT AQ
-   * 17B5 ;KHMER VOWEL INHERENT AA
-   * 180B..180D ;MONGOLIAN FREE VARIATION SELECTOR THREE
-   * 200B..200F ;RIGHT-TO-LEFT MARK
-   * 202A..202E ;RIGHT-TO-LEFT OVERRIDE
-   * 2060..206F ;NOMINAL DIGIT SHAPES
-   * #3164 ;HANGUL FILLER
-   * FE00..FE0F ;VARIATION SELECTOR-16
-   * FEFF ;ZERO WIDTH NO-BREAK SPACE
-   * #FFA0 ;HALFWIDTH HANGUL FILLER
-   * FFF0..FFF8 ;unassigned-FFF8
-   * 1D173..1D17A ;MUSICAL SYMBOL END PHRASE
-   * E..E0FFF ;unassigned-E0FFF
+   * Unicode 7.0:
+   * $ grep '; Default_Ignorable_Code_Point ' DerivedCoreProperties.txt | sed 
's/;.*#/#/'
+   * 00AD  # Cf   SOFT HYPHEN
+   * 034F  # Mn   COMBINING GRAPHEME JOINER
+   * 061C  # Cf   ARABIC LETTER MARK
+   * 115F..1160# Lo   [2] HANGUL CHOSEONG FILLER..HANGUL JUNGSEONG FILLER
+   * 17B4..17B5# Mn   [2] KHMER VOWEL INHERENT AQ..KHMER VOWEL INHERENT AA
+   * 180B..180D# Mn   [3] MONGOLIAN FREE VARIATION SELECTOR ONE..MONGOLIAN 
FREE VARIATION SELECTOR THREE
+   * 180E  # Cf   MONGOLIAN VOWEL SEPARATOR
+   * 200B..200F# Cf   [5] ZERO WIDTH SPACE..RIGHT-TO-LEFT MARK
+   * 202A..202E# Cf   [5] LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE
+   * 2060..2064# Cf   [5] WORD JOINER..INVISIBLE PLUS
+   * 2065  # Cn   reserved-2065
+   * 2066..206F# Cf  [10] LEFT-TO-RIGHT ISOLATE..NOMINAL DIGIT SHAPES
+   * 3164  # Lo   HANGUL FILLER
+   * FE00..FE0F# Mn  [16] VARIATION SELECTOR-1..VARIATION SELECTOR-16
+   * FEFF  # Cf   ZERO WIDTH NO-BREAK SPACE
+   * FFA0  # Lo   HALFWIDTH HANGUL FILLER
+   * FFF0..FFF8# Cn   [9] reserved-FFF0..reserved-FFF8
+   * 1BCA0..1BCA3  # Cf   [4] SHORTHAND FORMAT LETTER OVERLAP..SHORTHAND 
FORMAT UP STEP
+   * 1D173..1D17A  # Cf   [8] MUSICAL SYMBOL BEGIN BEAM..MUSICAL SYMBOL END 
PHRASE
+   * E # Cn   reserved-E
+   * E0001 # Cf   LANGUAGE TAG
+   * E0002..E001F  # Cn  [30] reserved-E0002..reserved-E001F
+   * E0020..E007F  # Cf  [96] TAG SPACE..CANCEL TAG
+   * E0080..E00FF  # Cn [128] reserved-E0080..reserved-E00FF
+   * E0100..E01EF  # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
+   * E01F0..E0FFF  # Cn [3600] reserved-E01F0..reserved-E0FFF
*/
   inline hb_bool_t
   is_default_ignorable (hb_codepoint_t ch)
@@ -197,7 +190,8 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
 {
   /* Other planes */
   switch (plane) {
-   case 0x01: return hb_in_rangehb_codepoint_t (ch, 0x0001D173, 
0x0001D17A);
+   case 0x01: return hb_in_rangeshb_codepoint_t (ch, 0x0001BCA0, 
0x0001BCA3,
+   0x0001D173, 
0x0001D17A);
case 0x0E: return hb_in_rangehb_codepoint_t (ch, 0x000E, 

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

2014-05-23 Thread Behdad Esfahbod
 src/hb-ot-shape-complex-indic-machine.rl |   13 ++---
 src/hb-ot-shape-complex-indic-private.hh |4 ++--
 src/hb-ot-shape-complex-indic.cc |   27 ---
 3 files changed, 28 insertions(+), 16 deletions(-)

New commits:
commit e9b2a4cfe593bdbe9288571635ba26ac42ede987
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 23 15:49:10 2014 -0400

[indic] Support U+1CED

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 230c8e4..f17cf41 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -215,6 +215,11 @@ set_indic_properties (hb_glyph_info_t info)
* For now, just treat them like regular tone marks. */
   else if (unlikely (hb_in_rangehb_codepoint_t (u, 0x1CE2, 0x1CE8)))
 cat = OT_A;
+  /* TODO: The following should only be allowed after some of
+   * the nasalization marks, maybe only for U+1CE9..U+1CF1.
+   * For now, just treat them like tone marks. */
+  else if (unlikely (u == 0x1CED))
+cat = OT_A;
   /* The following are Visarga variants. */
   else if (unlikely (hb_in_rangehb_codepoint_t (u, 0x1CF2, 0x1CF3)))
   {
commit d19f8e85702a1e473efe2f02027984dcc127602a
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 23 15:45:50 2014 -0400

[indic] Support U+A8F2..A8F7,1CE9..1CEC,1CEE..1CF1

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 89fc46c..230c8e4 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -221,6 +221,14 @@ set_indic_properties (hb_glyph_info_t info)
 cat = OT_SM;
 ASSERT_STATIC ((int) INDIC_SYLLABIC_CATEGORY_VISARGA == OT_SM);
   }
+  /* The following take marks in standalone clusters, similar to Avagraha. */
+  else if (unlikely (hb_in_rangeshb_codepoint_t (u, 0xA8F2, 0xA8F7,
+ 0x1CE9, 0x1CEC,
+ 0x1CEE, 0x1CF1)))
+  {
+cat = OT_Symbol;
+ASSERT_STATIC ((int) INDIC_SYLLABIC_CATEGORY_AVAGRAHA == OT_Symbol);
+  }
 
   if (unlikely (u == 0x17D1))
 cat = OT_X;
commit ddbdfcbf1c10eed0a7b81b29fee99f1bd22113e5
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 23 15:39:55 2014 -0400

[indic] Simplify grammar

No functional change.

diff --git a/src/hb-ot-shape-complex-indic-machine.rl 
b/src/hb-ot-shape-complex-indic-machine.rl
index 926c2eb..8332348 100644
--- a/src/hb-ot-shape-complex-indic-machine.rl
+++ b/src/hb-ot-shape-complex-indic-machine.rl
@@ -69,19 +69,18 @@ cn = c.ZWJ?.n?;
 forced_rakar = ZWJ H ZWJ Ra;
 symbol = Symbol.N?;
 matra_group = z{0,3}.M.N?.(H | forced_rakar)?;
-syllable_tail2 = (SM.SM?.ZWNJ?)? A{0,3}? VD{0,2};
-syllable_tail =  (Coeng (cn|V))? syllable_tail2;
+syllable_tail = (SM.SM?.ZWNJ?)? A{0,3}? VD{0,2};
 place_holder = NBSP | DOTTEDCIRCLE;
 halant_group = (z?.h.(ZWJ.N?)?);
 final_halant_group = halant_group | h.ZWNJ;
 medial_group = CM?.CM2?;
-halant_or_matra_group = (final_halant_group | (h.ZWJ)? matra_group{0,4});
+halant_or_matra_group = (final_halant_group | (h.ZWJ)? matra_group{0,4}) 
(Coeng (cn|V))?;
 
 
 consonant_syllable =   Repha? (cn.halant_group){0,4} cn medial_group 
halant_or_matra_group syllable_tail;
 vowel_syllable =   reph? V.n? (ZWJ | (halant_group.cn){0,4} medial_group 
halant_or_matra_group syllable_tail);
 standalone_cluster =   reph? place_holder.n? (halant_group.cn){0,4} 
medial_group halant_or_matra_group syllable_tail;
-symbol_cluster =   symbol syllable_tail2;
+symbol_cluster =   symbol syllable_tail;
 broken_cluster =   reph? n? (halant_group.cn){0,4} medial_group 
halant_or_matra_group syllable_tail;
 other =any;
 
commit 4e9b1f662b23966e67c548b86afeff2bec9b0eb7
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 23 15:38:42 2014 -0400

[indic] Always start new syllable for Avagraha

In fact, the previous grammar was ambigious.  No functional
change.

diff --git a/src/hb-ot-shape-complex-indic-machine.rl 
b/src/hb-ot-shape-complex-indic-machine.rl
index c64c03e..926c2eb 100644
--- a/src/hb-ot-shape-complex-indic-machine.rl
+++ b/src/hb-ot-shape-complex-indic-machine.rl
@@ -70,7 +70,7 @@ forced_rakar = ZWJ H ZWJ Ra;
 symbol = Symbol.N?;
 matra_group = z{0,3}.M.N?.(H | forced_rakar)?;
 syllable_tail2 = (SM.SM?.ZWNJ?)? A{0,3}? VD{0,2};
-syllable_tail =  (Coeng (cn|V))? symbol? syllable_tail2;
+syllable_tail =  (Coeng (cn|V))? syllable_tail2;
 place_holder = NBSP | DOTTEDCIRCLE;
 halant_group = (z?.h.(ZWJ.N?)?);
 final_halant_group = halant_group | h.ZWNJ;
commit 9f9bd9bf31161660214b8b39a78cdafbb79db1be
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 23 15:33:13 2014 -0400

[indic] Rename avagraha cluster to symbol cluster

In anticipation of adding more characters to that class of clusters.

diff --git a/src/hb-ot-shape-complex-indic-machine.rl 
b/src/hb-ot-shape-complex-indic-machine.rl
index 

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

2014-05-09 Thread Behdad Esfahbod
 src/Makefile.am |1 
 src/hb-open-type-private.hh |   20 +++
 src/hb-ot-cmap-table.hh |  223 
 src/hb-ot-font.cc   |1 
 4 files changed, 242 insertions(+), 3 deletions(-)

New commits:
commit c8a47452993b9dee6854bfc866aca4a20142696f
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 9 19:55:51 2014 -0400

[ot] Implement cmap subtable format 4

diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index ba2835b..e02c234 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -47,7 +47,59 @@ struct CmapSubtableFormat4
   private:
   inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
   {
+unsigned int segCount;
+const USHORT *endCount;
+const USHORT *startCount;
+const USHORT *idDelta;
+const USHORT *idRangeOffset;
+const USHORT *glyphIdArray;
+unsigned int glyphIdArrayLength;
+
+segCount = this-segCountX2 / 2;
+endCount = this-values;
+startCount = endCount + segCount + 1;
+idDelta = startCount + segCount;
+idRangeOffset = idDelta + segCount;
+glyphIdArray = idRangeOffset + segCount;
+glyphIdArrayLength = (this-length - 16 - 8 * segCount) / 2;
+
+/* Custom bsearch. */
+int min = 0, max = (int) segCount - 1;
+unsigned int i;
+while (min = max)
+{
+  int mid = (min + max) / 2;
+  if (codepoint  startCount[mid])
+max = mid - 1;
+  else if (codepoint  endCount[mid])
+min = mid + 1;
+  else
+  {
+   i = mid;
+   goto found;
+  }
+}
 return false;
+
+  found:
+hb_codepoint_t gid;
+unsigned int rangeOffset = idRangeOffset[i];
+if (rangeOffset == 0)
+  gid = codepoint + idDelta[i];
+else
+{
+  /* Somebody has been smoking... */
+  unsigned int index = rangeOffset / 2 + (codepoint - startCount[i]) + i - 
segCount;
+  if (unlikely (index = glyphIdArrayLength))
+   return false;
+  gid = glyphIdArray[index];
+  if (unlikely (!gid))
+   return false;
+  gid += idDelta[i];
+}
+
+*glyph = gid  0x;
+return true;
   }
 
   inline bool sanitize (hb_sanitize_context_t *c) {
commit 4719621f20dfd6a0377c650a7b4df223c18dc143
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 9 16:09:11 2014 -0400

Minor

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 40402fb..d9be744 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -840,7 +840,6 @@ struct GenericArrayOf
   template typename SearchType
   inline int search (const SearchType x) const
   {
-/* Hand-coded bsearch here since this is in the hot inner loop. */
 unsigned int count = len;
 for (unsigned int i = 0; i  count; i++)
   if (!this-array[i].cmp (x))
commit 41ca1fbebf61cf26e1e0e4b11f4a5b52fb7d88a9
Author: Behdad Esfahbod beh...@behdad.org
Date:   Fri May 9 15:35:56 2014 -0400

[ot] Start implementing cmap table

diff --git a/src/Makefile.am b/src/Makefile.am
index e2dd944..f670e27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,7 @@ HBSOURCES =  \
hb-object-private.hh \
hb-open-file-private.hh \
hb-open-type-private.hh \
+   hb-ot-cmap-table.hh \
hb-ot-head-table.hh \
hb-ot-hhea-table.hh \
hb-ot-hmtx-table.hh \
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
new file mode 100644
index 000..ba2835b
--- /dev/null
+++ b/src/hb-ot-cmap-table.hh
@@ -0,0 +1,171 @@
+/*
+ * Copyright © 2014  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN AS IS BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_OT_CMAP_TABLE_HH
+#define HB_OT_CMAP_TABLE_HH
+
+#include hb-open-type-private.hh
+
+
+namespace OT {
+
+
+/*
+ * cmap -- Character To Glyph Index Mapping Table
+ */
+
+#define HB_OT_TAG_cmap HB_TAG('c','m','a','p')
+
+
+struct CmapSubtableFormat4
+{
+  friend struct CmapSubtable;
+
+  

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

2013-12-02 Thread Behdad Esfahbod
 src/hb-ot-shape-private.hh   |2 -
 src/hb-shape-plan-private.hh |5 ++-
 src/hb-shape-plan.cc |   69 +++
 util/options.cc  |5 ++-
 util/view-cairo.hh   |2 -
 5 files changed, 67 insertions(+), 16 deletions(-)

New commits:
commit f47b9219546edcfdeb3991ee27f6d9ba455c3e08
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Dec 2 05:57:27 2013 -0500

Fix unsafe shape_plan-face dependency

diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index 8171471..cbfab5b 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -66,7 +66,7 @@ struct hb_ot_shape_planner_t
   hb_ot_map_builder_t map;
 
   hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) :
-face (master_plan-face),
+face (master_plan-face_unsafe),
 props (master_plan-props),
 shaper (NULL),
 map (face, props) {}
diff --git a/src/hb-shape-plan-private.hh b/src/hb-shape-plan-private.hh
index ee48767..e12b05f 100644
--- a/src/hb-shape-plan-private.hh
+++ b/src/hb-shape-plan-private.hh
@@ -39,7 +39,7 @@ struct hb_shape_plan_t
   ASSERT_POD ();
 
   hb_bool_t default_shaper_list;
-  hb_face_t *face;
+  hb_face_t *face_unsafe; /* We don't carry a reference to face. */
   hb_segment_properties_t props;
 
   hb_shape_func_t *shaper_func;
diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc
index d2aa03b..e354f29 100644
--- a/src/hb-shape-plan.cc
+++ b/src/hb-shape-plan.cc
@@ -46,7 +46,7 @@ hb_shape_plan_plan (hb_shape_plan_t*shape_plan,
 
 #define HB_SHAPER_PLAN(shaper) \
HB_STMT_START { \
- if (hb_##shaper##_shaper_face_data_ensure (shape_plan-face)) { \
+ if (hb_##shaper##_shaper_face_data_ensure (shape_plan-face_unsafe)) 
{ \
HB_SHAPER_DATA (shaper, shape_plan) = \
  HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, 
user_features, num_user_features); \
shape_plan-shaper_func = _hb_##shaper##_shape; \
@@ -122,7 +122,7 @@ hb_shape_plan_create (hb_face_t *face,
 
   hb_face_make_immutable (face);
   shape_plan-default_shaper_list = shaper_list == NULL;
-  shape_plan-face = hb_face_reference (face);
+  shape_plan-face_unsafe = face;
   shape_plan-props = *props;
   shape_plan-num_user_features = num_user_features;
   shape_plan-user_features = features;
@@ -202,7 +202,6 @@ hb_shape_plan_destroy (hb_shape_plan_t *shape_plan)
 #include hb-shaper-list.hh
 #undef HB_SHAPER_IMPLEMENT
 
-  hb_face_destroy (shape_plan-face);
   free (shape_plan-user_features);
 
   free (shape_plan);
@@ -277,7 +276,7 @@ hb_shape_plan_execute (hb_shape_plan_t*shape_plan,
hb_object_is_inert (buffer)))
 return false;
 
-  assert (shape_plan-face == font-face);
+  assert (shape_plan-face_unsafe == font-face);
   assert (hb_segment_properties_equal (shape_plan-props, buffer-props));
 
 #define HB_SHAPER_EXECUTE(shaper) \
@@ -444,11 +443,6 @@ retry:
 goto retry;
   }
 
-  /* Release our reference on face. */
-  /* XXX This is unsafe, since the face can be freed before us,
-   * and we will call hb_face_destroy() in our destroy()! */
-  hb_face_destroy (face);
-
   return hb_shape_plan_reference (shape_plan);
 }
 
commit c704a8700e169885f1d9cbab93544d85aa4358e9
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Dec 2 05:42:04 2013 -0500

[util] Fix uninitialized memory access

diff --git a/util/view-cairo.hh b/util/view-cairo.hh
index 2c504c1..7fe217c 100644
--- a/util/view-cairo.hh
+++ b/util/view-cairo.hh
@@ -36,7 +36,7 @@ struct view_cairo_t
   view_cairo_t (option_parser_t *parser)
   : output_options (parser, helper_cairo_supported_formats),
 view_options (parser),
-lines (0), scale (1.0) {}
+lines (0), scale (1.0), direction (HB_DIRECTION_INVALID) {}
   ~view_cairo_t (void) {
 if (debug)
   cairo_debug_reset_static_data ();
commit 260a3198f44a4ece60864b6f6caab2ee756ad762
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Dec 2 05:39:39 2013 -0500

[util] Plug leak

diff --git a/util/options.cc b/util/options.cc
index 66b5e15..3ae2454 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -369,11 +369,12 @@ void
 output_options_t::add_options (option_parser_t *parser)
 {
   const char *text;
+  char *text_free = NULL;
 
   if (NULL == supported_formats)
 text = Set output format;
   else
-text = g_strdup_printf (Set output format\n\nSupported formats are: 
%s, supported_formats);
+text = text_free = g_strdup_printf (Set output format\n\nSupported 
formats are: %s, supported_formats);
 
   GOptionEntry entries[] =
   {
@@ -386,6 +387,8 @@ output_options_t::add_options (option_parser_t *parser)
 Output options:,
 Options controlling the output,
 this);
+
+ 

Re: [HarfBuzz] harfbuzz: Branch 'master' - 5 commits

2013-09-03 Thread Behdad Esfahbod
On 13-09-02 06:41 AM, Khaled Hosny wrote:
 On Fri, Aug 09, 2013 at 06:42:20AM -0700, Behdad Esfahbod wrote:
 commit 10f964623f003c70f6bdd33423420abda3820ce0
 Author: Behdad Esfahbod beh...@behdad.org
 Date:   Fri Aug 9 09:40:01 2013 -0400

 Round when scaling values
 
 Doesn't matter for most users since they should be working in a
 fixed sub-pixel scale anyway (ie. 22.10, 26.6, 16.16, etc).
 
 With this commit, I’m seeing one pixel differences in my test suit,
 things like (with Amiri):
 
 expected:  
 [uni06DD+2620|one.small@-2210,0+0|two.small@-1610,0+0|three.small@-1010,0+0]
 result:
 [uni06DD+2620|one.small@-2209,0+1|two.small@-1609,0+1|three.small@-1009,0+1]
 
 Looks harmless, but wanted to double check before updating the expected
 output.

Are you shaping at upem size?  If yes, then the change may be a bug.  I don't
have sortsmill so can't test.  If Uniscribe returns the old value then this is
definitely a bug.  Feel free to suggest a patch.  Or we can just revert.

BTW, is Amiri still on SF, or github?  If it's on github, may be a good idea
to set it up on travis-ci.org, then add a hook from harfbuzz github to trigger
amiri tests on travis, and send failure reports to harfbuzz list.

Same about any other font projects that test against harfbuzz BTW!

 Regards,
 Khaled
 

-- 
behdad
http://behdad.org/
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] harfbuzz: Branch 'master' - 5 commits

2013-09-03 Thread Khaled Hosny
On Tue, Sep 03, 2013 at 04:21:12PM -0400, Behdad Esfahbod wrote:
 Are you shaping at upem size?

That is just the output of hb-shape, so I guess yes.

 If Uniscribe returns the old value then this is definitely a bug.

Seems so:

  $ cat test | hb-shape.exe amiri-regular.ttf --shapers=uniscribe
  
[uni06DD=0+2620|one.small=1@-2210,0+0|two.small=2@-1610,0+0|three.small=3@-1010,0+0]

  $ cat test | hb-shape.exe amiri-regular.ttf --shapers=ot
  
[uni06DD=0+2620|one.small=1@-2209,0+1|two.small=2@-1609,0+1|three.small=3@-1009,0+1]

 Feel free to suggest a patch.  Or we can just revert.

I’m not sure I understand the math behind that commit, so I can’t
suggest a fix.

 BTW, is Amiri still on SF, or github?  If it's on github, may be a good idea
 to set it up on travis-ci.org, then add a hook from harfbuzz github to trigger
 amiri tests on travis, and send failure reports to harfbuzz list.

There is a github mirror, that would be nice if it can be done, but I
need to check how to setup travis.

Regards,
Khaled
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] harfbuzz: Branch 'master' - 5 commits

2013-09-03 Thread Khaled Hosny
On Tue, Sep 03, 2013 at 06:16:37PM -0400, Behdad Esfahbod wrote:
 On 13-09-03 06:08 PM, Khaled Hosny wrote:
  On Tue, Sep 03, 2013 at 04:21:12PM -0400, Behdad Esfahbod wrote:
  Are you shaping at upem size?
  
  That is just the output of hb-shape, so I guess yes.
  
  If Uniscribe returns the old value then this is definitely a bug.
  
  Seems so:
  
$ cat test | hb-shape.exe amiri-regular.ttf --shapers=uniscribe

  [uni06DD=0+2620|one.small=1@-2210,0+0|two.small=2@-1610,0+0|three.small=3@-1010,0+0]
  
$ cat test | hb-shape.exe amiri-regular.ttf --shapers=ot

  [uni06DD=0+2620|one.small=1@-2209,0+1|two.small=2@-1609,0+1|three.small=3@-1009,0+1]
  
  Feel free to suggest a patch.  Or we can just revert.
  
  I’m not sure I understand the math behind that commit, so I can’t
  suggest a fix.
 
 It's simply adding .5, supposedly to get round instead of floor behavior.  I
 probably screwed up.  Will check.

I figured that out, but it looked like it was subtracting .5 for me,
which was puzzling. I guess I know why now, the affected values are
negative, so it ends up with something like:

  (-2210.0 * 2048 + 1024) / 2048

which is -2209.5, not -2210.5 as probably expected.

Regards,
Khaled
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] harfbuzz: Branch 'master' - 5 commits

2013-04-04 Thread Behdad Esfahbod
On 13-03-24 08:28 AM, Khaled Hosny wrote:
 On Tue, Feb 12, 2013 at 06:49:01AM -0800, Behdad Esfahbod wrote:
 commit 568000274c8edb5f41bc4f876ce21fcc8bdaeed8
 Author: Behdad Esfahbod beh...@behdad.org
 Date:   Tue Feb 12 09:44:57 2013 -0500

 Adjust mark advance-width zeroing logic for Myanmar
 
 Before, we were zeroing advance width of attached marks for
 non-Indic scripts, and not doing it for Indic.
 
 We have now three different behaviors, which seem to better
 reflect what Uniscribe is doing:
 
   - For Indic, no explicit zeroing happens whatsoever, which
 is the same as before,
 
   - For Myanmar, zero advance width of glyphs marked as marks
 *in GDEF*, and do that *before* applying GPOS.  This seems
 to be what the new Win8 Myanmar shaper does,
 
   - For everything else, zero advance width of glyphs that are
 from General_Category=Mn Unicode characters, and do so
 before applying GPOS.  This seems to be what Uniscribe does
 for Latin at least.
 
 With these changes, positioning of all tests matches for Myanmar,
 except for the glitch in Uniscribe not applying 'mark'.  See preivous
 commit.
 
 This commit is causing a regression with Amiri, the string “هَٰذ” with
 Uniscribe and HarfBuzz before this commit, gives:
 
   
 [uni0630.fina=3+965|uni0670.medi=0+600|uni064E=0@-256,0+0|uni0647.init=0+926]
 
 But now it gives:
 
   
 [uni0630.fina=3+965|uni0670.medi=0+0|uni064E=0@-256,0+0|uni0647.init=0+926]
 
 i.e. uni0670.medi is zeroed though it has a base glyph GDEF class.

Ugh.  I'm looking into this.  Will hopefully get it resolved today.


 Regards,
 Khaled
 

-- 
behdad
http://behdad.org/
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] harfbuzz: Branch 'master' - 5 commits

2013-03-24 Thread Khaled Hosny
On Tue, Feb 12, 2013 at 06:49:01AM -0800, Behdad Esfahbod wrote:
 commit 568000274c8edb5f41bc4f876ce21fcc8bdaeed8
 Author: Behdad Esfahbod beh...@behdad.org
 Date:   Tue Feb 12 09:44:57 2013 -0500
 
 Adjust mark advance-width zeroing logic for Myanmar
 
 Before, we were zeroing advance width of attached marks for
 non-Indic scripts, and not doing it for Indic.
 
 We have now three different behaviors, which seem to better
 reflect what Uniscribe is doing:
 
   - For Indic, no explicit zeroing happens whatsoever, which
 is the same as before,
 
   - For Myanmar, zero advance width of glyphs marked as marks
 *in GDEF*, and do that *before* applying GPOS.  This seems
 to be what the new Win8 Myanmar shaper does,
 
   - For everything else, zero advance width of glyphs that are
 from General_Category=Mn Unicode characters, and do so
 before applying GPOS.  This seems to be what Uniscribe does
 for Latin at least.
 
 With these changes, positioning of all tests matches for Myanmar,
 except for the glitch in Uniscribe not applying 'mark'.  See preivous
 commit.

This commit is causing a regression with Amiri, the string “هَٰذ” with
Uniscribe and HarfBuzz before this commit, gives:


[uni0630.fina=3+965|uni0670.medi=0+600|uni064E=0@-256,0+0|uni0647.init=0+926]

But now it gives:


[uni0630.fina=3+965|uni0670.medi=0+0|uni064E=0@-256,0+0|uni0647.init=0+926]

i.e. uni0670.medi is zeroed though it has a base glyph GDEF class.

Regards,
Khaled
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2013-02-12 Thread Behdad Esfahbod
 src/hb-atomic-private.hh   |2 -
 src/hb-mutex-private.hh|2 -
 src/hb-ot-layout-gpos-table.hh |   12 ++-
 src/hb-ot-layout-private.hh|3 -
 src/hb-ot-layout.cc|4 +-
 src/hb-ot-shape-complex-arabic.cc  |2 -
 src/hb-ot-shape-complex-default.cc |2 -
 src/hb-ot-shape-complex-indic.cc   |2 -
 src/hb-ot-shape-complex-myanmar-machine.rl |6 +--
 src/hb-ot-shape-complex-myanmar.cc |   47 +++--
 src/hb-ot-shape-complex-private.hh |9 -
 src/hb-ot-shape-complex-thai.cc|2 -
 src/hb-ot-shape.cc |   31 +--
 13 files changed, 96 insertions(+), 28 deletions(-)

New commits:
commit 568000274c8edb5f41bc4f876ce21fcc8bdaeed8
Author: Behdad Esfahbod beh...@behdad.org
Date:   Tue Feb 12 09:44:57 2013 -0500

Adjust mark advance-width zeroing logic for Myanmar

Before, we were zeroing advance width of attached marks for
non-Indic scripts, and not doing it for Indic.

We have now three different behaviors, which seem to better
reflect what Uniscribe is doing:

  - For Indic, no explicit zeroing happens whatsoever, which
is the same as before,

  - For Myanmar, zero advance width of glyphs marked as marks
*in GDEF*, and do that *before* applying GPOS.  This seems
to be what the new Win8 Myanmar shaper does,

  - For everything else, zero advance width of glyphs that are
from General_Category=Mn Unicode characters, and do so
before applying GPOS.  This seems to be what Uniscribe does
for Latin at least.

With these changes, positioning of all tests matches for Myanmar,
except for the glitch in Uniscribe not applying 'mark'.  See preivous
commit.

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 148a57c..59d818e 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1528,7 +1528,7 @@ struct GPOS : GSUBGPOS
   { return CastRPosLookup (GSUBGPOS::get_lookup (i)); }
 
   static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
-  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, 
hb_bool_t zero_width_attahced_marks);
+  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer);
 
   inline bool sanitize (hb_sanitize_context_t *c) {
 TRACE_SANITIZE (this);
@@ -1561,17 +1561,13 @@ fix_cursive_minor_offset (hb_glyph_position_t *pos, 
unsigned int i, hb_direction
 }
 
 static void
-fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t 
direction, hb_bool_t zero_width_attached_marks)
+fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t 
direction)
 {
   if (likely (!(pos[i].attach_lookback(
 return;
 
   unsigned int j = i - pos[i].attach_lookback();
 
-  if (zero_width_attached_marks) {
-pos[i].x_advance = 0;
-pos[i].y_advance = 0;
-  }
   pos[i].x_offset += pos[j].x_offset;
   pos[i].y_offset += pos[j].y_offset;
 
@@ -1598,7 +1594,7 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, 
hb_buffer_t *buffer)
 }
 
 void
-GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, 
hb_bool_t zero_width_attached_marks)
+GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
 {
   unsigned int len;
   hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, len);
@@ -1610,7 +1606,7 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, 
hb_buffer_t *buffer, hb_bool_t
 
   /* Handle attachments */
   for (unsigned int i = 0; i  len; i++)
-fix_mark_attachment (pos, i, direction, zero_width_attached_marks);
+fix_mark_attachment (pos, i, direction);
 
   HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
   HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 49093de..b550fa8 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -176,8 +176,7 @@ hb_ot_layout_position_lookup (hb_font_t*font,
 /* Should be called after all the position_lookup's are done */
 HB_INTERNAL void
 hb_ot_layout_position_finish (hb_font_t*font,
- hb_buffer_t  *buffer,
- hb_bool_t zero_width_attached_marks);
+ hb_buffer_t  *buffer);
 
 
 
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3ff6fc8..291ff9a 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -727,9 +727,9 @@ hb_ot_layout_position_lookup (hb_font_t*font,
 }
 
 void
-hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t 
zero_width_attached_marks)
+hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer)
 {
-  OT::GPOS::position_finish (font, buffer, zero_width_attached_marks);
+  

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

2012-11-14 Thread Behdad Esfahbod
 src/Makefile.am |3 
 src/hb-ot-map-private.hh|8 
 src/hb-ot-map.cc|6 
 src/hb-ot-shape-complex-arabic.cc   |1 
 src/hb-ot-shape-complex-default.cc  |  225 
+
 src/hb-ot-shape-complex-indic.cc|2 
 src/hb-ot-shape-complex-misc.cc |  339 

 src/hb-ot-shape-complex-private.hh  |   13 
 src/hb-ot-shape-complex-thai.cc |  378 
++
 test/shaping/texts/in-tree/shaper-thai/script-thai/misc/MANIFEST|1 
 test/shaping/texts/in-tree/shaper-thai/script-thai/misc/pua-shaping.txt |   11 
 11 files changed, 635 insertions(+), 352 deletions(-)

New commits:
commit 1eb3e94fe99a072ce422e60ac4d4d89ef489b08a
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Nov 14 17:25:03 2012 -0800

[Thai] Implement PUA-based fallback shaping

As explained here:

  http://linux.thai.net/~thep/th-otf/shaping.html

Our output now matches Uniscribe for old fonts (eg. XP Tahoma) with no
Thai GSUB table.

diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc
index 0736eca..87fe521 100644
--- a/src/hb-ot-shape-complex-thai.cc
+++ b/src/hb-ot-shape-complex-thai.cc
@@ -29,13 +29,230 @@
 
 /* Thai / Lao shaper */
 
+
+/* PUA shaping */
+
+
+enum thai_consonant_type_t
+{
+  NC,
+  AC,
+  RC,
+  DC,
+  NOT_CONSONANT,
+  NUM_CONSONANT_TYPES = NOT_CONSONANT
+};
+
+static thai_consonant_type_t
+get_consonant_type (hb_codepoint_t u)
+{
+  if (u == 0x0E1B || u == 0x0E1D || u == 0x0E1F || u == 0x0E2C)
+return AC;
+  if (u == 0x0E0D || u == 0x0E10)
+return RC;
+  if (u == 0x0E0E || u == 0x0E0F)
+return DC;
+  if (hb_in_rangehb_codepoint_t (u, 0x0E01, 0x0E2E))
+return NC;
+  return NOT_CONSONANT;
+}
+
+
+enum thai_mark_type_t
+{
+  AV,
+  BV,
+  T,
+  NOT_MARK,
+  NUM_MARK_TYPES = NOT_MARK
+};
+
+static thai_mark_type_t
+get_mark_type (hb_codepoint_t u)
+{
+  if (u == 0x0E31 || hb_in_rangehb_codepoint_t (u, 0x0E34, 0x0E37) ||
+  u == 0x0E47 || hb_in_rangehb_codepoint_t (u, 0x0E4D, 0x0E4E))
+return AV;
+  if (hb_in_rangehb_codepoint_t (u, 0x0E38, 0x0E3A))
+return BV;
+  if (hb_in_rangehb_codepoint_t (u, 0x0E48, 0x0E4C))
+return T;
+  return NOT_MARK;
+}
+
+
+enum thai_action_t
+{
+  NOP,
+  SD,  /* Shift combining-mark down */
+  SL,  /* Shift combining-mark left */
+  SDL, /* Shift combining-mark down-left */
+  RD   /* Remove descender from base */
+};
+
+static hb_codepoint_t
+thai_pua_shape (hb_codepoint_t u, thai_action_t action, hb_font_t *font)
+{
+  struct thai_pua_mapping_t {
+hb_codepoint_t u;
+hb_codepoint_t win_pua;
+hb_codepoint_t mac_pua;
+  } const *pua_mappings = NULL;
+  static const thai_pua_mapping_t SD_mappings[] = {
+{0x0E48, 0xF70A, 0xF88B}, /* MAI EK */
+{0x0E49, 0xF70B, 0xF88E}, /* MAI THO */
+{0x0E4A, 0xF70C, 0xF891}, /* MAI TRI */
+{0x0E4B, 0xF70D, 0xF894}, /* MAI CHATTAWA */
+{0x0E4C, 0xF70E, 0xF897}, /* THANTHAKHAT */
+{0x0E38, 0xF718, 0xF89B}, /* SARA U */
+{0x0E39, 0xF719, 0xF89C}, /* SARA UU */
+{0x0E3A, 0xF71A, 0xF89D}, /* PHINTHU */
+{0x, 0x, 0x}
+  };
+  static const thai_pua_mapping_t SDL_mappings[] = {
+{0x0E48, 0xF705, 0xF88C}, /* MAI EK */
+{0x0E49, 0xF706, 0xF88F}, /* MAI THO */
+{0x0E4A, 0xF707, 0xF892}, /* MAI TRI */
+{0x0E4B, 0xF708, 0xF895}, /* MAI CHATTAWA */
+{0x0E4C, 0xF709, 0xF898}, /* THANTHAKHAT */
+{0x, 0x, 0x}
+  };
+  static const thai_pua_mapping_t SL_mappings[] = {
+{0x0E48, 0xF713, 0xF88A}, /* MAI EK */
+{0x0E49, 0xF714, 0xF88D}, /* MAI THO */
+{0x0E4A, 0xF715, 0xF890}, /* MAI TRI */
+{0x0E4B, 0xF716, 0xF893}, /* MAI CHATTAWA */
+{0x0E4C, 0xF717, 0xF896}, /* THANTHAKHAT */
+{0x0E31, 0xF710, 0xF884}, /* MAI HAN-AKAT */
+{0x0E34, 0xF701, 0xF885}, /* SARA I */
+{0x0E35, 0xF702, 0xF886}, /* SARA II */
+{0x0E36, 0xF703, 0xF887}, /* SARA UE */
+{0x0E37, 0xF704, 0xF888}, /* SARA UEE */
+{0x0E47, 0xF712, 0xF889}, /* MAITAIKHU */
+{0x0E4D, 0xF711, 0xF899}, /* NIKHAHIT */
+{0x, 0x, 0x}
+  };
+  static const thai_pua_mapping_t RD_mappings[] = {
+{0x0E0D, 0xF70F, 0xF89A}, /* YO YING */
+{0x0E10, 0xF700, 0xF89E}, /* THO THAN */
+{0x, 0x, 0x}
+  };
+
+  switch (action) {
+default: assert (false); /* Fallthrough */
+case NOP: return u;
+case SD:  pua_mappings = SD_mappings; break;
+case SDL: pua_mappings = SDL_mappings; break;
+case SL:  pua_mappings = SL_mappings; break;
+case RD:  pua_mappings = RD_mappings; break;
+  }
+  for (; pua_mappings-u; pua_mappings++)
+if (pua_mappings-u == u)
+