[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue Nov 13 14:48:36 PST 2012
src/hb-buffer-private.hh | 2 +
src/hb-buffer.cc | 33 +++++++++++++++++++++++++++++++
src/hb-buffer.h | 17 ++++++++++++++++
src/hb-ot-shape-complex-arabic.cc | 40 +++++++++++++++++++-------------------
src/hb-ot-shape.cc | 9 +++++---
src/hb-shape.cc | 2 -
test/api/test-buffer.c | 31 ++++++++++++++++++++++++++++-
test/api/test-object.c | 2 -
8 files changed, 111 insertions(+), 25 deletions(-)
New commits:
commit 0c7df2222862122ebbdc8665a21d6771ef5e0252
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 14:42:35 2012 -0800
Add buffer flags
New API:
hb_buffer_flags_t
HB_BUFFER_FLAGS_DEFAULT
HB_BUFFER_FLAG_BOT
HB_BUFFER_FLAG_EOT
HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES
hb_buffer_set_flags()
hb_buffer_get_flags()
We use the BOT flag to decide whether to insert dottedcircle if the
first char in the buffer is a combining mark.
The PRESERVE_DEFAULT_IGNORABLES flag prevents removal of characters like
ZWNJ/ZWJ/...
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index 4e92fb5..6cfb115 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -89,6 +89,7 @@ struct hb_buffer_t {
hb_unicode_funcs_t *unicode; /* Unicode functions */
hb_segment_properties_t props; /* Script, language, direction */
+ hb_buffer_flags_t flags; /* BOT / EOT / etc. */
/* Buffer contents */
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 6aff7b9..b770144 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -153,6 +153,7 @@ hb_buffer_t::clear (void)
hb_segment_properties_t default_props = _HB_BUFFER_PROPS_DEFAULT;
props = default_props;
+ flags = HB_BUFFER_FLAGS_DEFAULT;
content_type = HB_BUFFER_CONTENT_TYPE_INVALID;
in_error = false;
@@ -590,6 +591,7 @@ hb_buffer_get_empty (void)
const_cast<hb_unicode_funcs_t *> (&_hb_unicode_funcs_nil),
_HB_BUFFER_PROPS_DEFAULT,
+ HB_BUFFER_FLAGS_DEFAULT,
HB_BUFFER_CONTENT_TYPE_INVALID,
true, /* in_error */
@@ -724,6 +726,22 @@ hb_buffer_get_language (hb_buffer_t *buffer)
return buffer->props.language;
}
+void
+hb_buffer_set_flags (hb_buffer_t *buffer,
+ hb_buffer_flags_t flags)
+{
+ if (unlikely (hb_object_is_inert (buffer)))
+ return;
+
+ buffer->flags = flags;
+}
+
+hb_buffer_flags_t
+hb_buffer_get_flags (hb_buffer_t *buffer)
+{
+ return buffer->flags;
+}
+
void
hb_buffer_reset (hb_buffer_t *buffer)
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index fbd809c..533bac8 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -68,6 +68,12 @@ typedef enum {
HB_BUFFER_CONTENT_TYPE_GLYPHS
} hb_buffer_content_type_t;
+typedef enum {
+ HB_BUFFER_FLAGS_DEFAULT = 0x00000000,
+ HB_BUFFER_FLAG_BOT = 0x00000001, /* Beginning-of-text */
+ HB_BUFFER_FLAG_EOT = 0x00000002, /* End-of-text */
+ HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES = 0x00000004
+} hb_buffer_flags_t;
hb_buffer_t *
hb_buffer_create (void);
@@ -129,6 +135,13 @@ hb_buffer_set_language (hb_buffer_t *buffer,
hb_language_t
hb_buffer_get_language (hb_buffer_t *buffer);
+void
+hb_buffer_set_flags (hb_buffer_t *buffer,
+ hb_buffer_flags_t flags);
+
+hb_buffer_flags_t
+hb_buffer_get_flags (hb_buffer_t *buffer);
+
/* Resets the buffer. Afterwards it's as if it was just created,
* except that it has a larger buffer allocated perhaps... */
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index cba7933..59c9716 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -250,17 +250,18 @@ arabic_joining (hb_buffer_t *buffer)
HB_BUFFER_ALLOCATE_VAR (buffer, arabic_shaping_action);
/* Check pre-context */
- for (unsigned int i = 0; i < buffer->context_len[0]; i++)
- {
- unsigned int this_type = get_joining_type (buffer->context[0][i], buffer->unicode->general_category (buffer->context[0][i]));
+ if (!(buffer->flags & HB_BUFFER_FLAG_BOT))
+ for (unsigned int i = 0; i < buffer->context_len[0]; i++)
+ {
+ unsigned int this_type = get_joining_type (buffer->context[0][i], buffer->unicode->general_category (buffer->context[0][i]));
- if (unlikely (this_type == JOINING_TYPE_T))
- continue;
+ if (unlikely (this_type == JOINING_TYPE_T))
+ continue;
- const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
- state = entry->next_state;
- break;
- }
+ const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
+ state = entry->next_state;
+ break;
+ }
for (unsigned int i = 0; i < count; i++)
{
@@ -282,18 +283,19 @@ arabic_joining (hb_buffer_t *buffer)
state = entry->next_state;
}
- for (unsigned int i = 0; i < buffer->context_len[1]; i++)
- {
- unsigned int this_type = get_joining_type (buffer->context[1][i], buffer->unicode->general_category (buffer->context[0][i]));
+ if (!(buffer->flags & HB_BUFFER_FLAG_EOT))
+ for (unsigned int i = 0; i < buffer->context_len[1]; i++)
+ {
+ unsigned int this_type = get_joining_type (buffer->context[1][i], buffer->unicode->general_category (buffer->context[0][i]));
- if (unlikely (this_type == JOINING_TYPE_T))
- continue;
+ if (unlikely (this_type == JOINING_TYPE_T))
+ continue;
- const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
- if (entry->prev_action != NONE && prev != (unsigned int) -1)
- buffer->info[prev].arabic_shaping_action() = entry->prev_action;
- break;
- }
+ const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
+ if (entry->prev_action != NONE && prev != (unsigned int) -1)
+ buffer->info[prev].arabic_shaping_action() = entry->prev_action;
+ break;
+ }
HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 26ec4db..634fe6f 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -237,7 +237,7 @@ hb_set_unicode_props (hb_buffer_t *buffer)
static void
hb_insert_dotted_circle (hb_buffer_t *buffer, hb_font_t *font)
{
- if (buffer->context_len[0] ||
+ if (!(buffer->flags & HB_BUFFER_FLAG_BOT) ||
_hb_glyph_info_get_general_category (&buffer->info[0]) !=
HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)
return;
@@ -509,8 +509,11 @@ hb_ot_position (hb_ot_shape_context_t *c)
/* Post-process */
static void
-hb_ot_hide_zerowidth (hb_ot_shape_context_t *c)
+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;
unsigned int count = c->buffer->len;
@@ -554,7 +557,7 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c)
hb_ot_substitute (c);
hb_ot_position (c);
- hb_ot_hide_zerowidth (c);
+ hb_ot_hide_default_ignorables (c);
HB_BUFFER_DEALLOCATE_VAR (c->buffer, unicode_props1);
HB_BUFFER_DEALLOCATE_VAR (c->buffer, unicode_props0);
diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c
index 7cc99bd..51b2277 100644
--- a/test/api/test-buffer.c
+++ b/test/api/test-buffer.c
@@ -110,6 +110,7 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
+ g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
/* test property changes are retained */
@@ -127,6 +128,9 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
hb_buffer_set_language (b, hb_language_from_string ("fa", -1));
g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
+ hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT);
+ g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT);
+
/* test clear clears all properties but unicode_funcs */
@@ -137,6 +141,7 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
+ g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
/* test reset clears all properties */
@@ -150,12 +155,16 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
hb_buffer_set_language (b, hb_language_from_string ("fa", -1));
g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
+ hb_buffer_set_flags (b, HB_BUFFER_FLAG_BOT);
+ g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAG_BOT);
+
hb_buffer_reset (b);
g_assert (hb_buffer_get_unicode_funcs (b) == hb_unicode_funcs_get_default ());
g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (b) == NULL);
+ g_assert (hb_buffer_get_flags (b) == HB_BUFFER_FLAGS_DEFAULT);
}
static void
commit 1c7e55511a870f2689680ca8f977e00879f3b3e3
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 14:42:22 2012 -0800
Minor fix
Ouch
diff --git a/src/hb-shape.cc b/src/hb-shape.cc
index 4d64823..7dfe049 100644
--- a/src/hb-shape.cc
+++ b/src/hb-shape.cc
@@ -176,7 +176,7 @@ hb_feature_to_string (hb_feature_t *feature,
len += 4;
while (len && s[len - 1] == ' ')
len--;
- if (feature->start != 0 || feature->start != (unsigned int) -1)
+ if (feature->start != 0 || feature->end != (unsigned int) -1)
{
s[len++] = '[';
if (feature->start)
commit c8d4f8b0fe56ce909e3ca07f8a30cb4fb940868b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 14:10:19 2012 -0800
Minor
diff --git a/test/api/test-object.c b/test/api/test-object.c
index 66e8d33..ae4d1cc 100644
--- a/test/api/test-object.c
+++ b/test/api/test-object.c
@@ -219,7 +219,7 @@ test_object (void)
for (i = 0; i < G_N_ELEMENTS (objects); i++) {
const object_t *o = &objects[i];
void *obj;
- hb_user_data_key_t key[2];
+ hb_user_data_key_t key[1001];
{
unsigned int j;
commit 82ecaff736e245e117d70b6ec1497508c6eb08d2
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 13 13:57:52 2012 -0800
Add hb_buffer_clear()
Which is like _reset(), but does NOT clear unicode-funcs.
diff --git a/src/hb-buffer-private.hh b/src/hb-buffer-private.hh
index c1acffd..4e92fb5 100644
--- a/src/hb-buffer-private.hh
+++ b/src/hb-buffer-private.hh
@@ -133,6 +133,7 @@ struct hb_buffer_t {
/* Methods */
HB_INTERNAL void reset (void);
+ HB_INTERNAL void clear (void);
inline unsigned int backtrack_len (void) const
{ return have_output? out_len : idx; }
diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 06b5c05..6aff7b9 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -142,6 +142,15 @@ hb_buffer_t::reset (void)
hb_unicode_funcs_destroy (unicode);
unicode = hb_unicode_funcs_get_default ();
+ clear ();
+}
+
+void
+hb_buffer_t::clear (void)
+{
+ if (unlikely (hb_object_is_inert (this)))
+ return;
+
hb_segment_properties_t default_props = _HB_BUFFER_PROPS_DEFAULT;
props = default_props;
@@ -722,6 +731,12 @@ hb_buffer_reset (hb_buffer_t *buffer)
buffer->reset ();
}
+void
+hb_buffer_clear (hb_buffer_t *buffer)
+{
+ buffer->clear ();
+}
+
hb_bool_t
hb_buffer_pre_allocate (hb_buffer_t *buffer, unsigned int size)
{
diff --git a/src/hb-buffer.h b/src/hb-buffer.h
index dc63d1b..fbd809c 100644
--- a/src/hb-buffer.h
+++ b/src/hb-buffer.h
@@ -135,6 +135,10 @@ hb_buffer_get_language (hb_buffer_t *buffer);
void
hb_buffer_reset (hb_buffer_t *buffer);
+/* Like reset, but does NOT clear unicode_funcs. */
+void
+hb_buffer_clear (hb_buffer_t *buffer);
+
/* Returns false if allocation failed */
hb_bool_t
hb_buffer_pre_allocate (hb_buffer_t *buffer,
diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c
index 1ddc3d8..7cc99bd 100644
--- a/test/api/test-buffer.c
+++ b/test/api/test-buffer.c
@@ -128,7 +128,27 @@ test_buffer_properties (fixture_t *fixture, gconstpointer user_data)
g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
- /* test reset clears properties */
+
+ /* test clear clears all properties but unicode_funcs */
+
+ hb_buffer_clear (b);
+
+ g_assert (hb_buffer_get_unicode_funcs (b) == ufuncs);
+ g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_INVALID);
+ g_assert (hb_buffer_get_script (b) == HB_SCRIPT_INVALID);
+ g_assert (hb_buffer_get_language (b) == NULL);
+
+
+ /* test reset clears all properties */
+
+ hb_buffer_set_direction (b, HB_DIRECTION_RTL);
+ g_assert (hb_buffer_get_direction (b) == HB_DIRECTION_RTL);
+
+ hb_buffer_set_script (b, HB_SCRIPT_ARABIC);
+ g_assert (hb_buffer_get_script (b) == HB_SCRIPT_ARABIC);
+
+ hb_buffer_set_language (b, hb_language_from_string ("fa", -1));
+ g_assert (hb_buffer_get_language (b) == hb_language_from_string ("Fa", -1));
hb_buffer_reset (b);
More information about the HarfBuzz
mailing list