[HarfBuzz] harfbuzz: Branch 'master'

2015-12-17 Thread Behdad Esfahbod
 src/hb-ot-shape-complex-indic.cc |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 508cc3d3cfcfb0383df0fe795cc28db4e0fd5729
Author: Behdad Esfahbod 
Date:   Thu Dec 17 17:31:17 2015 +

[indic] Allow context when matching for Malayalam new-spec

Test sequence:
U+0995,U+09CD,U+09B0

With Nirmala shipped on Windows 10, this failed to form the below form.
Works now.

Reported by Sairus.

diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 5354897..a630419 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -557,8 +557,15 @@ data_create_indic (const hb_ot_shape_plan_t *plan)
   indic_plan->virama_glyph = (hb_codepoint_t) -1;
 
   /* Use zero-context would_substitute() matching for new-spec of the main
-   * Indic scripts, and scripts with one spec only, but not for old-specs. */
-  bool zero_context = !indic_plan->is_old_spec;
+   * Indic scripts, and scripts with one spec only, but not for old-specs.
+   * The new-spec for all dual-spec scripts says zero-context matching happens.
+   *
+   * However, testing with Malayalam shows that old and new spec both allow
+   * context.  Testing with Bengali new-spec however shows that it doesn't.
+   * So, the heuristic here is the way it is.  It should *only* be changed,
+   * as we discover more cases of what Windows does.  DON'T TOUCH OTHERWISE.
+   */
+  bool zero_context = !indic_plan->is_old_spec && plan->props.script != 
HB_SCRIPT_MALAYALAM;
   indic_plan->rphf.init (&plan->map, HB_TAG('r','p','h','f'), zero_context);
   indic_plan->pref.init (&plan->map, HB_TAG('p','r','e','f'), zero_context);
   indic_plan->blwf.init (&plan->map, HB_TAG('b','l','w','f'), zero_context);
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


[HarfBuzz] harfbuzz: Branch 'master'

2015-12-17 Thread Behdad Esfahbod
 src/hb-uniscribe.cc |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit eaf1e93ef1ee19a3e72d781e8abbd7f1165c1618
Author: Behdad Esfahbod 
Date:   Thu Dec 17 16:57:47 2015 +

[uniscribe] Handle E_NOT_SUFFICIENT_BUFFER as well as E_OUTOFMEMORY

On Windows 10 we are seeing that other error message...

Test sequence: U+0995,U+-9CD,U+09B0
With Nirmala shipped on Windows 10, this failed to form the below form.
Works now.

Reported by Sairus.

diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc
index 01be0cc..86bb84f 100644
--- a/src/hb-uniscribe.cc
+++ b/src/hb-uniscribe.cc
@@ -919,7 +919,7 @@ retry:
 
 if (unlikely (items[i].a.fNoGlyphIndex))
   FAIL ("ScriptShapeOpenType() set fNoGlyphIndex");
