[HarfBuzz] harfbuzz-ng: Branch 'master'

2012-07-26 Thread Behdad Esfahbod
 src/hb-old/harfbuzz-global.h |   17 +++--
 src/hb-old/harfbuzz-impl.h   |6 +-
 2 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit fa2dfcd560444d8c54b6349ee106134d3536f79b
Author: Behdad Esfahbod 
Date:   Thu Jul 26 16:06:16 2012 -0400

Fix visibility warnings with MinGW32

diff --git a/src/hb-old/harfbuzz-global.h b/src/hb-old/harfbuzz-global.h
index c0f54d6..9ba5841 100644
--- a/src/hb-old/harfbuzz-global.h
+++ b/src/hb-old/harfbuzz-global.h
@@ -31,14 +31,19 @@
 #include 
 #include 
 
-#define HB_BEGIN_VISIBILITY _Pragma ("GCC visibility push(hidden)")
-#define HB_END_VISIBILITY _Pragma ("GCC visibility pop")
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
+# define HB_BEGIN_VISIBILITY _Pragma ("GCC visibility push(hidden)")
+# define HB_END_VISIBILITY _Pragma ("GCC visibility pop")
+#else
+# define HB_BEGIN_VISIBILITY
+# define HB_END_VISIBILITY
+#endif
 #ifdef __cplusplus
-#define HB_BEGIN_HEADER  extern "C" { HB_BEGIN_VISIBILITY
-#define HB_END_HEADER  HB_END_VISIBILITY }
+# define HB_BEGIN_HEADER  extern "C" { HB_BEGIN_VISIBILITY
+# define HB_END_HEADER  HB_END_VISIBILITY }
 #else
-#define HB_BEGIN_HEADER  HB_BEGIN_VISIBILITY
-#define HB_END_HEADER  HB_END_VISIBILITY
+# define HB_BEGIN_HEADER  HB_BEGIN_VISIBILITY
+# define HB_END_HEADER  HB_END_VISIBILITY
 #endif
 
 HB_BEGIN_HEADER
diff --git a/src/hb-old/harfbuzz-impl.h b/src/hb-old/harfbuzz-impl.h
index 01865ca..3f370b6 100644
--- a/src/hb-old/harfbuzz-impl.h
+++ b/src/hb-old/harfbuzz-impl.h
@@ -33,7 +33,11 @@
 HB_BEGIN_HEADER
 
 #ifndef HB_INTERNAL
-# define HB_INTERNAL __attribute__((visibility("hidden")))
+# ifndef __MINGW32__
+#  define HB_INTERNAL __attribute__((__visibility__("hidden")))
+# else
+#  define HB_INTERNAL
+# endif
 #endif
 
 #ifndef NULL
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] Malayalam [was: Lemongrass HarfBuzz Hackfest, end of day 4]

2012-07-26 Thread Behdad Esfahbod
On 07/23/2012 12:21 PM, Jonathan Kew wrote:
> 
> Another issue to check is the handling of a sequence with vowel-matra followed
> by virama, such as . I notice that we differ from Core Text
> on this one (using the Lohit Malayalam font) - our shaper appears to use a
> ligature of the u-matra and virama, whereas Core Text doesn't ligate them. I
> haven't tried Uniscribe yet to see what it gives.

Looks like Uniscribe agrees with CoreText.  I have to investigate.  It's
perhaps one of those features that we apply globally...

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


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

2012-07-26 Thread Behdad Esfahbod
 src/hb-coretext.cc |   41 +++--
 1 file changed, 39 insertions(+), 2 deletions(-)

New commits:
commit ac2085d4b391b0a72473ecac3dd6c22efe66833f
Author: Jonathan Kew 
Date:   Thu Jul 26 15:58:45 2012 -0400

[CoreText] Ensure cluster indices in output buffer are non-decreasing.

Does not provide Uniscribe-compatible results, but should at least avoid
breaking hb-view due to out-of-order cluster values.

For RTL runs, ensure cluster values are non-increasing (instead of
non-decreasing).

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 65a1c73..c99ffc4 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -319,5 +319,42 @@ _hb_coretext_shape (hb_font_t  *font,
 pos->y_offset = info->var2.u32;
   }
 
