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

2012-07-28 Thread Behdad Esfahbod
 src/hb-ot-layout-common-private.hh   |8 -
 src/hb-ot-layout-gpos-table.hh   |  179 +
 src/hb-ot-layout-gsub-table.hh   |  188 ++-
 src/hb-ot-layout-gsubgpos-private.hh |   52 ++---
 4 files changed, 313 insertions(+), 114 deletions(-)

New commits:
commit 338fe662b50f9309bf0050dd99becb644874195b
Author: Behdad Esfahbod beh...@behdad.org
Date:   Sat Jul 28 18:53:01 2012 -0400

[GSUB] Minor

diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index d95b691..03244b5 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1106,22 +1106,6 @@ struct SubstLookup : Lookup
 if (!_hb_ot_layout_check_glyph_property (c-face, c-buffer-cur(), 
c-lookup_props, c-property))
   return false;
 
-/* TODO: For the most common case this can move out of the main
- * loop, but it's not a big deal for now. */
-if (unlikely (lookup_type == SubstLookupSubTable::Extension))
-{
-  /* The spec says all subtables should have the same type.
-   * This is specially important if one has a reverse type!
-   *
-   * This is rather slow to do this here for every glyph,
-   * but it's easiest, and who uses extension lookups anyway?!*/
-  unsigned int type = get_subtable(0).u.extension.get_type ();
-  unsigned int count = get_subtable_count ();
-  for (unsigned int i = 1; i  count; i++)
-if (get_subtable(i).u.extension.get_type () != type)
- return false;
-}
-
 unsigned int count = get_subtable_count ();
 for (unsigned int i = 0; i  count; i++)
   if (get_subtable (i).apply (c, lookup_type))
@@ -1191,7 +1175,22 @@ struct SubstLookup : Lookup
 TRACE_SANITIZE ();
 if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
 OffsetArrayOfSubstLookupSubTable list = 
CastROffsetArrayOfSubstLookupSubTable  (subTable);
-return TRACE_RETURN (list.sanitize (c, this, get_type ()));
+if (unlikely (!list.sanitize (c, this, get_type ( return TRACE_RETURN 
(false);
+
+if (unlikely (get_type () == SubstLookupSubTable::Extension))
+{
+  /* The spec says all subtables of an Extension lookup should
+   * have the same type.  This is specially important if one has
+   * a reverse type!
+   *
+   * We just check that they are all either forward, or reverse. */
+  unsigned int type = get_subtable (0).u.extension.get_type ();
+  unsigned int count = get_subtable_count ();
+  for (unsigned int i = 1; i  count; i++)
+if (get_subtable (i).u.extension.get_type () != type)
+ return TRACE_RETURN (false);
+}
+return TRACE_RETURN (true);
   }
 };
 
commit e6f7479fe34fb4a7cada61d84c2ed70d1fd565c8
Author: Behdad Esfahbod beh...@behdad.org
Date:   Sat Jul 28 18:34:58 2012 -0400

[GSUB] Simplify would-apply

diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 2cbab32..d95b691 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -55,11 +55,6 @@ struct SingleSubstFormat1
 return this+coverage;
   }
 
-  inline bool would_apply (hb_would_apply_context_t *c) const
-  {
-return c-len == 1  (this+coverage) (c-first) != NOT_COVERED;
-  }
-
   inline bool apply (hb_apply_context_t *c) const
   {
 TRACE_APPLY ();
@@ -112,11 +107,6 @@ struct SingleSubstFormat2
 return this+coverage;
   }
 
-  inline bool would_apply (hb_would_apply_context_t *c) const
-  {
-return c-len == 1  (this+coverage) (c-first) != NOT_COVERED;
-  }
-
   inline bool apply (hb_apply_context_t *c) const
   {
 TRACE_APPLY ();
@@ -174,15 +164,6 @@ struct SingleSubst
 }
   }
 
-  inline bool would_apply (hb_would_apply_context_t *c) const
-  {
-switch (u.format) {
-case 1: return u.format1.would_apply (c);
-case 2: return u.format2.would_apply (c);
-default:return false;
-}
-  }
-
   inline bool apply (hb_apply_context_t *c) const
   {
 TRACE_APPLY ();
@@ -276,11 +257,6 @@ struct MultipleSubstFormat1
 return this+coverage;
   }
 
-  inline bool would_apply (hb_would_apply_context_t *c) const
-  {
-return c-len == 1  (this+coverage) (c-first) != NOT_COVERED;
-  }
-
   inline bool apply (hb_apply_context_t *c) const
   {
 TRACE_APPLY ();
@@ -331,14 +307,6 @@ struct MultipleSubst
 }
   }
 
-  inline bool would_apply (hb_would_apply_context_t *c) const
-  {
-switch (u.format) {
-case 1: return u.format1.would_apply (c);
-default:return false;
-}
-  }
-
   inline bool apply (hb_apply_context_t *c) const
   {
 TRACE_APPLY ();
@@ -393,11 +361,6 @@ struct AlternateSubstFormat1
 return this+coverage;
   }
 
-  inline bool would_apply (hb_would_apply_context_t *c) const
-  {
-return c-len == 1  (this+coverage) (c-first) != NOT_COVERED;
-  }
-
   inline bool apply (hb_apply_context_t *c) const
   {
 TRACE_APPLY ();
@@ -466,14 +429,6 @@ struct 

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

2012-05-24 Thread Jonathan Kew

This commit:


New commits:
commit 22afd66a30d01b6771405e76777306f600807bea
Author: Behdad Esfahbodbeh...@behdad.org
Date:   Thu May 17 21:23:49 2012 -0400

 Add hb_atomic_int_set() again


is slightly broken for the HB_NO_MT configuration...


@@ -73,6 +75,7 @@ typedef volatile int hb_atomic_int_t;
  #define HB_ATOMIC_INT_NIL 1
  typedef volatile int hb_atomic_int_t;
  #define hb_atomic_int_add(AI, V)  ((AI) += (V), (AI) - (V))
+#define hb_atomic_int_set(AI)  ((void) ((AI) = (V)))
  #define hb_atomic_int_get(AI) (AI)

  #endif


The hb_atomic_int_set macro needs two args, not just one.

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


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

2012-05-17 Thread Behdad Esfahbod
 TODO |   12 --
 src/Makefile.am  |1 
 src/hb-atomic-private.hh |   84 +++
 src/hb-mutex-private.hh  |   25 +++--
 src/hb-object-private.hh |   52 +
 src/hb-set-private.hh|4 +-
 src/hb-set.cc|4 +-
 src/hb-tt-font.cc|3 +
 src/hb-warning.cc|2 -
 9 files changed, 116 insertions(+), 71 deletions(-)

New commits:
commit 22afd66a30d01b6771405e76777306f600807bea
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu May 17 21:23:49 2012 -0400

Add hb_atomic_int_set() again

diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh
index f9050c3..60b319a 100644
--- a/src/hb-atomic-private.hh
+++ b/src/hb-atomic-private.hh
@@ -44,7 +44,8 @@
 
 #include intrin.h
 typedef long hb_atomic_int_t;
-#define hb_atomic_int_add(AI, V)   _InterlockedExchangeAdd ((AI), V)
+#define hb_atomic_int_add(AI, V)   _InterlockedExchangeAdd ((AI), (V))
+#define hb_atomic_int_set(AI, V)   _InterlockedExchange ((AI), (V))
 #define hb_atomic_int_get(AI)  (_ReadBarrier (), (AI))
 
 
@@ -61,10 +62,11 @@ typedef int32_t hb_atomic_int_t;
 #include glib.h
 typedef volatile int hb_atomic_int_t;
 #if GLIB_CHECK_VERSION(2,29,5)
-#define hb_atomic_int_add(AI, V)   g_atomic_int_add ((AI), V)
+#define hb_atomic_int_add(AI, V)   g_atomic_int_add ((AI), (V))
 #else
-#define hb_atomic_int_add(AI, V)   g_atomic_int_exchange_and_add ((AI), V)
+#define hb_atomic_int_add(AI, V)   g_atomic_int_exchange_and_add ((AI), 
(V))
 #endif
