[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Jul 22 09:51:34 PDT 2015
src/hb-ot-layout-gsubgpos-private.hh | 3
src/hb-ot-layout-private.hh | 4 -
src/hb-ot-shape.cc | 122 +++++++++++++++++------------------
3 files changed, 64 insertions(+), 65 deletions(-)
New commits:
commit 4ba796b26ee62de0d2830a550f3aa3b4aecf6f59
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Jul 22 17:41:31 2015 +0100
Refactor _hb_glyph_info_is_default_ignorable()
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 842be88..99c4c83 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -328,8 +328,7 @@ struct hb_apply_context_t
if (unlikely (_hb_glyph_info_is_default_ignorable (&info) &&
(ignore_zwnj || !_hb_glyph_info_is_zwnj (&info)) &&
- (ignore_zwj || !_hb_glyph_info_is_zwj (&info)) &&
- !_hb_glyph_info_ligated (&info)))
+ (ignore_zwj || !_hb_glyph_info_is_zwj (&info))))
return SKIP_MAYBE;
return SKIP_NO;
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 47fecd2..d854563 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -225,10 +225,12 @@ _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info)
return info->unicode_props1();
}
+static inline bool _hb_glyph_info_ligated (const hb_glyph_info_t *info);
+
static inline hb_bool_t
_hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info)
{
- return !!(info->unicode_props0() & MASK0_IGNORABLE);
+ return (info->unicode_props0() & MASK0_IGNORABLE) && !_hb_glyph_info_ligated (info);
}
static inline hb_bool_t
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 59c58fd..33b13b5 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -426,8 +426,7 @@ hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
unsigned int i = 0;
for (i = 0; i < count; i++)
{
- if (unlikely (!_hb_glyph_info_ligated (&info[i]) &&
- _hb_glyph_info_is_default_ignorable (&info[i])))
+ if (unlikely (_hb_glyph_info_is_default_ignorable (&info[i])))
break;
}
@@ -441,8 +440,7 @@ hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
/* Replace default-ignorables with a zero-advance space glyph. */
for (/*continue*/; i < count; i++)
{
- if (!_hb_glyph_info_ligated (&info[i]) &&
- _hb_glyph_info_is_default_ignorable (&info[i]))
+ if (_hb_glyph_info_is_default_ignorable (&info[i]))
{
info[i].codepoint = space;
pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0;
@@ -457,8 +455,7 @@ hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
buffer->next_glyphs (i);
while (buffer->idx < buffer->len)
{
- if (!_hb_glyph_info_ligated (&info[buffer->idx]) &&
- _hb_glyph_info_is_default_ignorable (&info[buffer->idx]))
+ if (_hb_glyph_info_is_default_ignorable (&info[buffer->idx]))
{
buffer->delete_glyph ();
continue;
commit f0010dfd01ef4a927b0bdc175dd4e343a8637174
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Jul 22 17:36:23 2015 +0100
[ot] Hide default-ignorables before finishing off positioning
For example, fixes the following sequence with Arial XP:
628 25cc 651 25cc 64e 3a 20 628 651 34f 64e
628 25cc 64e 25cc 651 3a 20 628 64e 34f 651
Discovered as part of:
https://bugs.freedesktop.org/show_bug.cgi?id=85873
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index d290cad..59c58fd 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -411,6 +411,65 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
}
}
+
+static void
+hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
+{
+ hb_buffer_t *buffer = c->buffer;
+
+ if (buffer->flags & HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES)
+ return;
+
+ unsigned int count = buffer->len;
+ hb_glyph_info_t *info = buffer->info;
+ hb_glyph_position_t *pos = buffer->pos;
+ unsigned int i = 0;
+ for (i = 0; i < count; i++)
+ {
+ if (unlikely (!_hb_glyph_info_ligated (&info[i]) &&
+ _hb_glyph_info_is_default_ignorable (&info[i])))
+ break;
+ }
+
+ /* No default-ignorables found; return. */
+ if (i == count)
+ return;
+
+ hb_codepoint_t space;
+ if (c->font->get_glyph (' ', 0, &space))
+ {
+ /* Replace default-ignorables with a zero-advance space glyph. */
+ for (/*continue*/; i < count; i++)
+ {
+ if (!_hb_glyph_info_ligated (&info[i]) &&
+ _hb_glyph_info_is_default_ignorable (&info[i]))
+ {
+ info[i].codepoint = space;
+ pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0;
+ }
+ }
+ }
+ else
+ {
+ /* Merge clusters and delete default-ignorables. */
+ buffer->clear_output ();
+ buffer->idx = 0;
+ buffer->next_glyphs (i);
+ while (buffer->idx < buffer->len)
+ {
+ if (!_hb_glyph_info_ligated (&info[buffer->idx]) &&
+ _hb_glyph_info_is_default_ignorable (&info[buffer->idx]))
+ {
+ buffer->delete_glyph ();
+ continue;
+ }
+ buffer->next_glyph ();
+ }
+ buffer->swap_buffers ();
+ }
+}
+
+
static inline void
hb_ot_map_glyphs_fast (hb_buffer_t *buffer)
{
@@ -656,6 +715,10 @@ hb_ot_position (hb_ot_shape_context_t *c)
hb_bool_t fallback = !hb_ot_position_complex (c);
+ /* Need to do this here, since position_finish and fallback positioning
+ * might be affected by width of default_ignorables. */
+ hb_ot_hide_default_ignorables (c);
+
hb_ot_layout_position_finish (c->font, c->buffer);
if (fallback && c->plan->shaper->fallback_position)
@@ -673,66 +736,6 @@ hb_ot_position (hb_ot_shape_context_t *c)
}
-/* Post-process */
-
-static void
-hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
-{
- hb_buffer_t *buffer = c->buffer;
-
- if (buffer->flags & HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES)
- return;
-
- unsigned int count = buffer->len;
- hb_glyph_info_t *info = buffer->info;
- hb_glyph_position_t *pos = buffer->pos;
- unsigned int i = 0;
- for (i = 0; i < count; i++)
- {
- if (unlikely (!_hb_glyph_info_ligated (&info[i]) &&
- _hb_glyph_info_is_default_ignorable (&info[i])))
- break;
- }
-
- /* No default-ignorables found; return. */
- if (i == count)
- return;
-
- hb_codepoint_t space;
- if (c->font->get_glyph (' ', 0, &space))
- {
- /* Replace default-ignorables with a zero-advance space glyph. */
- for (/*continue*/; i < count; i++)
- {
- if (!_hb_glyph_info_ligated (&info[i]) &&
- _hb_glyph_info_is_default_ignorable (&info[i]))
- {
- info[i].codepoint = space;
- pos[i].x_advance = pos[i].y_advance = pos[i].x_offset = pos[i].y_offset = 0;
- }
- }
- }
- else
- {
- /* Merge clusters and delete default-ignorables. */
- buffer->clear_output ();
- buffer->idx = 0;
- buffer->next_glyphs (i);
- while (buffer->idx < buffer->len)
- {
- if (!_hb_glyph_info_ligated (&info[buffer->idx]) &&
- _hb_glyph_info_is_default_ignorable (&info[buffer->idx]))
- {
- buffer->delete_glyph ();
- continue;
- }
- buffer->next_glyph ();
- }
- buffer->swap_buffers ();
- }
-}
-
-
/* Pull it all together! */
static void
@@ -756,8 +759,6 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
hb_ot_substitute (c);
hb_ot_position (c);
- hb_ot_hide_default_ignorables (c);
-
_hb_buffer_deallocate_unicode_vars (c->buffer);
c->buffer->props.direction = c->target_direction;
More information about the HarfBuzz
mailing list