[HarfBuzz] harfbuzz-ng: Branch 'master' - 3 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Jul 21 09:01:09 PDT 2011
src/hb-ot-shape-normalize.cc | 33 +++++++++++++++++++----------
src/hb-ot-shape-private.hh | 3 +-
src/hb-ot-shape.cc | 48 +++++++++++++++++++++----------------------
3 files changed, 48 insertions(+), 36 deletions(-)
New commits:
commit d63adfc7d09b26764d9166da97372b21257e7611
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jul 21 11:48:57 2011 -0400
No need to handle variation-selectors seperately, they are GC=Mn
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index d868f37..bffd075 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -197,8 +197,7 @@ hb_form_clusters (hb_buffer_t *buffer)
if (FLAG (buffer->info[i].general_category()) &
(FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) |
- FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)) ||
- is_variation_selector (buffer->info[buffer->i].codepoint))
+ FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
buffer->info[i].cluster = buffer->info[i - 1].cluster;
}
commit aa7264123a088936f2043b45d4d41ca7413fabe5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jul 21 11:34:59 2011 -0400
Only form clusters if we are reversing
This produces more accurate cluster mappings. Cluster mappings are
minimal now. Combining marks get their own cluster value most of
the time.
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 939bf4f..d868f37 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -177,12 +177,12 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
/* Prepare */
static void
-hb_set_unicode_props (hb_ot_shape_context_t *c)
+hb_set_unicode_props (hb_buffer_t *buffer)
{
- hb_unicode_funcs_t *unicode = c->buffer->unicode;
- hb_glyph_info_t *info = c->buffer->info;
+ hb_unicode_funcs_t *unicode = buffer->unicode;
+ hb_glyph_info_t *info = buffer->info;
- unsigned int count = c->buffer->len;
+ unsigned int count = buffer->len;
for (unsigned int i = 1; i < count; i++) {
info[i].general_category() = hb_unicode_general_category (unicode, info[i].codepoint);
info[i].combining_class() = hb_unicode_combining_class (unicode, info[i].codepoint);
@@ -190,41 +190,42 @@ hb_set_unicode_props (hb_ot_shape_context_t *c)
}
static void
-hb_form_clusters (hb_ot_shape_context_t *c)
+hb_form_clusters (hb_buffer_t *buffer)
{
- unsigned int count = c->buffer->len;
+ unsigned int count = buffer->len;
for (unsigned int i = 1; i < count; i++)
- if (FLAG (c->buffer->info[i].general_category()) &
+ if (FLAG (buffer->info[i].general_category()) &
(FLAG (HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)) ||
- is_variation_selector (c->buffer->info[c->buffer->i].codepoint))
- c->buffer->info[i].cluster = c->buffer->info[i - 1].cluster;
+ is_variation_selector (buffer->info[buffer->i].codepoint))
+ buffer->info[i].cluster = buffer->info[i - 1].cluster;
}
static void
-hb_ensure_native_direction (hb_ot_shape_context_t *c)
+hb_ensure_native_direction (hb_buffer_t *buffer)
{
- hb_direction_t direction = c->buffer->props.direction;
+ hb_direction_t direction = buffer->props.direction;
/* TODO vertical:
* The only BTT vertical script is Ogham, but it's not clear to me whether OpenType
* Ogham fonts are supposed to be implemented BTT or not. Need to research that
* first. */
- if ((HB_DIRECTION_IS_HORIZONTAL (direction) && direction != hb_script_get_horizontal_direction (c->buffer->props.script)) ||
+ if ((HB_DIRECTION_IS_HORIZONTAL (direction) && direction != hb_script_get_horizontal_direction (buffer->props.script)) ||
(HB_DIRECTION_IS_VERTICAL (direction) && direction != HB_DIRECTION_TTB))
{
- hb_buffer_reverse_clusters (c->buffer);
- c->buffer->props.direction = HB_DIRECTION_REVERSE (c->buffer->props.direction);
+ hb_form_clusters (buffer);
+ hb_buffer_reverse_clusters (buffer);
+ buffer->props.direction = HB_DIRECTION_REVERSE (buffer->props.direction);
}
}
static void
-hb_reset_glyph_infos (hb_ot_shape_context_t *c)
+hb_reset_glyph_infos (hb_buffer_t *buffer)
{
- unsigned int count = c->buffer->len;
+ unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++)
- c->buffer->info[i].var1.u32 = c->buffer->info[i].var2.u32 = 0;
+ buffer->info[i].var1.u32 = buffer->info[i].var2.u32 = 0;
}
@@ -357,17 +358,15 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c)
/* Save the original direction, we use it later. */
c->target_direction = c->buffer->props.direction;
- hb_reset_glyph_infos (c); /* BUFFER: Clear buffer var1 and var2 */
-
- hb_set_unicode_props (c); /* BUFFER: Set general_category and combining_class in var1 */
+ hb_reset_glyph_infos (c->buffer); /* BUFFER: Clear buffer var1 and var2 */
- hb_form_clusters (c);
+ hb_set_unicode_props (c->buffer); /* BUFFER: Set general_category and combining_class in var1 */
- hb_ensure_native_direction (c);
+ hb_ensure_native_direction (c->buffer);
if (_hb_normalize (c))
/* Buffer contents changed, reset unicode_props */
- hb_set_unicode_props (c); /* BUFFER: Set general_category and combining_class in var1 */
+ hb_set_unicode_props (c->buffer); /* BUFFER: Set general_category and combining_class in var1 */
hb_ot_shape_setup_masks (c); /* BUFFER: Clobbers var2 */
commit 5c6f5982d78e2d7fadc2fbb8b4f3a4be9420c59a
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Jul 21 11:31:08 2011 -0400
Towards normalization
diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc
index 6d55a30..f6e962c 100644
--- a/src/hb-ot-shape-normalize.cc
+++ b/src/hb-ot-shape-normalize.cc
@@ -28,32 +28,41 @@
HB_BEGIN_DECLS
-static void
-handle_single_char_cluster (hb_ot_shape_context_t *c,
- unsigned int i)
+static bool
+get_glyph (hb_ot_shape_context_t *c, unsigned int i)
{
hb_buffer_t *b = c->buffer;
- hb_codepoint_t glyph;
- if (hb_font_get_glyph (c->font, b->info[i].codepoint, 0, &glyph))
- return;
+ return hb_font_get_glyph (c->font, b->info[i].codepoint, 0, &b->info[i].intermittent_glyph());
+}
+
+static bool
+handle_single_char_cluster (hb_ot_shape_context_t *c,
+ unsigned int i)
+{
+ if (get_glyph (c, i))
+ return FALSE;
/* Decompose */
+
+ return FALSE;
}
-static void
+static bool
handle_multi_char_cluster (hb_ot_shape_context_t *c,
unsigned int i,
unsigned int end)
{
/* If there's a variation-selector, give-up, it's just too hard. */
+ return FALSE;
}
-void
+bool
_hb_normalize (hb_ot_shape_context_t *c)
{
hb_buffer_t *b = c->buffer;
-
+ bool changed = FALSE;
+
unsigned int count = b->len;
for (unsigned int i = 0; i < count;) {
unsigned int end;
@@ -61,11 +70,13 @@ _hb_normalize (hb_ot_shape_context_t *c)
if (b->info[i].cluster != b->info[end].cluster)
break;
if (i + 1 == end)
- handle_single_char_cluster (c, i);
+ changed |= handle_single_char_cluster (c, i);
else
- handle_multi_char_cluster (c, i, end);
+ changed |= handle_multi_char_cluster (c, i, end);
i = end;
}
+
+ return changed;
}
HB_END_DECLS
diff --git a/src/hb-ot-shape-private.hh b/src/hb-ot-shape-private.hh
index d64178a..03dd4ed 100644
--- a/src/hb-ot-shape-private.hh
+++ b/src/hb-ot-shape-private.hh
@@ -100,8 +100,9 @@ is_variation_selector (hb_codepoint_t unicode)
}
-HB_INTERNAL void _hb_normalize (hb_ot_shape_context_t *c);
+HB_INTERNAL bool _hb_normalize (hb_ot_shape_context_t *c);
+#define intermittent_glyph() var2.u32
HB_END_DECLS
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 50f2986..939bf4f 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -365,7 +365,9 @@ hb_ot_shape_execute_internal (hb_ot_shape_context_t *c)
hb_ensure_native_direction (c);
- _hb_normalize (c);
+ if (_hb_normalize (c))
+ /* Buffer contents changed, reset unicode_props */
+ hb_set_unicode_props (c); /* BUFFER: Set general_category and combining_class in var1 */
hb_ot_shape_setup_masks (c); /* BUFFER: Clobbers var2 */
More information about the HarfBuzz
mailing list