+#define hb_atomic_int_set(AI, V)   g_atomic_int_set ((AI), (V))
 #define hb_atomic_int_get(AI)  g_atomic_int_get ((AI))
 
 
@@ -73,6 +75,7 @@ typedef volatile int hb_atomic_int_t;
 #define HB_ATOMIC_INT_NIL 1
 typedef volatile int hb_atomic_int_t;
 #define hb_atomic_int_add(AI, V)   ((AI) += (V), (AI) - (V))
+#define hb_atomic_int_set(AI)  ((void) ((AI) = (V)))
 #define hb_atomic_int_get(AI)  (AI)
 
 #endif
commit 4aa7258cb16176a89e1547fee8f86571fdd98307
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu May 17 21:01:04 2012 -0400

Fix type conflicts on Windows without glib

diff --git a/src/hb-tt-font.cc b/src/hb-tt-font.cc
index ccd86e1..b2f24f6 100644
--- a/src/hb-tt-font.cc
+++ b/src/hb-tt-font.cc
@@ -24,12 +24,13 @@
  * Google Author(s): Behdad Esfahbod
  */
 
+#include hb-font-private.hh /* Shall be first since may include windows.h */
+
 #include hb-open-type-private.hh
 
 #include hb-ot-hhea-table.hh
 #include hb-ot-hmtx-table.hh
 
-#include hb-font-private.hh
 #include hb-blob.h
 
 #include string.h
commit f039e79d5438a8fc4a3ec11a387bbfc0f6b83024
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu May 17 20:55:12 2012 -0400

Don't use min/max as function names

They can be macros on some systems.  Eg. mingw32.

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 3a7eb81..717e530 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -102,7 +102,7 @@ struct _hb_set_t
 for (unsigned int i = 0; i  ELTS; i++)
   elts[i] = ~other-elts[i];
   }
-  inline hb_codepoint_t min (void) const
+  inline hb_codepoint_t get_min (void) const
   {
 for (unsigned int i = 0; i  ELTS; i++)
   if (elts[i])
@@ -111,7 +111,7 @@ struct _hb_set_t
return i * BITS + j;
 return 0;
   }
