| Index: third_party/harfbuzz-ng/src/hb-ot-shape-complex-arabic.cc
|
| diff --git a/third_party/harfbuzz-ng/src/hb-ot-shape-complex-arabic.cc b/third_party/harfbuzz-ng/src/hb-ot-shape-complex-arabic.cc
|
| index 77a9c8230a918f4de40e46a07e9584395675adbd..2b863ef29215f2b4b5cc8c05bfd45a170e439060 100644
|
| --- a/third_party/harfbuzz-ng/src/hb-ot-shape-complex-arabic.cc
|
| +++ b/third_party/harfbuzz-ng/src/hb-ot-shape-complex-arabic.cc
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (C) 2010 Google, Inc.
|
| + * Copyright © 2010 Google, Inc.
|
| *
|
| * This is part of HarfBuzz, a text shaping library.
|
| *
|
| @@ -26,11 +26,10 @@
|
|
|
| #include "hb-ot-shape-complex-private.hh"
|
|
|
| -HB_BEGIN_DECLS
|
|
|
|
|
| /* buffer var allocations */
|
| -#define arabic_shaping_action() var2.u32 /* arabic shaping action */
|
| +#define arabic_shaping_action() complex_var_temporary_u16() /* arabic shaping action */
|
|
|
|
|
| /*
|
| @@ -55,31 +54,31 @@ enum {
|
| * Joining types:
|
| */
|
|
|
| -#include "hb-ot-shape-complex-arabic-table.h"
|
| +#include "hb-ot-shape-complex-arabic-table.hh"
|
|
|
| -static unsigned int get_joining_type (hb_codepoint_t u, hb_category_t gen_cat)
|
| +static unsigned int get_joining_type (hb_codepoint_t u, hb_unicode_general_category_t gen_cat)
|
| {
|
| /* TODO Macroize the magic bit operations */
|
|
|
| - if (likely (JOINING_TABLE_FIRST <= u && u <= JOINING_TABLE_LAST)) {
|
| + if (likely (hb_in_range<hb_codepoint_t> (u, JOINING_TABLE_FIRST, JOINING_TABLE_LAST))) {
|
| unsigned int j_type = joining_table[u - JOINING_TABLE_FIRST];
|
| if (likely (j_type != JOINING_TYPE_X))
|
| return j_type;
|
| }
|
|
|
| /* Mongolian joining data is not in ArabicJoining.txt yet */
|
| - if (unlikely (0x1800 <= u && u <= 0x18AF))
|
| + if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x1800, 0x18AF)))
|
| {
|
| /* All letters, SIBE SYLLABLE BOUNDARY MARKER, and NIRUGU are D */
|
| - if (gen_cat == HB_CATEGORY_OTHER_LETTER || u == 0x1807 || u == 0x180A)
|
| + if (gen_cat == HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER || u == 0x1807 || u == 0x180A)
|
| return JOINING_TYPE_D;
|
| }
|
|
|
| - if (unlikely ((u & ~(0x200C^0x200D)) == 0x200C)) {
|
| + if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x200C, 0x200D))) {
|
| return u == 0x200C ? JOINING_TYPE_U : JOINING_TYPE_C;
|
| }
|
|
|
| - return ((1<<gen_cat) & ((1<<HB_CATEGORY_NON_SPACING_MARK)|(1<<HB_CATEGORY_ENCLOSING_MARK)|(1<<HB_CATEGORY_FORMAT))) ?
|
| + return (FLAG(gen_cat) & (FLAG(HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) | FLAG(HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) | FLAG(HB_UNICODE_GENERAL_CATEGORY_FORMAT))) ?
|
| JOINING_TYPE_T : JOINING_TYPE_U;
|
| }
|
|
|
| @@ -121,8 +120,7 @@ enum {
|
| static const struct arabic_state_table_entry {
|
| uint8_t prev_action;
|
| uint8_t curr_action;
|
| - uint8_t next_state;
|
| - uint8_t padding;
|
| + uint16_t next_state;
|
| } arabic_state_table[][NUM_STATE_MACHINE_COLS] =
|
| {
|
| /* jt_U, jt_R, jt_D, jg_ALAPH, jg_DALATH_RISH */
|
| @@ -152,47 +150,82 @@ static const struct arabic_state_table_entry {
|
|
|
|
|
| void
|
| -_hb_ot_shape_complex_collect_features_arabic (hb_ot_shape_plan_t *plan, const hb_segment_properties_t *props)
|
| +_hb_ot_shape_complex_collect_features_arabic (hb_ot_map_builder_t *map, const hb_segment_properties_t *props)
|
| {
|
| + /* For Language forms (in ArabicOT speak), we do the iso/fina/medi/init together,
|
| + * then rlig and calt each in their own stage. This makes IranNastaliq's ALLAH
|
| + * ligature work correctly. It's unfortunate though...
|
| + *
|
| + * This also makes Arial Bold in Windows7 work. See:
|
| + * https://bugzilla.mozilla.org/show_bug.cgi?id=644184
|
| + *
|
| + * TODO: Add test cases for these two.
|
| + */
|
| +
|
| + map->add_bool_feature (HB_TAG('c','c','m','p'));
|
| + map->add_bool_feature (HB_TAG('l','o','c','l'));
|
| +
|
| + map->add_gsub_pause (NULL, NULL);
|
| +
|
| unsigned int num_features = props->script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
| for (unsigned int i = 0; i < num_features; i++)
|
| - plan->map.add_bool_feature (arabic_syriac_features[i], false);
|
| + map->add_bool_feature (arabic_syriac_features[i], false);
|
| +
|
| + map->add_gsub_pause (NULL, NULL);
|
| +
|
| + map->add_bool_feature (HB_TAG('r','l','i','g'));
|
| + map->add_gsub_pause (NULL, NULL);
|
| +
|
| + map->add_bool_feature (HB_TAG('c','a','l','t'));
|
| + map->add_gsub_pause (NULL, NULL);
|
| +
|
| + /* ArabicOT spec enables 'cswh' for Arabic where as for basic shaper it's disabled by default. */
|
| + map->add_bool_feature (HB_TAG('c','s','w','h'));
|
| +}
|
| +
|
| +bool
|
| +_hb_ot_shape_complex_prefer_decomposed_arabic (void)
|
| +{
|
| + return FALSE;
|
| }
|
|
|
| void
|
| -_hb_ot_shape_complex_setup_masks_arabic (hb_ot_shape_context_t *c)
|
| +_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer)
|
| {
|
| - unsigned int count = c->buffer->len;
|
| + unsigned int count = buffer->len;
|
| unsigned int prev = 0, state = 0;
|
|
|
| + HB_BUFFER_ALLOCATE_VAR (buffer, arabic_shaping_action);
|
| +
|
| for (unsigned int i = 0; i < count; i++)
|
| {
|
| - unsigned int this_type = get_joining_type (c->buffer->info[i].codepoint, (hb_category_t) c->buffer->info[i].general_category());
|
| + unsigned int this_type = get_joining_type (buffer->info[i].codepoint, (hb_unicode_general_category_t) buffer->info[i].general_category());
|
|
|
| if (unlikely (this_type == JOINING_TYPE_T)) {
|
| - c->buffer->info[i].arabic_shaping_action() = NONE;
|
| + buffer->info[i].arabic_shaping_action() = NONE;
|
| continue;
|
| }
|
|
|
| const arabic_state_table_entry *entry = &arabic_state_table[state][this_type];
|
|
|
| if (entry->prev_action != NONE)
|
| - c->buffer->info[prev].arabic_shaping_action() = entry->prev_action;
|
| + buffer->info[prev].arabic_shaping_action() = entry->prev_action;
|
|
|
| - c->buffer->info[i].arabic_shaping_action() = entry->curr_action;
|
| + buffer->info[i].arabic_shaping_action() = entry->curr_action;
|
|
|
| prev = i;
|
| state = entry->next_state;
|
| }
|
|
|
| hb_mask_t mask_array[TOTAL_NUM_FEATURES + 1] = {0};
|
| - unsigned int num_masks = c->buffer->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
| + unsigned int num_masks = buffer->props.script == HB_SCRIPT_SYRIAC ? SYRIAC_NUM_FEATURES : COMMON_NUM_FEATURES;
|
| for (unsigned int i = 0; i < num_masks; i++)
|
| - mask_array[i] = c->plan->map.get_1_mask (arabic_syriac_features[i]);
|
| + mask_array[i] = map->get_1_mask (arabic_syriac_features[i]);
|
|
|
| for (unsigned int i = 0; i < count; i++)
|
| - c->buffer->info[i].mask |= mask_array[c->buffer->info[i].arabic_shaping_action()];
|
| + buffer->info[i].mask |= mask_array[buffer->info[i].arabic_shaping_action()];
|
| +
|
| + HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
|
| }
|
|
|
|
|
| -HB_END_DECLS
|
|
|