+  // Fix up clusters so that we never return out-of-order indices;
+  // if core text has reordered glyphs, we'll merge them to the
+  // beginning of the reordered cluster.
+  // This does *not* mean we'll form the same clusters as Uniscribe
+  // or the native OT backend, only that the cluster indices will be
+  // non-decreasing in the output buffer.
+  if (HB_DIRECTION_IS_FORWARD (buffer->props.direction)) {
+unsigned int prev_cluster = 0;
+for (unsigned int i = 0; i < count; i++) {
+  unsigned int curr_cluster = buffer->info[i].cluster;
+  if (curr_cluster < prev_cluster) {
+for (unsigned int j = i; j > 0; j--) {
+  if (buffer->info[j - 1].cluster > curr_cluster)
+buffer->info[j - 1].cluster = curr_cluster;
+  else
+break;
+}
+  }
+  prev_cluster = curr_cluster;
+}
+  } else {
+// For RTL runs, we make them non-increasing instead.
+unsigned int prev_cluster = (unsigned int)-1;
+for (unsigned int i = 0; i < count; i++) {
+  unsigned int curr_cluster = buffer->info[i].cluster;
+  if (curr_cluster > prev_cluster) {
+for (unsigned int j = i; j > 0; j--) {
+  if (buffer->info[j - 1].cluster < curr_cluster)
+buffer->info[j - 1].cluster = curr_cluster;
+  else
+break;
+}
+  }
+  prev_cluster = curr_cluster;
+}
+  }
+
   return true;
 }
commit 441d3bb7de311d54b9f0a5210344f9a96e97e153
Author: Behdad Esfahbod 
Date:   Thu Jul 26 12:01:12 2012 -0400