-  inline hb_codepoint_t max (void) const
+  inline hb_codepoint_t get_max (void) const
   {
 for (unsigned int i = ELTS; i; i--)
   if (elts[i - 1])
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 9d013a1..0e8adde 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -167,11 +167,11 @@ hb_set_subtract (hb_set_t *set,
 hb_codepoint_t
 hb_set_min (hb_set_t *set)
 {
-  return set-min ();
+  return set-get_min ();
 }
 
 hb_codepoint_t
 hb_set_max (hb_set_t *set)
 {
-  return set-max ();
+  return set-get_max ();
 }
commit 34961e3198e27fa37fd4cfdad12ef86a2e9e51c2
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu May 17 20:50:38 2012 -0400

Prefer native atomic/mutex ops to glib's

diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh
index c4dabe1..f9050c3 100644
--- a/src/hb-atomic-private.hh
+++ b/src/hb-atomic-private.hh
@@ -1,7 +1,7 @@
 /*
  * Copyright © 2007  Chris Wilson
  * Copyright © 2009,2010  Red Hat, Inc.
- * Copyright © 2011  Google, Inc.
+ * Copyright © 2011,2012  Google, Inc.
  *
  *  This is part of HarfBuzz, a text shaping library.
  *
@@ -39,25 +39,15 @@
 
 /* We need external help for these */
 
-#if !defined(HB_NO_MT)  defined(HAVE_GLIB)
-
-#include glib.h
-typedef volatile int hb_atomic_int_t;
-#if GLIB_CHECK_VERSION(2,29,5)
-#define hb_atomic_int_add(AI, V)   g_atomic_int_add ((AI), V)
-#else
-#define hb_atomic_int_add(AI, V)   g_atomic_int_exchange_and_add ((AI), V)
-#endif
-#define hb_atomic_int_get(AI)  g_atomic_int_get ((AI))
 
-
-#elif !defined(HB_NO_MT)  defined(_MSC_VER)  _MSC_VER = 

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

2012-05-05 Thread Behdad Esfahbod
 src/hb-ot-map-private.hh   |   
 7 +-
 src/hb-ot-shape-normalize.cc   |   
 1 
 src/hb-ot-shape.cc |   
35 ++
 src/hb-ot.h|   
 8 ++
 src/hb-set-private.hh  |   
 7 +-
 src/hb-set.cc  |   
 2 
 src/hb-unicode.cc  |   
 2 
 src/main.cc|   
 9 +-
 test/shaping/texts/in-tree/shaper-indic/indic/script-bengali/misc/misc.txt |   
 1 
 9 files changed, 62 insertions(+), 10 deletions(-)

New commits:
commit 1a2a4a0078dda834443edd421037a4bcbad18c5e
Author: Behdad Esfahbod beh...@behdad.org
Date:   Sat May 5 22:38:20 2012 +0200

Fix warning and build issues

As reported by Jonathan Kew on the list.

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index ee489d0..7dd19b9 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -136,7 +136,7 @@ struct _hb_set_t
   elt_t elts[ELTS]; /* 8kb */
 
   ASSERT_STATIC (sizeof (elt_t) * 8 == BITS);
-  ASSERT_STATIC (sizeof (elts) * 8  MAX_G);
+  ASSERT_STATIC (sizeof (elt_t) * 8 * ELTS  MAX_G);
 };
 
 
diff --git a/src/main.cc b/src/main.cc
index 442b1b9..03b6e6c 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -124,10 +124,11 @@ main (int argc, char **argv)
const LangSys langsys = n_langsys == -1
   ? script.get_default_lang_sys ()
   : script.get_lang_sys (n_langsys);
-   printf (n_langsys == -1
-  ?   Default Language System\n
-  :   Language System %2d of %2d: %.4s\n, n_langsys, 
num_langsys,
-   (const char *)script.get_lang_sys_tag (n_langsys));
+   if (n_langsys == -1)
+ printf (  Default Language System\n);
+   else
+ printf (  Language System %2d of %2d: %.4s\n, n_langsys, 
num_langsys,
+ (const char *)script.get_lang_sys_tag (n_langsys));
if (langsys.get_required_feature_index () == Index::NOT_FOUND_INDEX)
  printf (No required feature\n);
 
commit a5e39fed85e069ba1afbf90408349ad99ceb0e1d
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Apr 25 00:14:46 2012 -0400

Minor

diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index c7f4aa0..ee489d0 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -38,6 +38,8 @@ struct _hb_set_t
   inline void init (void) {
 clear ();
   }
+  inline void fini (void) {
+  }
   inline void clear (void) {
 memset (elts, 0, sizeof elts);
   }
diff --git a/src/hb-set.cc b/src/hb-set.cc
index 3b1c5bd..0a0bc61 100644
--- a/src/hb-set.cc
+++ b/src/hb-set.cc
@@ -67,6 +67,8 @@ hb_set_destroy (hb_set_t *set)
 {
   if (!hb_object_destroy (set)) return;
 
+  set-fini ();
+
   free (set);
 }
 
commit 1827dc208c867e433a95237d1ed3fc7a73d1d9a7
Author: Behdad Esfahbod beh...@behdad.org
Date:   Tue Apr 24 16:56:37 2012 -0400

Add hb_ot_shape_glyphs_closure()

Experimental API for now.

diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh
index d5fc4ce..3811206 100644
--- a/src/hb-ot-map-private.hh
+++ b/src/hb-ot-map-private.hh
@@ -69,6 +69,10 @@ struct hb_ot_map_t
   inline void position (hb_font_t *font, hb_buffer_t *buffer) const
   { apply (1, (hb_ot_map_t::apply_lookup_func_t) hb_ot_layout_position_lookup, 
font, buffer); }
 
+  HB_INTERNAL void substitute_closure (hb_face_t *face,
+  hb_set_t *glyphs) const;
+
+
   inline void finish (void) {
 features.finish ();
 lookups[0].finish ();
@@ -125,9 +129,6 @@ struct hb_ot_map_t
  void *face_or_font,
  hb_buffer_t *buffer) const;
 
-  HB_INTERNAL void substitute_closure (hb_face_t *face,
-  hb_set_t *glyphs) const;
-
   hb_mask_t global_mask;
 
   hb_tag_t chosen_script[2];
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index b31cdc5..167b1d7 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -30,6 +30,7 @@
 #include hb-ot-shape-normalize-private.hh
 
 #include hb-font-private.hh
+#include hb-set-private.hh
 
 
 
@@ -478,3 +479,37 @@ _hb_ot_shape (hb_font_t  *font,
 
   return TRUE;
 }
+
+
+void
+hb_ot_shape_glyphs_closure (hb_font_t  *font,
+   hb_buffer_t*buffer,
+   const hb_feature_t *features,
+   unsigned intnum_features,
+   hb_set_t   *glyphs)
+{
+  hb_ot_shape_plan_t plan;
+
+  buffer-guess_properties ();
+
+  hb_ot_shape_plan_internal (plan, 

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

2012-04-24 Thread Behdad Esfahbod
On 04/17/2012 10:35 PM, John Daggett wrote:
 Just a note here that this will be problematic when rendering upright
 Latin text in vertical mode.  Frankly, I don't think there's a clear,
 consistent design model for OpenType features in the vertical case.
 There's clearly a need to distinguish more clearly vertical ligatures
 from horizontal ones, having 'f' and 'i' ligate in the upright
 vertical case doesn't make sense.  Kazuraki relies on the 'vert'
 feature to disambiguate horizontal and vertical ligatures but this
 won't work for fonts not designed with the vertical case in mind.

Nod.  That's exactly why I didn't have 'liga' for vertical before...

behdad


 So I think this change will need tweaking in the future, once there's
 a clearer definition of the OpenType feature model for vertical text.
 
 Cheers,
 
 John Daggett
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2012-04-17 Thread John Daggett
 commit a5f1834f57ea3fb254f5c7d372747de316fcc8f1
 Author: Behdad Esfahbod beh...@behdad.org
 Date:   Mon Apr 16 15:55:13 2012 -0400
 
 Apply 'liga' for vertical writing mode too
 
 Apparently that's what Kazuraki uses to form vertical ligatures,
 which suggests that it's what Adobe does.
 
 diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
 index d21559c..66b1461 100644
 --- a/src/hb-ot-shape.cc
 +++ b/src/hb-ot-shape.cc
 @@ -35,6 +35,7 @@
  
  hb_tag_t common_features[] = {
HB_TAG('c','c','m','p'),
 +  HB_TAG('l','i','g','a'),
HB_TAG('l','o','c','l'),
HB_TAG('m','a','r','k'),
HB_TAG('m','k','m','k'),
 @@ -46,7 +47,6 @@ hb_tag_t horizontal_features[] = {
HB_TAG('c','l','i','g'),
HB_TAG('c','u','r','s'),
HB_TAG('k','e','r','n'),
 -  HB_TAG('l','i','g','a'),
  };

Just a note here that this will be problematic when rendering upright
Latin text in vertical mode.  Frankly, I don't think there's a clear,
consistent design model for OpenType features in the vertical case.
There's clearly a need to distinguish more clearly vertical ligatures
from horizontal ones, having 'f' and 'i' ligate in the upright
vertical case doesn't make sense.  Kazuraki relies on the 'vert'
feature to disambiguate horizontal and vertical ligatures but this
won't work for fonts not designed with the vertical case in mind.

So I think this change will need tweaking in the future, once there's
a clearer definition of the OpenType feature model for vertical text.

Cheers,

John Daggett
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2011-08-16 Thread Behdad Esfahbod
 configure.ac  |2 +-
 src/hb-buffer.cc  |1 +
 src/hb-ft.cc  |   23 ---
 src/hb-ot-shape-complex-arabic.cc |1 +
 util/common.hh|4 +++-
 util/options.cc   |8 
 util/options.hh   |4 ++--
 7 files changed, 28 insertions(+), 15 deletions(-)

New commits:
commit 0b7e4d9f20b3ed947d0c441ca59b43c4097cdb0e
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Aug 15 20:41:59 2011 +0200

[ft] FT_Get_Advance() for advance-width callbacks

Using graphite2's comparerenderer suggests that this makes hb-ft 15
times faster.  No caching layer needed anymore.

diff --git a/configure.ac b/configure.ac
index 6cd1018..f42fb3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,7 @@ AM_CONDITIONAL(HAVE_ICU, $have_icu)
 
 dnl ==
 
-PKG_CHECK_MODULES(FREETYPE, freetype2, have_freetype=true, have_freetype=false)
+PKG_CHECK_MODULES(FREETYPE, freetype2 = 2.3.8, have_freetype=true, 
have_freetype=false)
 if $have_freetype; then
AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library])
_save_libs=$LIBS
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 25368f1..23c2cc0 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -31,6 +31,7 @@
 
 #include hb-font-private.hh
 
+#include FT_ADVANCES_H
 #include FT_TRUETYPE_TABLES_H
 
 
@@ -47,9 +48,13 @@
  *
  *   - We don't handle any load_flags.  That definitely has API implications. 
:(
  * I believe hb_ft_font_create() should take load_flags input.
+ * In particular, FT_Get_Advance() without the NO_HINTING flag seems to be
+ * buggy.
  *
  *   - We don't handle / allow for emboldening / obliqueing.
  *
+ *   - Rounding, etc?
+ *
  *   - In the future, we should add constructors to create fonts in font space.
  *
  *   - I believe transforms are not correctly implemented.  FreeType does not
@@ -89,12 +94,13 @@ hb_ft_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
   void *user_data HB_UNUSED)
 {
   FT_Face ft_face = (FT_Face) font_data;
-  int load_flags = FT_LOAD_DEFAULT;
+  int load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
+  FT_Fixed v;
 
-  if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
+  if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, v)))
 return 0;
 
-  return ft_face-glyph-metrics.horiAdvance;
+  return v  10;
 }
 
 static hb_position_t
