[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Sep 27 14:06:56 PDT 2013
src/hb-ot-shape.cc | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
New commits:
commit 3d2c4f0c2ff8fab4262988aad65b170e5b479b20
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Sep 27 17:06:29 2013 -0400
Fix hiding of default_ignorables if font doesn't have space glyph
Based on patch from Jonathan Kew. See discussion on the list.
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 15f4461..4ed6b84 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -533,22 +533,42 @@ hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c)
if (c->buffer->flags & HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES)
return;
- hb_codepoint_t space = 0;
+ hb_codepoint_t space;
+ enum {
+ SPACE_DONT_KNOW,
+ SPACE_AVAILABLE,
+ SPACE_UNAVAILABLE
+ } space_status = SPACE_DONT_KNOW;
unsigned int count = c->buffer->len;
+ hb_glyph_info_t *info = c->buffer->info;
+ hb_glyph_position_t *pos = c->buffer->pos;
+ unsigned int j = 0;
for (unsigned int i = 0; i < count; i++)
- if (unlikely (!is_a_ligature (c->buffer->info[i]) &&
- _hb_glyph_info_is_default_ignorable (&c->buffer->info[i])))
+ {
+ if (unlikely (!is_a_ligature (info[i]) &&
+ _hb_glyph_info_is_default_ignorable (&info[i])))
{
- if (!space) {
- /* We assume that the space glyph is not gid0. */
- if (unlikely (!c->font->get_glyph (' ', 0, &space)) || !space)
- return; /* No point! */
+ if (space_status == SPACE_DONT_KNOW)
+ space_status = c->font->get_glyph (' ', 0, &space) ? SPACE_AVAILABLE : SPACE_UNAVAILABLE;
+
+ if (space_status == SPACE_AVAILABLE)
+ {
+ info[i].codepoint = space;
+ pos[i].x_advance = 0;
+ pos[i].y_advance = 0;
}
- c->buffer->info[i].codepoint = space;
- c->buffer->pos[i].x_advance = 0;
- c->buffer->pos[i].y_advance = 0;
+ else
+ continue; /* Delete it. */
+ }
+ if (j != i)
+ {
+ info[j] = info[i];
+ pos[j] = pos[i];
}
+ j++;
+ }
+ c->buffer->len = j;
}
More information about the HarfBuzz
mailing list