From 136863371c1402769426d892aef1b92f9ca1a25e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 5 Nov 2015 13:24:15 -0800 Subject: [PATCH] Add new shaper method postprocess_glyphs() Unused currently. To be used for Syriac stretch implementation. https://github.com/behdad/harfbuzz/issues/141 --- src/hb-ot-shape-complex-arabic.cc | 3 ++- src/hb-ot-shape-complex-default.cc | 1 + src/hb-ot-shape-complex-hangul.cc | 7 ++++--- src/hb-ot-shape-complex-hebrew.cc | 1 + src/hb-ot-shape-complex-indic.cc | 1 + src/hb-ot-shape-complex-myanmar.cc | 2 ++ src/hb-ot-shape-complex-private.hh | 9 +++++++++ src/hb-ot-shape-complex-thai.cc | 1 + src/hb-ot-shape-complex-tibetan.cc | 1 + src/hb-ot-shape-complex-use.cc | 1 + src/hb-ot-shape.cc | 9 ++++++--- 11 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index cde02e0a5..c36db4698 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -379,7 +379,8 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic = NULL, /* override_features */ data_create_arabic, data_destroy_arabic, - NULL, /* preprocess_text_arabic */ + NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, NULL, /* decompose */ NULL, /* compose */ diff --git a/src/hb-ot-shape-complex-default.cc b/src/hb-ot-shape-complex-default.cc index f7f097eed..1e441fa55 100644 --- a/src/hb-ot-shape-complex-default.cc +++ b/src/hb-ot-shape-complex-default.cc @@ -35,6 +35,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default = NULL, /* data_create */ NULL, /* data_destroy */ NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, NULL, /* decompose */ NULL, /* compose */ diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc index 1fa79ce6d..e453a716a 100644 --- a/src/hb-ot-shape-complex-hangul.cc +++ b/src/hb-ot-shape-complex-hangul.cc @@ -411,13 +411,14 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul = "hangul", collect_features_hangul, override_features_hangul, - data_create_hangul, /* data_create */ - data_destroy_hangul, /* data_destroy */ + data_create_hangul, + data_destroy_hangul, preprocess_text_hangul, + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_NONE, NULL, /* decompose */ NULL, /* compose */ - setup_masks_hangul, /* setup_masks */ + setup_masks_hangul, HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, false, /* fallback_position */ }; diff --git a/src/hb-ot-shape-complex-hebrew.cc b/src/hb-ot-shape-complex-hebrew.cc index c7b7a5eba..62825fa86 100644 --- a/src/hb-ot-shape-complex-hebrew.cc +++ b/src/hb-ot-shape-complex-hebrew.cc @@ -163,6 +163,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = NULL, /* data_create */ NULL, /* data_destroy */ NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, NULL, /* decompose */ compose_hebrew, diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index 44481dbb4..166cd275e 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1834,6 +1834,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic = data_create_indic, data_destroy_indic, NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, decompose_indic, compose_indic, diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index 7f74f2df8..00368d8e4 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -507,6 +507,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_old = NULL, /* data_create */ NULL, /* data_destroy */ NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, NULL, /* decompose */ NULL, /* compose */ @@ -523,6 +524,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar = NULL, /* data_create */ NULL, /* data_destroy */ NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, NULL, /* decompose */ NULL, /* compose */ diff --git a/src/hb-ot-shape-complex-private.hh b/src/hb-ot-shape-complex-private.hh index 8d03dee51..80de4f316 100644 --- a/src/hb-ot-shape-complex-private.hh +++ b/src/hb-ot-shape-complex-private.hh @@ -110,6 +110,15 @@ struct hb_ot_complex_shaper_t hb_buffer_t *buffer, hb_font_t *font); + /* postprocess_glyphs() + * Called during shape(). + * Shapers can use to modify glyphs after shaping ends. + * May be NULL. + */ + void (*postprocess_glyphs) (const hb_ot_shape_plan_t *plan, + hb_buffer_t *buffer, + hb_font_t *font); + hb_ot_shape_normalization_mode_t normalization_preference; diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc index 51a1a1059..ee55055b9 100644 --- a/src/hb-ot-shape-complex-thai.cc +++ b/src/hb-ot-shape-complex-thai.cc @@ -372,6 +372,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai = NULL, /* data_create */ NULL, /* data_destroy */ preprocess_text_thai, + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, NULL, /* decompose */ NULL, /* compose */ diff --git a/src/hb-ot-shape-complex-tibetan.cc b/src/hb-ot-shape-complex-tibetan.cc index 01465a426..9f09287f6 100644 --- a/src/hb-ot-shape-complex-tibetan.cc +++ b/src/hb-ot-shape-complex-tibetan.cc @@ -52,6 +52,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_tibetan = NULL, /* data_create */ NULL, /* data_destroy */ NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT, NULL, /* decompose */ NULL, /* compose */ diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 779a9cb1d..cc01fd38e 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -576,6 +576,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_use = data_create_use, data_destroy_use, NULL, /* preprocess_text */ + NULL, /* postprocess_glyphs */ HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, NULL, /* decompose */ compose_use, diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 36b1297dd..c4c1c7f9a 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -553,9 +553,6 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c) { hb_buffer_t *buffer = c->buffer; - if (c->plan->shaper->preprocess_text) - c->plan->shaper->preprocess_text (c->plan, buffer, c->font); - hb_ot_shape_initialize_masks (c); hb_ot_mirror_chars (c); @@ -815,11 +812,17 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) hb_ensure_native_direction (c->buffer); + if (c->plan->shaper->preprocess_text) + c->plan->shaper->preprocess_text (c->plan, c->buffer, c->font); + hb_ot_substitute (c); hb_ot_position (c); hb_ot_hide_default_ignorables (c); + if (c->plan->shaper->postprocess_glyphs) + c->plan->shaper->postprocess_glyphs (c->plan, c->buffer, c->font); + _hb_buffer_deallocate_unicode_vars (c->buffer); c->buffer->props.direction = c->target_direction;