@@ -104,14 +110,15 @@ hb_ft_get_glyph_v_advance (hb_font_t *font HB_UNUSED,
   void *user_data HB_UNUSED)
 {
   FT_Face ft_face = (FT_Face) font_data;
-  int load_flags = FT_LOAD_DEFAULT;
+  int load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING | 
FT_LOAD_VERTICAL_LAYOUT;
+  FT_Fixed v;
 
-  if (unlikely (FT_Load_Glyph (ft_face, glyph, load_flags)))
+  if (unlikely (FT_Get_Advance (ft_face, glyph, load_flags, v)))
 return 0;
 
   /* Note: FreeType's vertical metrics grows downward while other FreeType 
coordinates
* have a Y growing upward.  Hence the extra negation. */
-  return -ft_face-glyph-metrics.vertAdvance;
+  return -v  10;
 }
 
 static hb_bool_t
diff --git a/util/common.hh b/util/common.hh
index 5c8baab..58dec6f 100644
--- a/util/common.hh
+++ b/util/common.hh
@@ -44,6 +44,8 @@
 #include glib.h
 #include glib/gprintf.h
 
-void fail (const char *format, ...);
+
+void fail (const char *format, ...) G_GNUC_NORETURN;
+
 
 #endif
commit 97796453aab56873809a15b5e316cba8acea7449
Author: Behdad Esfahbod beh...@behdad.org
Date:   Mon Aug 15 19:03:43 2011 +0200

Fix falloffs of the GOption conversion

diff --git a/util/options.cc b/util/options.cc
index 2bc2c70..d623243 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -31,6 +31,8 @@ view_options_t view_opts[1];
 shape_options_t shape_opts[1];
 font_options_t font_opts[1];
 
+const char *out_file = /dev/stdout;
+hb_bool_t debug = FALSE;
 
 
 static gboolean