Minor

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index f49e76e..65a1c73 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -260,8 +260,8 @@ _hb_coretext_shape (hb_font_t  *font,
 
 #define ALLOCATE_ARRAY(Type, name, len) \
   Type *name = (Type *) scratch; \
-  scratch += len * sizeof (name[0]); \
-  scratch_size -= len * sizeof (name[0]);
+  scratch += (len) * sizeof ((name)[0]); \
+  scratch_size -= (len) * sizeof ((name)[0]);
 
 const CGGlyph* glyphs = CTRunGetGlyphsPtr (run);
 if (!glyphs) {
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2012-07-26 Thread Behdad Esfahbod
On 07/26/2012 09:17 AM, Harshula wrote:
>> > [hb-old] Fix clusters
>> > 
>> > Unlike its "documentation", hb-old's log_clusters are, well, indeed
>> > logical, not visual.  Fixup.  Adapted / copied from hb-uniscribe.
> This commit seems to have broken Sinhala rendering with FreeSerif font
> for the following file:

I have a hard time believing that that commit can break shaping at all.
Specially if you say hb-shape output is the same.

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


Re: [HarfBuzz] HarfBuzz.old backend in new HarfBuzz

2012-07-26 Thread Behdad Esfahbod
On 07/26/2012 03:26 AM, Martin Hosken wrote:
> Dear Behdad,
> 
>> Pretty much like the Uniscribe and CoreText backends, this new backend is
>> primarily for testing, and may be removed in the future (after I have
>> convinced everyone to move to the real HarfBuzz).
> 
> Is now the right time to ask for the reenabling of the graphite backend?

Not really.  I'm trying to finish the native backend and get it in the field.
 Graphite backedn only distracts me from that.

Plus, based on previous experience, I think I'm going to disable all
non-native backends by default.  It will be another story after Firefox people
do their fuzz testing and find that Graphite2 is fairly stable.

That said, I'm pulling and building graphitedev right now.  Is that the
version I should be looking at?

behdad

> Yours,
> Martin
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2012-07-26 Thread Harshula
[Resending with smaller attachments]

On Wed, 2012-07-25 at 16:21 -0700, Behdad Esfahbod wrote:
> src/hb-old.cc|   51 
> +--
>  src/hb-old/harfbuzz-shaper.h |1 
>  src/hb-uniscribe.cc  |5 ++--
>  3 files changed, 44 insertions(+), 13 deletions(-)
> 
> New commits:
> commit 91e721ea8693205f4f738bca97a5055ee75cf463
> Author: Behdad Esfahbod 
> Date:   Wed Jul 25 19:20:34 2012 -0400
> 
> [hb-old] Fix clusters
> 
> Unlike its "documentation", hb-old's log_clusters are, well, indeed
> logical, not visual.  Fixup.  Adapted / copied from hb-uniscribe.

This commit seems to have broken Sinhala rendering with FreeSerif font
for the following file:
http://git.savannah.gnu.org/cgit/sinhala.git/plain/patches/icu-sinhala-rendering.txt

I have attached the output of both hb-view and hb-shape. hb-shape output
has not changed. hb-view output is very different. The aforementioned
patch actually does fix a rendering problem with the standalone
consonant ක (ka) when using the FreeSerif font. But breaks කො (ko), කෝ
(koo), කෞ (kau), ක්‍ර (kra), ක්‍ය (kya).

cya,
#


> diff --git a/src/hb-old.cc b/src/hb-old.cc
> index a3b5679..e828ca8 100644
> --- a/src/hb-old.cc
> +++ b/src/hb-old.cc
> @@ -251,6 +251,8 @@ _hb_old_shape (hb_font_t  *font,
>  
>buffer->guess_properties ();
>  
> +  bool backward = HB_DIRECTION_IS_BACKWARD (buffer->props.direction);
> +
>  #define FAIL(...) \
>HB_STMT_START { \
>  DEBUG_MSG (OLD, NULL, __VA_ARGS__); \
> @@ -285,23 +287,23 @@ retry:
>pchars[chars_len++] = 0xDC00 + ((c - 0x1) & ((1 << 10) - 1));
>  }
>}
> -#undef utf16_index
>  
> 
>  #define ALLOCATE_ARRAY(Type, name, len) \
>name = (Type *) scratch; \
> -  scratch += len * sizeof (name[0]); \
> -  scratch_size -= len * sizeof (name[0]);
> +  scratch += (len) * sizeof ((name)[0]); \
> +  scratch_size -= (len) * sizeof ((name)[0]);
>  
> 
>HB_ShaperItem item = {0};
>  
>ALLOCATE_ARRAY (const HB_UChar16, item.string, chars_len);
> +  ALLOCATE_ARRAY (unsigned short, item.log_clusters, chars_len + 2);
>item.stringLength = chars_len;
>item.item.pos = 0;
>item.item.length = item.stringLength;
>item.item.script = hb_old_script_from_script (buffer->props.script);
> -  item.item.bidiLevel = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 
> 0 : 1;
> +  item.item.bidiLevel = backward ? 1 : 0;
>  
>item.font = old_font;
>item.face = old_face;
> @@ -314,14 +316,17 @@ retry:
>   sizeof (HB_GlyphAttributes) +
>   sizeof (HB_Fixed) +
>   sizeof (HB_FixedPoint) +
> - sizeof (unsigned short));
> + sizeof (uint32_t));
>  
>item.num_glyphs = num_glyphs;
>ALLOCATE_ARRAY (HB_Glyph, item.glyphs, num_glyphs);
>ALLOCATE_ARRAY (HB_GlyphAttributes, item.attributes, num_glyphs);
>ALLOCATE_ARRAY (HB_Fixed, item.advances, num_glyphs);
>ALLOCATE_ARRAY (HB_FixedPoint, item.offsets, num_glyphs);
> -  ALLOCATE_ARRAY (unsigned short, item.log_clusters, num_glyphs);
> +  uint32_t *vis_clusters;
> +  ALLOCATE_ARRAY (uint32_t, vis_clusters, num_glyphs);
> +
> +#undef ALLOCATE_ARRAY
>  
>if (!HB_ShapeItem (&item))
>  return false;
> @@ -335,24 +340,48 @@ retry:
>}
>num_glyphs = item.num_glyphs;
>  
> -#undef ALLOCATE_ARRAY
> +  /* Ok, we've got everything we need, now compose output buffer,
> +   * very, *very*, carefully! */
> +
> +  /* Calculate visual-clusters.  That's what we ship. */
> +  for (unsigned int i = 0; i < num_glyphs; i++)
> +vis_clusters[i] = -1;
> +  for (unsigned int i = 0; i < buffer->len; i++) {
> +uint32_t *p = 
> &vis_clusters[item.log_clusters[buffer->info[i].utf16_index()]];
> +*p = MIN (*p, buffer->info[i].cluster);
> +  }
> +  if (!backward) {
> +for (unsigned int i = 1; i < num_glyphs; i++)
> +  if (vis_clusters[i] == -1)
> + vis_clusters[i] = vis_clusters[i - 1];
> +  } else {
> +for (int i = num_glyphs - 2; i >= 0; i--)
> +  if (vis_clusters[i] == -1)
> + vis_clusters[i] = vis_clusters[i + 1];
> +  }
> +
> +#undef utf16_index
>  
> +  buffer->ensure (num_glyphs);
> +  if (buffer->in_error)
> +FAIL ("Buffer in error");
> +
> +
> +  buffer->len = num_glyphs;
>hb_glyph_info_t *info = buffer->info;
>for (unsigned int i = 0; i < num_glyphs; i++)
>{
>  info[i].codepoint = item.glyphs[i];
> -info[i].cluster = item.log_clusters[i];
> +info[i].cluster = vis_clusters[i];
>  
>  info[i].mask = item.advances[i];
>  info[i].var1.u32 = item.offsets[i].x;
>  info[i].var2.u32 = item.offsets[i].y;
>}
> -  buffer->len = num_glyphs;
>  
>buffer->clear_positions ();
>  
> -  unsigned int count = buffer->len;
> -  for (unsigned int i = 0; i < count; ++i) {
> +  for (unsigned int i = 0; i < num_gl

Re: [HarfBuzz] HarfBuzz.old backend in new HarfBuzz

2012-07-26 Thread Martin Hosken
Dear Behdad,

> Pretty much like the Uniscribe and CoreText backends, this new backend is
> primarily for testing, and may be removed in the future (after I have
> convinced everyone to move to the real HarfBuzz).

Is now the right time to ask for the reenabling of the graphite backend?

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