}
static void
-setup_masks_arabic (const hb_ot_shape_plan_t *plan,
- hb_buffer_t *buffer,
- hb_font_t *font)
+arabic_joining (hb_buffer_t *buffer)
{
- const arabic_shape_plan_t *arabic_plan = (const arabic_shape_plan_t *) plan->data;
-
unsigned int count = buffer->len;
unsigned int prev = 0, state = 0;
state = entry->next_state;
}
- if (likely (!arabic_plan->do_fallback)) {
- /* Has OpenType tables */
- for (unsigned int i = 0; i < count; i++)
- buffer->info[i].mask |= arabic_plan->mask_array[buffer->info[i].arabic_shaping_action()];
- } else
+ HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
+}
+
+static void
+preprocess_text_arabic (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t *buffer,
+ hb_font_t *font)
+{
+ const arabic_shape_plan_t *arabic_plan = (const arabic_shape_plan_t *) plan->data;
+
+ if (unlikely (arabic_plan->do_fallback))
+ {
+ arabic_joining (buffer);
arabic_fallback_shape (font, buffer);
+ }
+}
- HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
+static void
+setup_masks_arabic (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t *buffer,
+ hb_font_t *font)
+{
+ const arabic_shape_plan_t *arabic_plan = (const arabic_shape_plan_t *) plan->data;
+
+ if (likely (!arabic_plan->do_fallback))
+ {
+ arabic_joining (buffer);
+ unsigned int count = buffer->len;
+ for (unsigned int i = 0; i < count; i++)
+ buffer->info[i].mask |= arabic_plan->mask_array[buffer->info[i].arabic_shaping_action()];
+ }
}
const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic =
NULL, /* override_features */
data_create_arabic,
data_destroy_arabic,
+ preprocess_text_arabic,
NULL, /* normalization_preference */
setup_masks_arabic,
true, /* zero_width_attached_marks */
override_features_indic,
data_create_indic,
data_destroy_indic,
+ NULL, /* preprocess_text */
NULL, /* normalization_preference */
setup_masks_indic,
false, /* zero_width_attached_marks */
/*
- * Copyright © 2010 Google, Inc.
+ * Copyright © 2010,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
NULL, /* override_features */
NULL, /* data_create */
NULL, /* data_destroy */
+ NULL, /* preprocess_text */
normalization_preference_default,
NULL, /* setup_masks */
true, /* zero_width_attached_marks */
/* Thai / Lao shaper */
static void
-setup_masks_thai (const hb_ot_shape_plan_t *plan HB_UNUSED,
- hb_buffer_t *buffer,
- hb_font_t *font HB_UNUSED)
+preprocess_text_thai (const hb_ot_shape_plan_t *plan HB_UNUSED,
+ hb_buffer_t *buffer,
+ hb_font_t *font HB_UNUSED)
{
/* The following is NOT specified in the MS OT Thai spec, however, it seems
* to be what Uniscribe and other engines implement. According to Eric Muller:
NULL, /* override_features */
NULL, /* data_create */
NULL, /* data_destroy */
+ preprocess_text_thai,
NULL, /* normalization_preference */
- setup_masks_thai,
+ NULL, /* setup_masks */
true, /* zero_width_attached_marks */
};
/* collect_features()
* Called during shape_plan().
* Shapers should use plan->map to add their features and callbacks.
- * May be NULL.
*/
void (*collect_features) (hb_ot_shape_planner_t *plan);
* Called during shape_plan().
* Shapers should use plan->map to override features and add callbacks after
* common features are added.
- * May be NULL.
*/
void (*override_features) (hb_ot_shape_planner_t *plan);
* Called at the end of shape_plan().
* Whatever shapers return will be accessible through plan->data later.
* If NULL is returned, means a plan failure.
- * May be NULL. */
+ */
void *(*data_create) (const hb_ot_shape_plan_t *plan);
/* data_destroy()
* May be NULL. */
void (*data_destroy) (void *data);
+
+ /* preprocess_text()
+ * Called during shape().
+ * Shapers can use to modify text before shaping starts.
+ */
+ void (*preprocess_text) (const hb_ot_shape_plan_t *plan,
+ hb_buffer_t *buffer,
+ hb_font_t *font);
+
+
/* normalization_preference()
* Called during shape().
*/
/* setup_masks()
* Called during shape().
* Shapers should use map to get feature masks and set on buffer.
+ * Shapers may NOT modify characters.
*/
void (*setup_masks) (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
static inline void
hb_ot_substitute_default (hb_ot_shape_context_t *c)
{
+ if (c->plan->shaper->preprocess_text)
+ c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font);
+
hb_ot_mirror_chars (c);
HB_BUFFER_ALLOCATE_VAR (c->buffer, glyph_index);