@@ -40,7 +42,7 @@ parse_margin (const char *name G_GNUC_UNUSED,
  GError**error G_GNUC_UNUSED)
 {
   view_options_t::margin_t m = view_opts-margin;
-  switch (sscanf (arg, %f %f %f %f, m.t, m.r, m.b, m.l)) {
+  switch (sscanf (arg, %lf %lf %lf %lf, m.t, m.r, m.b, m.l)) {
 case 1: m.r = m.t;
 case 2: m.b = m.t;
 case 3: m.l = m.r;
@@ -268,7 +270,7 @@ parse_options (int argc, char *argv[])
   GOptionEntry entries[] =
   {
 {version,0, G_OPTION_FLAG_NO_ARG,
-  G_OPTION_ARG_CALLBACK,   (gpointer) 
show_version,   Show version numbers, NULL},
+ G_OPTION_ARG_CALLBACK,(gpointer) 
show_version,   Show version numbers, NULL},
 {debug,  0, 0, G_OPTION_ARG_NONE,debug, 
Free all resources before exit,   NULL},
 {output, 0, 0, G_OPTION_ARG_STRING,  out_file,  
Set output 

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

2011-07-30 Thread Behdad Esfahbod
 src/Makefile.am  |2 
 src/hb-ot-shape-complex-arabic.cc|6 
 src/hb-ot-shape-complex-indic-machine.rl |   35 ++--
 src/hb-ot-shape-complex-indic.cc |  238 ---
 src/hb-ot-shape-normalize.cc |   26 +--
 src/hb-private.hh|   38 
 test/test-shape-complex.c|   10 -
 7 files changed, 293 insertions(+), 62 deletions(-)

New commits:
commit 45d6f29f15f1d2323bcaa2498aed23ff0c8a1567
Author: Behdad Esfahbod beh...@behdad.org
Date:   Sat Jul 30 14:44:30 2011 -0400

[Indic] Reorder matras

Number of failing shape-complex tests goes from 125 down to 94.

Next: Add Ra handling and it's fair to say we kinda support Indic :).

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 0579500..95f3f1f 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -63,8 +63,6 @@ enum indic_position_t {
   POS_ABOVE,
   POS_BELOW,
   POS_POST,
-
-  POS_INHERIT /* For Halant, Nukta, ZWJ, ZWNJ */
 };
 
 /* Categories used in IndicSyllabicCategory.txt from UCD */
@@ -365,6 +363,14 @@ _hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, 
hb_buffer_t *buffer)
   }
 }
 
+static int
+compare_indic_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
+{
+  int a = pa-indic_position();
+  int b = pb-indic_position();
+
+  return a  b ? -1 : a == b ? 0 : +1;
+}
 
 static void
 found_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, 
hb_mask_t *mask_array,
@@ -454,6 +460,25 @@ found_consonant_syllable (const hb_ot_map_t *map, 
hb_buffer_t *buffer, hb_mask_t
*/
 
 
+  /* Reorder characters */
+
+  for (i = start; i  base; i++)
+buffer-info[i].indic_position() = POS_PRE;
+  buffer-info[base].indic_position() = POS_BASE;
+
+  /* Attach ZWJ, ZWNJ, nukta, and halant to previous char to move with them. */
+  for (i = start + 1; i  end; i++)
+if ((FLAG (buffer-info[i].indic_category()) 
+(FLAG (OT_ZWNJ) | FLAG (OT_ZWJ) | FLAG (OT_N) | FLAG (OT_H
+  buffer-info[i].indic_position() = buffer-info[i - 1].indic_position();
+
+  /* We do bubble-sort, skip malicious clusters attempts */
+  if (end - start  20)
+return;
+
+  /* Sit tight, rock 'n roll! */
+  hb_bubble_sort (buffer-info + start, end - start, compare_indic_order);
+
   /* Setup masks now */
 
   /* Pre-base */
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 8ed7a67..e2fd91c 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -147,6 +147,15 @@ decompose_multi_char_cluster (hb_ot_shape_context_t *c,
 decompose_current_glyph (c, FALSE);
 }
 
+static int
+compare_combining_class (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
+{
+  unsigned int a = pa-combining_class();
+  unsigned int b = pb-combining_class();
+
+  return a  b ? -1 : a == b ? 0 : +1;
+}
+
 void
 _hb_ot_shape_normalize (hb_ot_shape_context_t *c)
 {
@@ -216,22 +225,7 @@ _hb_ot_shape_normalize (hb_ot_shape_context_t *c)
   continue;
 }
 
-unsigned int k = end - i - 1;
-do {
-  hb_glyph_info_t *pinfo = buffer-info + i;
-  unsigned int new_k = 0;
-
-  for (unsigned int j = 0; j  k; j++)
-   if (pinfo[j].combining_class()  pinfo[j+1].combining_class()) {
- hb_glyph_info_t t;
- t = pinfo[j];
- pinfo[j] = pinfo[j + 1];
- pinfo[j + 1] = t;
-
- new_k = j;
-   }
-  k = new_k;
-} while (k);
+hb_bubble_sort (buffer-info + i, end - i, compare_combining_class);
 
 i = end;
   }
diff --git a/src/hb-private.hh b/src/hb-private.hh
index b5277a5..23fc0af 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -568,12 +568,9 @@ struct hb_auto_trace_t0 {
   const char *message) {}
 };
 
-HB_BEGIN_DECLS
-
 
 /* Misc */
 
-HB_END_DECLS
 
 /* Pre-mature optimization:
  * Checks for lo = u = hi but with an optimization if lo and hi
@@ -590,13 +587,40 @@ hb_in_range (T u, T lo, T hi)
 return lo = u  u = hi;
 }
 
-HB_BEGIN_DECLS
-
 
-/* Useful for set-operations on small enums */
+/* Useful for set-operations on small enums.
+ * For example, for testing x ∈ {x1, x2, x3} use:
+ * (FLAG(x)  (FLAG(x1) | FLAG(x2) | FLAG(x3)))
+ */
 #define FLAG(x) (1(x))
 
 
+template typename T inline void
+hb_bubble_sort (T *array, unsigned int len, int(*compar)(const T *, const T *))
+{
+  if (unlikely (!len))
+return;
+
+  unsigned int k = len - 1;
+  do {
+unsigned int new_k = 0;
+
+for (unsigned int j = 0; j  k; j++)
+  if (compar (array[j], array[j+1])  0) {
+T t;
+   t = array[j];
+   array[j] = array[j + 1];
+   array[j + 1] = t;
+
+   new_k = j;
+  }
+k = new_k;
+  } while (k);
+}
+
+
+HB_BEGIN_DECLS
+
 HB_END_DECLS
 
 #endif /* HB_PRIVATE_HH */
commit 911bf32acad7f1cd161f666cb659990ade0925ad
Author: Behdad Esfahbod beh...@behdad.org
Date:   Sat Jul 30 

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

2011-07-21 Thread Behdad Esfahbod
 src/Makefile.am  |1 
 src/hb-buffer-private.hh |   10 ++
 src/hb-buffer.cc |   19 +--
 src/hb-ot-shape-normalize.cc |   71 +++
 src/hb-ot-shape-private.hh   |   12 +++
 src/hb-ot-shape.cc   |   18 +++---
 test/test-unicode.c  |2 -
 7 files changed, 117 insertions(+), 16 deletions(-)

New commits:
commit ad903e66b1cc4ec1b8160f93b3ab2b5e636f8d62
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 21 10:17:22 2011 -0400

s/COMBINING_MARK/SPACING_MARK/ here too.  Oops!

diff --git a/test/test-unicode.c b/test/test-unicode.c
index dd57984..c614c7d 100644
--- a/test/test-unicode.c
+++ b/test/test-unicode.c
@@ -234,7 +234,7 @@ static const test_pair_t general_category_tests[] =
   {   0x3400, HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER },
   {   0x01C5, HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER },
   {   0xFF21, HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER },
-  {   0x0903, HB_UNICODE_GENERAL_CATEGORY_COMBINING_MARK },
+  {   0x0903, HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK },
   {   0x20DD, HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK },
   {   0xA806, HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK },
   {   0xFF10, HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER },
commit cf7f43ec3382cac2af11f5637c840500daabf889
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 21 01:12:26 2011 -0400

Remove stale comment

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index b9754ce..50f2986 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -371,7 +371,6 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c)
 
   /* SUBSTITUTE */
   {
-/* Mirroring needs to see the original direction */
 hb_mirror_chars (c);
 
 hb_substitute_default (c);
commit 54d1a0d2b2c4ffe15494967122c6422ecb1fc80b
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 21 01:11:09 2011 -0400

Form clusters before ensuring native direciton

This is essential as ensure_native_direction uses cluster info that
is set by form_clusters().

diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 33123d4..b9754ce 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -361,10 +361,10 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c)
 
   hb_set_unicode_props (c); /* BUFFER: Set general_category and 
combining_class in var1 */
 
-  hb_ensure_native_direction (c);
-
   hb_form_clusters (c);
 
+  hb_ensure_native_direction (c);
+
   _hb_normalize (c);
 
   hb_ot_shape_setup_masks (c); /* BUFFER: Clobbers var2 */
commit 9111b21ef99d5e53348176f683261b0101eb427f
Author: Behdad Esfahbod beh...@behdad.org
Date:   Thu Jul 21 00:58:29 2011 -0400

Add _hb_buffer_output_glyph() and _hb_buffer_skip_glyph()

diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 4fae884..73535d4 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -66,6 +66,13 @@ _hb_buffer_replace_glyph (hb_buffer_t *buffer,
  hb_codepoint_t glyph_index);
 
 HB_INTERNAL void
+_hb_buffer_output_glyph (hb_buffer_t *buffer,
+hb_codepoint_t glyph_index);
+
+HB_INTERNAL void
+_hb_buffer_skip_glyph (hb_buffer_t *buffer);
+
+HB_INTERNAL void
 _hb_buffer_next_glyph (hb_buffer_t *buffer);
 
 
@@ -125,6 +132,9 @@ struct _hb_buffer_t {
   { _hb_buffer_replace_glyphs_be16 (this, num_in, num_out, glyph_data_be); }
   inline void replace_glyph (hb_codepoint_t glyph_index)
   { _hb_buffer_replace_glyph (this, glyph_index); }
+  inline void output_glyph (hb_codepoint_t glyph_index)
+  { _hb_buffer_output_glyph (this, glyph_index); }
+  inline void skip_glyph (void) { _hb_buffer_skip_glyph (this); }
 
   inline void reset_masks (hb_mask_t mask)
   {
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index b65ddbb..174d8e8 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -404,8 +404,8 @@ _hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer,
 }
 
 void
-_hb_buffer_replace_glyph (hb_buffer_t *buffer,
- hb_codepoint_t glyph_index)
+_hb_buffer_output_glyph (hb_buffer_t *buffer,
+hb_codepoint_t glyph_index)
 {
   hb_glyph_info_t *info;
 
@@ -420,11 +420,24 @@ _hb_buffer_replace_glyph (hb_buffer_t *buffer,
   info = buffer-out_info[buffer-out_len];
   info-codepoint = glyph_index;
 
-  buffer-i++;
   buffer-out_len++;
 }
 
 void
+_hb_buffer_replace_glyph (hb_buffer_t *buffer,
+ hb_codepoint_t glyph_index)
+{
+  _hb_buffer_output_glyph (buffer, glyph_index);
+  _hb_buffer_skip_glyph (buffer);
+}
+
+void
+_hb_buffer_skip_glyph (hb_buffer_t *buffer)
+{
+  buffer-i++;
+}
+
+void
 _hb_buffer_next_glyph (hb_buffer_t *buffer)
 {
   if (buffer-have_output)
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 306beb3..33123d4 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -264,7 +264,7 @@ hb_map_glyphs (hb_font_t*font,
 if (unlikely (is_variation_selector 

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

2011-05-11 Thread Behdad Esfahbod
 TODO|4 +-
 src/Makefile.am |3 +
 src/hb-blob.cc  |2 -
 src/hb-open-type-private.hh |8 ++---
 src/hb-ot-head-private.hh   |1 
 src/hb-ot-layout.cc |1 
 src/hb-ot-map-private.hh|7 
 src/hb-ot-maxp-private.hh   |   68 
 src/hb-ot-shape-private.hh  |2 +
 src/hb-ot-shape.cc  |2 +
 src/hb-private.hh   |   10 +-
 src/hb-unicode.cc   |6 ---
 test/test-unicode.c |6 +++
 13 files changed, 105 insertions(+), 15 deletions(-)

New commits:
commit 4101ca7dbbdf1438fa116fb8cad935501ac7cca8
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed May 11 14:30:56 2011 -0400

Plug more leaks

All good now.

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index cdb7496..17ff339 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -126,7 +126,7 @@ hb_blob_create_sub_blob (hb_blob_t*parent,
 {
   hb_blob_t *blob;
 
-  if (!length || offset = parent-length || !(blob = 
hb_object_createhb_blob_t ()))
+  if (!length || offset = parent-length)
 return _hb_blob_nil;
 
   hb_blob_make_immutable (parent);
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index e16eddd..4aa47ec 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -191,8 +191,8 @@ struct hb_sanitize_context_t
 
   inline void setup (void)
   {
-this-start = hb_blob_get_data (blob, NULL);
-this-end = this-start + hb_blob_get_length (blob);
+this-start = hb_blob_get_data (this-blob, NULL);
+this-end = this-start + hb_blob_get_length (this-blob);
 this-edit_count = 0;
 this-debug_depth = 0;
 
@@ -321,10 +321,8 @@ struct Sanitizer
  sane = false;
}
   }
-  c-finish ();
 } else {
   unsigned int edit_count = c-edit_count;
-  c-finish ();
   if (edit_count  !c-writable) {
 c-start = hb_blob_get_data_writable (blob, NULL);
c-end = c-start + hb_blob_get_length (blob);
@@ -339,6 +337,8 @@ struct Sanitizer
   }
 }
 
+c-finish ();
+
 (void) (HB_DEBUG_SANITIZE 
   fprintf (stderr, Sanitizer %p %s %s\n, blob, sane ? passed : 
FAILED, HB_FUNC));
 if (sane)
commit 6a7ac79e26e85f6781186cf708a12825c0857324
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed May 11 14:19:18 2011 -0400

Plug leaks

diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh
index 2a74138..02f5a91 100644
--- a/src/hb-ot-map-private.hh
+++ b/src/hb-ot-map-private.hh
@@ -120,6 +120,13 @@ struct hb_ot_map_t {
   hb_ot_layout_position_lookup (font, buffer, lookup_maps[1][i].index, 
lookup_maps[1][i].mask);
   }
 
+  inline void finish (void) {
+feature_infos.finish ();
+feature_maps.finish ();
+lookup_maps[0].finish ();
+lookup_maps[1].finish ();
+  }
+
   private:
 
   hb_mask_t global_mask;
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index c0faf8c..b95815a 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -51,6 +51,8 @@ struct hb_ot_shape_plan_t
 {
   hb_ot_map_t map;
   hb_ot_complex_shaper_t shaper;
+
+  inline void finish (void) { map.finish (); }
 };
 
 
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 4f90027..aa5b920 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -381,6 +381,8 @@ hb_ot_shape (hb_font_t  *font,
 
   hb_ot_shape_plan_internal (plan, font-face, buffer-props, features, 
num_features);
   hb_ot_shape_execute (plan, font, buffer, features, num_features);
+
+  plan.finish ();
 }
 
 
diff --git a/src/hb-private.hh b/src/hb-private.hh
index f22e0d2..215ef96 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -313,6 +313,14 @@ struct hb_prealloced_array_t {
   {
 return (const Type *) ::bsearch (key, array, len, sizeof (Type), 
(hb_compare_func_t) Type::cmp);
   }
+
+  inline void finish (void)
+  {
+if (array != static_array)
+  free (array);
+array = NULL;
+allocated = len = 0;
+  }
 };
 
 template typename Type
@@ -394,7 +402,7 @@ struct hb_lockable_set_t
old.finish ();
l.lock ();
 }
-items.shrink (0);
+items.finish ();
 l.unlock ();
   }
 
commit 7aa12ebdff11a4ffbd04bf9b164586eb0c172e37
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed May 11 11:55:11 2011 -0400

[unicode] Simplify method setting

diff --git a/src/hb-unicode.cc b/src/hb-unicode.cc
index 62cbcdc..943d7a7 100644
--- a/src/hb-unicode.cc
+++ b/src/hb-unicode.cc
@@ -206,14 +206,10 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t
 *ufuncs,\
 ufuncs-get.name = func;   
\
 ufuncs-user_data.name = user_data;
\
 ufuncs-destroy.name = destroy;
\
-  } else if (ufuncs-parent != NULL) { 
\
+  } else {

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

2011-05-02 Thread Behdad Esfahbod
 src/hb-blob.cc   |   13 -
 src/hb-common.cc |   54 +++
 src/hb-font-private.hh   |2 +
 src/hb-font.cc   |   48 --
 src/hb-font.h|   26 ++
 src/hb-ft.cc |7 -
 src/hb-ot-layout-gdef-private.hh |2 -
 src/hb-ot-layout-gpos-private.hh |2 -
 src/hb-ot-layout.cc  |   10 ++-
 src/hb-ot-layout.h   |2 -
 src/hb-ot-map-private.hh |2 -
 src/hb-ot-shape.cc   |   23 +++-
 src/hb-ot-shape.h|1 
 src/hb-private.hh|   48 +-
 src/hb-shape.cc  |   18 +
 src/hb-shape.h   |1 
 src/hb-view.cc   |4 --
 test/test-object.c   |7 +++--
 18 files changed, 168 insertions(+), 102 deletions(-)

New commits:
commit d4141a44b97377a65e6d2a3e03b3709307af38c1
Author: Behdad Esfahbod beh...@behdad.org
Date:   Tue May 3 00:19:18 2011 -0400

[blob] Implement sub_blob() in terms of create()

Fixes problem with uninitialized sub_blob-mutex among other things.

Reported by Bradley Grainger.

diff --git a/src/hb-blob.cc b/src/hb-blob.cc
index bcbfa34..8d6d746 100644
--- a/src/hb-blob.cc
+++ b/src/hb-blob.cc
@@ -127,16 +127,14 @@ hb_blob_create_sub_blob (hb_blob_t*parent,
 
   pdata = hb_blob_lock (parent);
 
-  blob-data = pdata + offset;
-  blob-length = MIN (length, parent-length - offset);
-
   hb_mutex_lock (parent-lock);
-  blob-mode = parent-mode;
+  blob = hb_blob_create (pdata + offset,
+MIN (length, parent-length - offset),
+parent-mode,
+hb_blob_reference (parent),
+(hb_destroy_func_t) _hb_blob_unlock_and_destroy);
   hb_mutex_unlock (parent-lock);
 
-  blob-user_data = hb_blob_reference (parent);
-  blob-destroy = (hb_destroy_func_t) _hb_blob_unlock_and_destroy;
-
   return blob;
 }
 
commit fc52e9e44c2fe84d63f18dc0098720830f0b467d
Author: Behdad Esfahbod beh...@behdad.org
Date:   Tue May 3 00:09:16 2011 -0400

Implement win32 thread-safety stuff

Patch from Bradley Grainger.

diff --git a/src/hb-common.cc b/src/hb-common.cc
index b75146d..2f5e89b 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -263,4 +263,58 @@ hb_script_get_horizontal_direction (hb_script_t script)
 }
 
 
+
+/* System stuff */
+
+
+#ifdef _MSC_VER
+
+#include Windows.h
+
+hb_mutex_t
+_hb_win32_mutex_create ()
+{
+  hb_mutex_t m;
+  _hb_win32_mutex_init (m);
+  return m;
+}
+
+void
+_hb_win32_mutex_init (hb_mutex_t *m)
+{
+  LPCRITICAL_SECTION lpcs = (LPCRITICAL_SECTION) calloc(1, 
sizeof(CRITICAL_SECTION));
+  InitializeCriticalSection (lpcs);
+  *m = (void*) lpcs;
+}
+
+void
+_hb_win32_mutex_lock (hb_mutex_t m)
+{
+  EnterCriticalSection ((LPCRITICAL_SECTION) m);
+}
+
+int
+_hb_win32_mutex_trylock (hb_mutex_t m)
+{
+  return TryEnterCriticalSection ((LPCRITICAL_SECTION) m);
+}
+
+void
+_hb_win32_mutex_unlock (hb_mutex_t m)
+{
+  LeaveCriticalSection ((LPCRITICAL_SECTION) m);
+}
+
+void
+_hb_win32_mutex_free (hb_mutex_t *m)
+{
+  LPCRITICAL_SECTION lpcs = (LPCRITICAL_SECTION) *m;
+  DeleteCriticalSection (lpcs);
+  free(lpcs);
+  *m = 0;
+}
+
+#endif
+
+
 HB_END_DECLS
diff --git a/src/hb-private.hh b/src/hb-private.hh
index a45fece..cac434a 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -243,13 +243,31 @@ typedef GStaticMutex hb_mutex_t;
 #else
 
 #ifdef _MSC_VER
-#define _HB__STR2__(x) #x
-#define _HB__STR1__(x) _HB__STR2__(x)
-#define _HB__LOC__ __FILE__ (_HB__STR1__(__LINE__)) : Warning Msg: 
-#pragma message(_HB__LOC__Could not find any system to define platform 
macros, library will NOT be thread-safe)
+
+#include intrin.h
+
+typedef long hb_atomic_int_t;
+#define hb_atomic_int_fetch_and_add(AI, V) _InterlockedExchangeAdd ((AI), 
V)
+#define hb_atomic_int_get(AI)  (_ReadBarrier (), (AI))
+#define hb_atomic_int_set(AI, V)   ((void) _InterlockedExchange 
((AI), (V)))
+
+typedef void * hb_mutex_t;
+extern HB_INTERNAL hb_mutex_t _hb_win32_mutex_create (void);
+extern HB_INTERNAL void _hb_win32_mutex_init (hb_mutex_t *m);
+extern HB_INTERNAL void _hb_win32_mutex_lock (hb_mutex_t m);
+extern HB_INTERNAL int _hb_win32_mutex_trylock (hb_mutex_t m);
+extern HB_INTERNAL void _hb_win32_mutex_unlock (hb_mutex_t m);
+extern HB_INTERNAL void _hb_win32_mutex_free (hb_mutex_t *m);
+#define HB_MUTEX_INIT  _hb_win32_mutex_create ()
+#define hb_mutex_init(M)   _hb_win32_mutex_init ((M))
+#define hb_mutex_lock(M)   _hb_win32_mutex_lock ((M))
+#define hb_mutex_trylock(M)_hb_win32_mutex_trylock ((M))
+#define hb_mutex_unlock(M) _hb_win32_mutex_unlock ((M))
+#define hb_mutex_free(M)   

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

2010-11-17 Thread Behdad Esfahbod
 TODO |5 +
 src/hb-icu.c |8 +++-
 src/hb-ot-layout-gsubgpos-private.hh |4 +++-
 src/hb-ot-tag.c  |   33 +++--
 src/hb-unicode.c |7 ++-
 src/hb-unicode.h |9 +++--
 6 files changed, 47 insertions(+), 19 deletions(-)

New commits:
commit 43bf2f7f1ec427c431e2ee2fd1a9345e7d5c9718
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Nov 17 14:49:40 2010 -0500

Add OpenType script tags for Unicode 5.2 and Unicode 6.0 scripts

Based on tags proposed by Microsoft for inclusion in OpenType.

diff --git a/src/hb-ot-tag.c b/src/hb-ot-tag.c
index 8c23ce9..f3e0f1f 100644
--- a/src/hb-ot-tag.c
+++ b/src/hb-ot-tag.c
@@ -125,26 +125,26 @@ static const hb_tag_t ot_scripts[][3] = {
   {HB_TAG('l','y','d','i')},   /* HB_SCRIPT_LYDIAN */
 
   /* Unicode-5.2 additions */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_AVESTAN */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_BAMUM */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_EGYPTIAN_HIEROGLYPHS */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_IMPERIAL_ARAMAIC */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_INSCRIPTIONAL_PAHLAVI */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_INSCRIPTIONAL_PARTHIAN */
+  {HB_TAG('a','v','s','t')},   /* HB_SCRIPT_AVESTAN */
+  {HB_TAG('b','a','m','u')},   /* HB_SCRIPT_BAMUM */
+  {HB_TAG('e','g','y','p')},   /* HB_SCRIPT_EGYPTIAN_HIEROGLYPHS */
+  {HB_TAG('a','r','m','i')},   /* HB_SCRIPT_IMPERIAL_ARAMAIC */
+  {HB_TAG('p','h','l','i')},   /* HB_SCRIPT_INSCRIPTIONAL_PAHLAVI */
+  {HB_TAG('p','r','t','i')},   /* HB_SCRIPT_INSCRIPTIONAL_PARTHIAN */
   {HB_TAG('j','a','v','a')},   /* HB_SCRIPT_JAVANESE */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_KAITHI */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_LISU */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_MEETEI_MAYEK */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_OLD_SOUTH_ARABIAN */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_OLD_TURKIC */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_SAMARITAN */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_TAI_THAM */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_TAI_VIET */
+  {HB_TAG('k','t','h','i')},   /* HB_SCRIPT_KAITHI */
+  {HB_TAG('l','i','s','u')},   /* HB_SCRIPT_LISU */
+  {HB_TAG('m','y','e','i')},   /* HB_SCRIPT_MEETEI_MAYEK */
+  {HB_TAG('s','a','r','b')},   /* HB_SCRIPT_OLD_SOUTH_ARABIAN */
+  {HB_TAG('o','r','k','h')},   /* HB_SCRIPT_OLD_TURKIC */
+  {HB_TAG('s','a','m','r')},   /* HB_SCRIPT_SAMARITAN */
+  {HB_TAG('l','a','n','a')},   /* HB_SCRIPT_TAI_THAM */
+  {HB_TAG('t','a','v','t')},   /* HB_SCRIPT_TAI_VIET */
 
   /* Unicode-6.0 additions */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_BATAK */
-  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_BRAHMI */
-  {HB_TAG('D','F','L','T')}/* HB_SCRIPT_MANDAIC */
+  {HB_TAG('b','a','t','k')},   /* HB_SCRIPT_BATAK */
+  {HB_TAG('b','r','a','h')},   /* HB_SCRIPT_BRAHMI */
+  {HB_TAG('m','a','n','d')}/* HB_SCRIPT_MANDAIC */
 };
 
 const hb_tag_t *
commit afab01cf7caca79cf6dfabe6827d1703be1a74f7
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Nov 17 14:35:34 2010 -0500

Add Unicode 6.0 scripts

diff --git a/src/hb-icu.c b/src/hb-icu.c
index 97b2fa0..44709b1 100644
--- a/src/hb-icu.c
+++ b/src/hb-icu.c
@@ -228,6 +228,12 @@ hb_icu_get_script (hb_codepoint_t unicode)
   MATCH_SCRIPT2(ORKHON, OLD_TURKIC); /* Orkh */
   MATCH_SCRIPT (SAMARITAN);  /* Samr */
   MATCH_SCRIPT (TAI_VIET);   /* Tavt */
+
+  /* Unicode-6.0 additions */
+  MATCH_SCRIPT (BATAK);  /* Batk */
+  MATCH_SCRIPT (BRAHMI); /* Brah */
+  MATCH_SCRIPT2(MANDAEAN, MANDAIC);  /* Mand */
+
   }
   return HB_SCRIPT_UNKNOWN;
 }
diff --git a/src/hb-ot-tag.c b/src/hb-ot-tag.c
index d774c4f..8c23ce9 100644
--- a/src/hb-ot-tag.c
+++ b/src/hb-ot-tag.c
@@ -139,7 +139,12 @@ static const hb_tag_t ot_scripts[][3] = {
   {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_OLD_TURKIC */
   {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_SAMARITAN */
   {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_TAI_THAM */
-  {HB_TAG('D','F','L','T')}/* HB_SCRIPT_TAI_VIET */
+  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_TAI_VIET */
+
+  /* Unicode-6.0 additions */
+  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_BATAK */
+  {HB_TAG('D','F','L','T')},   /* HB_SCRIPT_BRAHMI */
+  {HB_TAG('D','F','L','T')}/* HB_SCRIPT_MANDAIC */
 };
 
 const hb_tag_t *
diff --git a/src/hb-unicode.c b/src/hb-unicode.c
index 280c61f..2ab308b 100644
--- a/src/hb-unicode.c
+++ b/src/hb-unicode.c
@@ -341,7 +341,12 @@ const hb_direction_t horiz_dir[] =
   RTL, /* Orkh */
   RTL, /* Samr */
   LTR, /* Lana */
-  LTR  /* Tavt */
+  LTR, /* Tavt */
+
+  /* Unicode-6.0 additions */
+  LTR, /* Batk */
+  LTR, /* Brah */
+  RTL  /* Mand */
 };
 #undef LTR
 #undef RTL
diff --git a/src/hb-unicode.h b/src/hb-unicode.h
index 9fedd27..5fd6dff 100644
--- 

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

2010-10-27 Thread Behdad Esfahbod
 src/hb-ot-layout-common-private.hh   |2 -
 src/hb-ot-layout-gdef-private.hh |   34 +++--
 src/hb-ot-layout-gpos-private.hh |   31 ++-
 src/hb-ot-layout-gsubgpos-private.hh |6 ---
 src/hb-ot-layout.cc  |   55 +--
 src/hb-ot-layout.h   |   13 
 6 files changed, 80 insertions(+), 61 deletions(-)

New commits:
commit 13528d0c78cadb1f67267c9a692558caef9fdaa6
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Oct 27 14:09:27 2010 -0400

Supposedly implement vertical support in GPOS

Not tested at all.

diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh
index 6be604e..187dc98 100644
--- a/src/hb-ot-layout-gpos-private.hh
+++ b/src/hb-ot-layout-gpos-private.hh
@@ -855,27 +855,40 @@ struct CursivePosFormat1
 (this+this_record.exitAnchor).get_anchor (c-layout, 
c-buffer-info[i].codepoint, exit_x, exit_y);
 (this+next_record.entryAnchor).get_anchor (c-layout, 
c-buffer-info[j].codepoint, entry_x, entry_y);
 
-/* TODO vertical */
+hb_direction_t direction = c-buffer-props.direction;
 
-/* Align the exit anchor of the left glyph with the entry anchor of the 
right glyph. */
-if (c-buffer-props.direction == HB_DIRECTION_RTL)
+/* Align the exit anchor of the left/top glyph with the entry anchor of 
the right/bottom glyph
+ * by adjusting advance of the left/top glyph. */
+if (HB_DIRECTION_IS_BACKWARD (direction))
 {
-  c-buffer-pos[j].x_advance = c-buffer-pos[j].x_offset + entry_x - 
exit_x;
+  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+   c-buffer-pos[j].x_advance = c-buffer-pos[j].x_offset + entry_x - 
exit_x;
+  else
+   c-buffer-pos[j].y_advance = c-buffer-pos[j].y_offset + entry_y - 
exit_y;
 }
 else
 {
-  c-buffer-pos[i].x_advance = c-buffer-pos[i].x_offset + exit_x - 
entry_x;
+  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+   c-buffer-pos[i].x_advance = c-buffer-pos[i].x_offset + exit_x - 
entry_x;
+  else
+   c-buffer-pos[i].y_advance = c-buffer-pos[i].y_offset + exit_y - 
entry_y;
 }
 
 if  (c-lookup_flag  LookupFlag::RightToLeft)
 {
   c-buffer-pos[i].cursive_chain = j - i;
-  c-buffer-pos[i].y_offset = entry_y - exit_y;
+  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+   c-buffer-pos[i].y_offset = entry_y - exit_y;
+  else
+   c-buffer-pos[i].x_offset = entry_x - exit_x;
 }
 else
 {
   c-buffer-pos[j].cursive_chain = i - j;
-  c-buffer-pos[j].y_offset = exit_y - entry_y;
+  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+   c-buffer-pos[j].y_offset = exit_y - entry_y;
+  else
+   c-buffer-pos[j].x_offset = exit_x - entry_x;
 }
 
 c-buffer-i = j;
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 75fa203..f85bf86 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -607,25 +607,34 @@ hb_ot_layout_position_finish (hb_font_t*font 
HB_UNUSED,
   unsigned int i, j;
   unsigned int len = hb_buffer_get_length (buffer);
   hb_internal_glyph_position_t *pos = (hb_internal_glyph_position_t *) 
hb_buffer_get_glyph_positions (buffer);
+  hb_direction_t direction = buffer-props.direction;
 
   /* TODO: Vertical */
 
-  /* Handle cursive connections */
-  /* First handle all chain-back connections */
-  for (j = 0; j  len; j++) {
-if (pos[j].cursive_chain  0)
-{
-  pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
-  pos[j].cursive_chain = 0;
+  /* Handle cursive connections:
+   * First handle all chain-back connections, then handle all chain-forward 
connections. */
+  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+  {
+for (j = 0; j  len; j++) {
+  if (pos[j].cursive_chain  0)
+   pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
+}
+for (i = len; i  0; i--) {
+  j = i - 1;
+  if (pos[j].cursive_chain  0)
+   pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
 }
   }
-  /* Then handle all chain-forward connections */
-  for (i = len; i  0; i--) {
-j = i - 1;
-if (pos[j].cursive_chain  0)
-{
-  pos[j].y_offset += pos[j + pos[j].cursive_chain].y_offset;
-  pos[j].cursive_chain = 0;
+  else
+  {
+for (j = 0; j  len; j++) {
+  if (pos[j].cursive_chain  0)
+   pos[j].x_offset += pos[j + pos[j].cursive_chain].x_offset;
+}
+for (i = len; i  0; i--) {
+  j = i - 1;
+  if (pos[j].cursive_chain  0)
+   pos[j].x_offset += pos[j + pos[j].cursive_chain].x_offset;
 }
   }
 
@@ -639,7 +648,7 @@ hb_ot_layout_position_finish (hb_font_t*font HB_UNUSED,
   pos[i].x_offset += pos[back].x_offset;
   pos[i].y_offset += pos[back].y_offset;
 
-  if (buffer-props.direction == HB_DIRECTION_RTL)
+  if (HB_DIRECTION_IS_BACKWARD (buffer-props.direction))
for (j = back + 1; j  i + 1; j++) {