-if (unlikely (hr == E_OUTOFMEMORY))
+if (unlikely (hr == E_OUTOFMEMORY || hr == E_NOT_SUFFICIENT_BUFFER))
 {
   if (unlikely (!buffer->ensure (buffer->allocated * 2)))
FAIL ("Buffer resize failed");
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


[HarfBuzz] behdad/harfbuzz coverage decreased (-12.6%) to 20.611% on master

2015-12-17 Thread notifier

behdad/harfbuzz
coverage decreased (-12.6%) to 20.611%
for commit:
[util] Use O_BINARY instead of _O_BINARY

The latter doesn't seem to be available in Cygwin.  I'm surprised it
compiled before...
by
behdad
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


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

2015-12-17 Thread Behdad Esfahbod
 src/hb-ot-layout-gsubgpos-private.hh|   12 
++-
 test/shaping/Makefile.am|1 
 test/shaping/fonts/sha1sum/MANIFEST |1 
 test/shaping/fonts/sha1sum/c78d1f25ea1df1210414f2fe2e0e1e53082bba76.ttf |binary
 test/shaping/tests/MANIFEST |1 
 test/shaping/tests/ligature-id.tests|   35 
++
 util/options.cc |4 
-
 7 files changed, 49 insertions(+), 5 deletions(-)

New commits:
commit 21e5d7edc4f28157254ef29a8ac247f3a572f6a6
Author: Behdad Esfahbod 
Date:   Thu Dec 17 16:28:38 2015 +

[util] Use O_BINARY instead of _O_BINARY

The latter doesn't seem to be available in Cygwin.  I'm surprised it
compiled before...

diff --git a/util/options.cc b/util/options.cc
index 882e060..bc699c1 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -490,7 +490,7 @@ font_options_t::get_font (void) const
   GString *gs = g_string_new (NULL);
   char buf[BUFSIZ];
 #if defined(_WIN32) || defined(__CYGWIN__)
-  setmode (fileno (stdin), _O_BINARY);
+  setmode (fileno (stdin), O_BINARY);
 #endif
   while (!feof (stdin)) {
size_t ret = fread (buf, 1, sizeof (buf), stdin);
@@ -672,7 +672,7 @@ output_options_t::get_file_handle (void)
 fp = fopen (output_file, "wb");
   else {
 #if defined(_WIN32) || defined(__CYGWIN__)
-setmode (fileno (stdout), _O_BINARY);
+setmode (fileno (stdout), O_BINARY);
 #endif
 fp = stdout;
   }
commit 100fbeaf196515774c985ee839d0fa0695f9a6fa
Author: Behdad Esfahbod 
Date:   Thu Dec 17 15:23:09 2015 +

Fix ligature component of a mark happening after a ligature within a 
ligature!

Say, if we are ligating "A B_C m D", then previously 'm' was being
attached to 'B' in the combined A_B_C_D ligature.  Now we attach it
to 'C'.  No test for this though :(.

diff --git a/src/hb-ot-layout-gsubgpos-private.hh 
b/src/hb-ot-layout-gsubgpos-private.hh
index 11ad7e5..d6db005 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -847,7 +847,7 @@ static inline bool ligate_input (hb_apply_context_t *c,
   if (!is_mark_ligature) {
 unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
if (this_comp == 0)
- this_comp = 1;
+ this_comp = last_num_components;
unsigned int new_lig_comp = components_so_far - last_num_components +
MIN (this_comp, last_num_components);
  _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, 
new_lig_comp);
commit 2f02fc79a5018e3348fccf366c470803554e1e58
Author: Behdad Esfahbod 
Date:   Thu Dec 17 15:21:14 2015 +

Improve ligature-component handling

We use three bits for lig_id these days, so we finally got a report of
two separate ligatures with the same lig_id happening adjacent to each
other, and then the component-handling code was breaking things.
Protect against that by ignoring same-lig-id but lig-comp=0 glyphs after
a new ligature.

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

diff --git a/src/hb-ot-layout-gsubgpos-private.hh 
b/src/hb-ot-layout-gsubgpos-private.hh
index 2873d0f..11ad7e5 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -845,9 +845,12 @@ static inline bool ligate_input (hb_apply_context_t *c,
 while (buffer->idx < match_positions[i] && !buffer->in_error)
 {
   if (!is_mark_ligature) {
+unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
+   if (this_comp == 0)
+ this_comp = 1;
unsigned int new_lig_comp = components_so_far - last_num_components +
-   MIN (MAX (_hb_glyph_info_get_lig_comp 
(&buffer->cur()), 1u), last_num_components);
-   _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, 
new_lig_comp);
+   MIN (this_comp, last_num_components);
+ _hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, 
new_lig_comp);
   }
   buffer->next_glyph ();
 }
@@ -864,8 +867,11 @@ static inline bool ligate_input (hb_apply_context_t *c,
 /* Re-adjust components for any marks following. */
 for (unsigned int i = buffer->idx; i < buffer->len; i++) {
   if (last_lig_id == _hb_glyph_info_get_lig_id (&buffer->info[i])) {
+unsigned int this_comp = _hb_glyph_info_get_lig_comp 
(&buffer->info[i]);
+   if (!this_comp)
+ break;
unsigned int new_lig_comp = components_so_far - last_num_components +
-   MIN (MAX (_hb_glyph_info_get_lig_comp 
(&buffer->info[i]), 1u), last_num_components);
+   MIN (this_comp, last_num_components);

[HarfBuzz] harfbuzz: Branch 'master'

2015-12-17 Thread Behdad Esfahbod
 src/hb-ot-layout-private.hh |6 
+--
 src/hb-ot-shape-complex-use.cc  |   19 
++
 test/shaping/Makefile.am|1 
 test/shaping/fonts/sha1sum/MANIFEST |1 
 test/shaping/fonts/sha1sum/fbb6c84c9e1fe0c39e152fbe845e51fd81f6748e.ttf |binary
 test/shaping/tests/MANIFEST |1 
 test/shaping/tests/use.tests|1 
 7 files changed, 18 insertions(+), 11 deletions(-)

New commits:
commit 2ab0de9fbd03231b647345b01e31b136e2e00978
Author: Behdad Esfahbod 
Date:   Thu Dec 17 11:59:15 2015 +

[use] Fix halant detection

Before, we were just checking the use_category().  This detects as
halant a ligature that had the halant as first glyph (as seen in
NotoSansBalinese.)  Change that to use the is_ligated() glyph prop
bit.  The font is forming this ligature in ccmp, which is before
the rphf / pref tests.  So we need to make sure the "ligated" bit
survives those tests.  Since those only check the "substituted" bit,
we now only clear that bit for them and "ligated" survives.

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

diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 45897ed..f48184f 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -517,11 +517,9 @@ _hb_glyph_info_clear_ligated_and_multiplied 
(hb_glyph_info_t *info)
 }
 
 static inline void
-_hb_glyph_info_clear_substituted_and_ligated_and_multiplied (hb_glyph_info_t 
*info)
+_hb_glyph_info_clear_substituted (hb_glyph_info_t *info)
 {
-  info->glyph_props() &= ~(HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED |
-  HB_OT_LAYOUT_GLYPH_PROPS_LIGATED |
-  HB_OT_LAYOUT_GLYPH_PROPS_MULTIPLIED);
+  info->glyph_props() &= ~(HB_OT_LAYOUT_GLYPH_PROPS_SUBSTITUTED);
 }
 
 
diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc
index a1b63d5..3e7003a 100644
--- a/src/hb-ot-shape-complex-use.cc
+++ b/src/hb-ot-shape-complex-use.cc
@@ -360,7 +360,7 @@ clear_substitution_flags (const hb_ot_shape_plan_t *plan,
   hb_glyph_info_t *info = buffer->info;
   unsigned int count = buffer->len;
   for (unsigned int i = 0; i < count; i++)
-_hb_glyph_info_clear_substituted_and_ligated_and_multiplied (&info[i]);
+_hb_glyph_info_clear_substituted (&info[i]);
 }
 
 static void
@@ -405,6 +405,12 @@ record_pref (const hb_ot_shape_plan_t *plan,
   }
 }
 
+static inline bool
+is_halant (const hb_glyph_info_t &info)
+{
+  return info.use_category() == USE_H && !_hb_glyph_info_ligated (&info);
+}
+
 static void
 reorder_syllable (hb_buffer_t *buffer, unsigned int start, unsigned int end)
 {
@@ -420,7 +426,6 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int start, 
unsigned int end)
 
   hb_glyph_info_t *info = buffer->info;
 
-#define HALANT_FLAGS FLAG(USE_H)
 #define BASE_FLAGS (FLAG (USE_B) | FLAG (USE_GB) | FLAG (USE_IV))
 
   /* Move things forward. */
@@ -428,12 +433,12 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int 
start, unsigned int end)
   {
 /* Got a repha.  Reorder it to after first base, before first halant. */
 for (unsigned int i = start + 1; i < end; i++)
-  if (FLAG_UNSAFE (info[i].use_category()) & (HALANT_FLAGS | BASE_FLAGS))
+  if ((FLAG_UNSAFE (info[i].use_category()) & (BASE_FLAGS)) || is_halant 
(info[i]))
   {
/* If we hit a halant, move before it; otherwise it's a base: move to 
it's
 * place, and shift things in between backward. */
 
-   if (info[i].use_category() == USE_H)
+   if (is_halant (info[i]))
  i--;
 
buffer->merge_clusters (start, i + 1);
@@ -450,11 +455,11 @@ reorder_syllable (hb_buffer_t *buffer, unsigned int 
start, unsigned int end)
   for (unsigned int i = start; i < end; i++)
   {
 uint32_t flag = FLAG_UNSAFE (info[i].use_category());
-if (flag & (HALANT_FLAGS | BASE_FLAGS))
+if ((flag & (BASE_FLAGS)) || is_halant (info[i]))
 {
-  /* If we hit a halant, move before it; otherwise it's a base: move to 
it's
+  /* If we hit a halant, move after it; otherwise it's a base: move to it's
* place, and shift things in between backward. */
-  if (info[i].use_category() == USE_H)
+  if (is_halant (info[i]))
j = i + 1;
   else
j = i;
diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index a8e485e..f381ac5 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -55,6 +55,7 @@ TESTS = \
tests/mongolian-variation-selector.tests \
tests/spaces.tests \
tests/simple.tests \
+   tests/use.tests \
tests/vertical.tests \
tests/zero-width-marks.tests \
$(NULL)
diff --git a/test/shaping/fonts/sha1sum/MANIFEST 
b/test/shaping/fonts/

[HarfBuzz] harfbuzz: Branch 'master'

2015-12-17 Thread Behdad Esfahbod
 src/hb-ot-shape-complex-arabic.cc |   24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

New commits:
commit 86bcbd65b0d98357fb3d67a2f4f2a704ace55e10
Author: Behdad Esfahbod 
Date:   Thu Dec 17 11:04:33 2015 +

[arabic] Use glyph advance width in apply_stch() instead of extents

That seems to be what Windows is doing, and makes more sense.

diff --git a/src/hb-ot-shape-complex-arabic.cc 
b/src/hb-ot-shape-complex-arabic.cc
index 8ab9a02..4da8990 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -463,10 +463,6 @@ apply_stch (const hb_ot_shape_plan_t *plan,
* Second pass applies the stretch, copying things to the end of buffer.
*/
 
-  /* 30 = 2048 / 70.
-   * https://www.microsoft.com/typography/cursivescriptguidelines.mspx */
-  hb_position_t overlap = font->x_scale / 30;
-  DEBUG_MSG (ARABIC, NULL, "overlap for stretching is %d", overlap);
   int sign = font->x_scale < 0 ? -1 : +1;
   unsigned int extra_glyphs_needed = 0; // Set during MEASURE, used during CUT
   typedef enum { MEASURE, CUT } step_t;
@@ -504,18 +500,15 @@ apply_stch (const hb_ot_shape_plan_t *plan,
 hb_in_range (info[i - 1].arabic_shaping_action(), 
STCH_FIXED, STCH_REPEATING))
   {
i--;
-   hb_glyph_extents_t extents;
-   if (!font->get_glyph_extents (info[i].codepoint, &extents))
- extents.width = 0;
-   extents.width -= overlap;
+   hb_position_t width = font->get_glyph_h_advance (info[i].codepoint);
if (info[i].arabic_shaping_action() == STCH_FIXED)
{
- w_fixed += extents.width;
+ w_fixed += width;
  n_fixed++;
}
else
{
- w_repeating += extents.width;
+ w_repeating += width;
  n_repeating++;
}
   }
@@ -540,7 +533,7 @@ apply_stch (const hb_ot_shape_plan_t *plan,
   /* Number of additional times to repeat each repeating tile. */
   int n_copies = 0;
 
-  hb_position_t w_remaining = w_total - w_fixed - overlap;
+  hb_position_t w_remaining = w_total - w_fixed;
   if (sign * w_remaining > sign * w_repeating && sign * w_repeating > 0)
n_copies = (sign * w_remaining) / (sign * w_repeating) - 1;
 
@@ -562,13 +555,10 @@ apply_stch (const hb_ot_shape_plan_t *plan,
   }
   else
   {
-hb_position_t x_offset = -overlap;
+   hb_position_t x_offset = 0;
for (unsigned int k = end; k > start; k--)
{
- hb_glyph_extents_t extents;
- if (!font->get_glyph_extents (info[k - 1].codepoint, &extents))
-   extents.width = 0;
- extents.width -= overlap;
+ hb_position_t width = font->get_glyph_h_advance (info[k - 
1].codepoint);
 
  unsigned int repeat = 1;
  if (info[k - 1].arabic_shaping_action() == STCH_REPEATING)
@@ -578,7 +568,7 @@ apply_stch (const hb_ot_shape_plan_t *plan,
 repeat, info[k - 1].codepoint, j);
  for (unsigned int n = 0; n < repeat; n++)
  {
-   x_offset -= extents.width;
+   x_offset -= width;
if (n > 0)
  x_offset += extra_repeat_overlap;
pos[k - 1].x_offset = x_offset;
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] A plea to make HarfBuzz easier to build.

2015-12-17 Thread Behdad Esfahbod
On 15-12-16 12:06 AM, Jamie Dale wrote:
> The way I handled this was to create a define called HAVE_STUB_GETENV (which
> is a really weird name in hindsight) in my config.h file. I then just set that
> define, along with HAVE_INTEL_ATOMIC_PRIMITIVES, when building for PS4.
> 
> I'm not sure if you'd want to take that into HarfBuzz proper, or whether you'd
> want a better way?

If there's a macro to detect PS4, we can add that.  We already do that for 
WinCE:

#  if defined(_WIN32_WCE)
 /* Some things not defined on Windows CE. */
#define strdup _strdup
#define getenv(Name) NULL
#if _WIN32_WCE < 0x800
#  define setlocale(Category, Locale) "C"
static int errno = 0; /* Use something better? */
#endif
...

behdad


> #ifdef HAVE_STUB_GETENV
> // Stub out getenv as not all platforms support it
> #define getenv(name) 0
> #endif // HAVE_STUB_GETENV
> 
> -Jamie.
> 
>   This email has been sent from a virus-free computer protected by Avast.
> www.avast.com
> 
> 
> 
> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> 
> On 15 December 2015 at 11:40, Behdad Esfahbod  > wrote:
> 
> On 15-12-13 09:33 PM, Jamie Dale wrote:
> > You'll need a define to stub out getenv for a PS4 build
> 
> I'll take a patch to hb-private.hh to do that.
> 
> 
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz