.circleci/config.yml | 13 - src/check-symbols.sh | 2 src/hb-buffer.hh | 3 src/hb-font.cc | 2 src/hb-ot-face.cc | 20 +- src/hb-ot-face.hh | 78 ++++---- src/hb-ot-layout.hh | 12 - src/hb-ot-map.hh | 7 src/hb-ot-shape-complex-arabic.cc | 43 ---- src/hb-ot-shape-complex-default.cc | 2 src/hb-ot-shape-complex-hangul.cc | 2 src/hb-ot-shape-complex-hebrew.cc | 16 - src/hb-ot-shape-complex-indic.cc | 2 src/hb-ot-shape-complex-indic.hh | 2 src/hb-ot-shape-complex-khmer.cc | 2 src/hb-ot-shape-complex-myanmar.cc | 8 src/hb-ot-shape-complex-thai.cc | 2 src/hb-ot-shape-complex-tibetan.cc | 2 src/hb-ot-shape-complex-use.cc | 10 - src/hb-ot-shape-complex.hh | 12 - src/hb-ot-shape-fallback.cc | 2 src/hb-ot-shape-normalize.cc | 2 src/hb-ot-shape.cc | 92 ++++++---- src/hb-ot-shape.hh | 34 +-- src/sample.py | 6 test/api/test-buffer.c | 8 test/api/test-multithread.c | 3 test/fuzzing/main.cc | 22 -- test/fuzzing/run-shape-fuzzer-tests.py | 2 test/fuzzing/run-subset-fuzzer-tests.py | 2 test/shaping/data/in-house/Makefile.sources | 1 test/shaping/data/in-house/fonts/641ca9d7808b01cafa9a666c13811c9b56eb9c52.ttf |binary test/shaping/data/in-house/tests/arabic-mark-attach.tests | 1 33 files changed, 180 insertions(+), 235 deletions(-)
New commits: commit 0a371fee4d22ed63207aa76c00b05b75bbc95f5f Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 14:48:39 2018 +0200 Minor diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index 16a0c477..40b9921f 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -205,8 +205,10 @@ struct hb_ot_map_builder_t inline void add_feature (const hb_ot_map_feature_t &feat) { add_feature (feat.tag, feat.flags); } - inline void enable_feature (hb_tag_t tag) - { add_feature (tag, F_GLOBAL); } + inline void enable_feature (hb_tag_t tag, + hb_ot_map_feature_flags_t flags=F_NONE, + unsigned int value=1) + { add_feature (tag, F_GLOBAL | flags, value); } inline void disable_feature (hb_tag_t tag) { add_feature (tag, F_GLOBAL, 0); } diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 9893a22f..2cdd7ba8 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -215,14 +215,14 @@ collect_features_arabic (hb_ot_shape_planner_t *plan) * however, it says a ZWJ should also mean "don't ligate". So we run * the main ligating features as MANUAL_ZWJ. */ - map->add_feature (HB_TAG('r','l','i','g'), F_GLOBAL | F_MANUAL_ZWJ | F_HAS_FALLBACK); + map->enable_feature (HB_TAG('r','l','i','g'), F_MANUAL_ZWJ | F_HAS_FALLBACK); if (plan->props.script == HB_SCRIPT_ARABIC) map->add_gsub_pause (arabic_fallback_shape); /* No pause after rclt. See 98460779bae19e4d64d29461ff154b3527bf8420. */ - map->add_feature (HB_TAG('r','c','l','t'), F_GLOBAL | F_MANUAL_ZWJ); - map->add_feature (HB_TAG('c','a','l','t'), F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (HB_TAG('r','c','l','t'), F_MANUAL_ZWJ); + map->enable_feature (HB_TAG('c','a','l','t'), F_MANUAL_ZWJ); map->add_gsub_pause (nullptr); /* And undo here. */ diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index b0ca3c74..bebb8ec5 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -106,14 +106,14 @@ collect_features_myanmar (hb_ot_shape_planner_t *plan) for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++) { - map->add_feature (basic_features[i], F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (basic_features[i], F_MANUAL_ZWJ); map->add_gsub_pause (nullptr); } map->add_gsub_pause (final_reordering); for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++) - map->add_feature (other_features[i], F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (other_features[i], F_MANUAL_ZWJ); for (unsigned int i = 0; i < ARRAY_LENGTH (positioning_features); i++) map->enable_feature (positioning_features[i]); diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index bdcad409..f9a580ca 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -132,19 +132,19 @@ collect_features_use (hb_ot_shape_planner_t *plan) map->enable_feature (HB_TAG('l','o','c','l')); map->enable_feature (HB_TAG('c','c','m','p')); map->enable_feature (HB_TAG('n','u','k','t')); - map->add_feature (HB_TAG('a','k','h','n'), F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (HB_TAG('a','k','h','n'), F_MANUAL_ZWJ); /* "Reordering group" */ map->add_gsub_pause (clear_substitution_flags); map->add_feature (HB_TAG('r','p','h','f'), F_MANUAL_ZWJ); map->add_gsub_pause (record_rphf); map->add_gsub_pause (clear_substitution_flags); - map->add_feature (HB_TAG('p','r','e','f'), F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (HB_TAG('p','r','e','f'), F_MANUAL_ZWJ); map->add_gsub_pause (record_pref); /* "Orthographic unit shaping group" */ for (unsigned int i = 0; i < ARRAY_LENGTH (basic_features); i++) - map->add_feature (basic_features[i], F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (basic_features[i], F_MANUAL_ZWJ); map->add_gsub_pause (reorder); @@ -155,7 +155,7 @@ collect_features_use (hb_ot_shape_planner_t *plan) /* "Standard typographic presentation" */ for (unsigned int i = 0; i < ARRAY_LENGTH (other_features); i++) - map->add_feature (other_features[i], F_GLOBAL | F_MANUAL_ZWJ); + map->enable_feature (other_features[i], F_MANUAL_ZWJ); /* "Positional feature application" */ for (unsigned int i = 0; i < ARRAY_LENGTH (positioning_features); i++) diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 34434efe..dc88fa9b 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -125,7 +125,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, map->add_feature (HB_TAG ('d','n','o','m')); /* Random! */ - map->add_feature (HB_TAG ('r','a','n','d'), F_GLOBAL | F_RANDOM, HB_OT_MAP_MAX_VALUE); + map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE); if (planner->shaper->collect_features) planner->shaper->collect_features (planner); @@ -142,7 +142,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, * matter which script/langsys it is listed (or not) under. * See various bugs referenced from: * https://github.com/harfbuzz/harfbuzz/issues/63 */ - map->add_feature (HB_TAG ('v','e','r','t'), F_GLOBAL | F_GLOBAL_SEARCH); + map->enable_feature (HB_TAG ('v','e','r','t'), F_GLOBAL_SEARCH); } if (planner->shaper->override_features) commit 94d15528f80dbb7110d816fb5845f257f605a0be Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 14:45:09 2018 +0200 Minor diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index cc8b8d84..16a0c477 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -175,6 +175,7 @@ enum hb_ot_map_feature_flags_t F_MANUAL_ZWJ = 0x0008u, /* Don't skip over ZWJ when matching **input**. */ F_MANUAL_JOINERS = F_MANUAL_ZWNJ | F_MANUAL_ZWJ, F_GLOBAL_MANUAL_JOINERS= F_GLOBAL | F_MANUAL_JOINERS, + F_GLOBAL_HAS_FALLBACK = F_GLOBAL | F_HAS_FALLBACK, F_GLOBAL_SEARCH = 0x0010u, /* If feature not found in LangSys, look for it in global feature list and pick one. */ F_RANDOM = 0x0020u /* Randomly select a glyph from an AlternateSubstFormat1 subtable. */ }; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 9c941a3b..34434efe 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -70,24 +70,26 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, } -static hb_tag_t common_features[] = -{ - HB_TAG('c','c','m','p'), - HB_TAG('l','o','c','l'), - HB_TAG('m','a','r','k'), - HB_TAG('m','k','m','k'), - HB_TAG('r','l','i','g'), +static const hb_ot_map_feature_t +common_features[] = +{ + {HB_TAG('c','c','m','p'), F_GLOBAL}, + {HB_TAG('l','o','c','l'), F_GLOBAL}, + {HB_TAG('m','a','r','k'), F_GLOBAL_MANUAL_JOINERS}, + {HB_TAG('m','k','m','k'), F_GLOBAL_MANUAL_JOINERS}, + {HB_TAG('r','l','i','g'), F_GLOBAL}, }; -static hb_tag_t horizontal_features[] = +static const hb_ot_map_feature_t +horizontal_features[] = { - HB_TAG('c','a','l','t'), - HB_TAG('c','l','i','g'), - HB_TAG('c','u','r','s'), - HB_TAG('k','e','r','n'), - HB_TAG('l','i','g','a'), - HB_TAG('r','c','l','t'), + {HB_TAG('c','a','l','t'), F_GLOBAL}, + {HB_TAG('c','l','i','g'), F_GLOBAL}, + {HB_TAG('c','u','r','s'), F_GLOBAL}, + {HB_TAG('k','e','r','n'), F_GLOBAL_HAS_FALLBACK}, + {HB_TAG('l','i','g','a'), F_GLOBAL}, + {HB_TAG('r','c','l','t'), F_GLOBAL}, }; static void @@ -129,16 +131,11 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, planner->shaper->collect_features (planner); for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++) - map->add_feature (common_features[i], F_GLOBAL | - (common_features[i] == HB_TAG('m','a','r','k') || - common_features[i] == HB_TAG('m','k','m','k') ? - F_MANUAL_JOINERS : F_NONE)); + map->add_feature (common_features[i]); if (HB_DIRECTION_IS_HORIZONTAL (props->direction)) for (unsigned int i = 0; i < ARRAY_LENGTH (horizontal_features); i++) - map->add_feature (horizontal_features[i], F_GLOBAL | - (horizontal_features[i] == HB_TAG('k','e','r','n') ? - F_HAS_FALLBACK : F_NONE)); + map->add_feature (horizontal_features[i]); else { /* We really want to find a 'vert' feature if there's any in the font, no commit 729f634728fb553300021d52089495271dfb19fd Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 14:40:14 2018 +0200 Disable joiner-skipping when looking back for base to attach mark to Fixes https://github.com/harfbuzz/harfbuzz/issues/1189 diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index bcb5b72f..9c941a3b 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -129,7 +129,10 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, planner->shaper->collect_features (planner); for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++) - map->enable_feature (common_features[i]); + map->add_feature (common_features[i], F_GLOBAL | + (common_features[i] == HB_TAG('m','a','r','k') || + common_features[i] == HB_TAG('m','k','m','k') ? + F_MANUAL_JOINERS : F_NONE)); if (HB_DIRECTION_IS_HORIZONTAL (props->direction)) for (unsigned int i = 0; i < ARRAY_LENGTH (horizontal_features); i++) diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index e5cf77fd..a79ab041 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -2,6 +2,7 @@ TESTS = \ tests/arabic-fallback-shaping.tests \ tests/arabic-feature-order.tests \ tests/arabic-like-joining.tests \ + tests/arabic-mark-attach.tests \ tests/arabic-mark-order.tests \ tests/arabic-stch.tests \ tests/automatic-fractions.tests \ diff --git a/test/shaping/data/in-house/fonts/641ca9d7808b01cafa9a666c13811c9b56eb9c52.ttf b/test/shaping/data/in-house/fonts/641ca9d7808b01cafa9a666c13811c9b56eb9c52.ttf new file mode 100644 index 00000000..1328e13c Binary files /dev/null and b/test/shaping/data/in-house/fonts/641ca9d7808b01cafa9a666c13811c9b56eb9c52.ttf differ diff --git a/test/shaping/data/in-house/tests/arabic-mark-attach.tests b/test/shaping/data/in-house/tests/arabic-mark-attach.tests new file mode 100644 index 00000000..a577e51a --- /dev/null +++ b/test/shaping/data/in-house/tests/arabic-mark-attach.tests @@ -0,0 +1 @@ +../fonts/641ca9d7808b01cafa9a666c13811c9b56eb9c52.ttf::U+064A,U+0633,U+06E1,U+200D,U+0654,U+064E,U+0644:[afii57444.zz04=6+1091|afii57454=1@75,925+0|uni0654=1+0|space=1+0|uni06E1=1@950,1115+0|afii57427.zz03_calt=1+1847|afii57450.zz21=0+345] commit c36f3f5bef52e660541933f003fafa6e3a14785d Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 14:34:29 2018 +0200 [arabic] Use manual-zwj instead of flipping joiners diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 24d46400..bcaf066c 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -68,8 +68,7 @@ enum hb_buffer_scratch_flags_t { HB_BUFFER_SCRATCH_FLAG_HAS_SPACE_FALLBACK = 0x00000004u, HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, HB_BUFFER_SCRATCH_FLAG_HAS_UNSAFE_TO_BREAK = 0x00000010u, - HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS = 0x00000020u, - HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000040u, + HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000020u, /* Reserved for complex shapers' internal use. */ HB_BUFFER_SCRATCH_FLAG_COMPLEX0 = 0x01000000u, diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index d9b954f4..7a787b77 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -224,16 +224,8 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer) { buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_DEFAULT_IGNORABLES; props |= UPROPS_MASK_IGNORABLE; - if (u == 0x200Cu) - { - props |= UPROPS_MASK_Cf_ZWNJ; - buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS; - } - else if (u == 0x200Du) - { - props |= UPROPS_MASK_Cf_ZWJ; - buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS; - } + if (u == 0x200Cu) props |= UPROPS_MASK_Cf_ZWNJ; + else if (u == 0x200Du) props |= UPROPS_MASK_Cf_ZWJ; /* Mongolian Free Variation Selectors need to be remembered * because although we need to hide them like default-ignorables, * they need to non-ignorable during shaping. This is similar to diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index e4e1d5fa..9893a22f 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -159,11 +159,6 @@ static const struct arabic_state_table_entry { static void -flip_joiners (const hb_ot_shape_plan_t *plan, - hb_font_t *font, - hb_buffer_t *buffer); - -static void arabic_fallback_shape (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); @@ -217,28 +212,20 @@ collect_features_arabic (hb_ot_shape_planner_t *plan) } /* Normally, Unicode says a ZWNJ means "don't ligate". In Arabic script - * however, it says a ZWJ should also mean "don't ligate". So we convert - * a ZWJ to a ZWNJ for GSUB. We want to revert it back to ZWJ before - * GPOS processing though. So we just flip their roles, and flip back - * later. Note that this makes a ZWNJ into ZWJ for GSUB stage, which - * means it would *not* break ligatures. But since ligatures around - * ZWNJ are rare, we don't care. - * - * Since we don't currently have a way to apply a pause before GPOS - * starts, let's just do this dance around a few required GUSB features. */ - map->add_gsub_pause (flip_joiners); + * however, it says a ZWJ should also mean "don't ligate". So we run + * the main ligating features as MANUAL_ZWJ. */ - map->add_feature (HB_TAG('r','l','i','g'), F_GLOBAL | F_HAS_FALLBACK); + map->add_feature (HB_TAG('r','l','i','g'), F_GLOBAL | F_MANUAL_ZWJ | F_HAS_FALLBACK); if (plan->props.script == HB_SCRIPT_ARABIC) map->add_gsub_pause (arabic_fallback_shape); /* No pause after rclt. See 98460779bae19e4d64d29461ff154b3527bf8420. */ - map->enable_feature (HB_TAG('r','c','l','t')); - map->enable_feature (HB_TAG('c','a','l','t')); + map->add_feature (HB_TAG('r','c','l','t'), F_GLOBAL | F_MANUAL_ZWJ); + map->add_feature (HB_TAG('c','a','l','t'), F_GLOBAL | F_MANUAL_ZWJ); + map->add_gsub_pause (nullptr); /* And undo here. */ - map->add_gsub_pause (flip_joiners); /* The spec includes 'cswh'. Earlier versions of Windows * used to enable this by default, but testing suggests @@ -393,22 +380,6 @@ setup_masks_arabic (const hb_ot_shape_plan_t *plan, setup_masks_arabic_plan (arabic_plan, buffer, plan->props.script); } - -static void -flip_joiners (const hb_ot_shape_plan_t *plan HB_UNUSED, - hb_font_t *font HB_UNUSED, - hb_buffer_t *buffer) -{ - if (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_JOINERS)) - return; - - unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; - for (unsigned int i = 0; i < count; i++) - if (_hb_glyph_info_is_joiner (&info[i])) - _hb_glyph_info_flip_joiners (&info[i]); -} - static void arabic_fallback_shape (const hb_ot_shape_plan_t *plan, hb_font_t *font, commit 48c513fec978819927535bc86b43be74315f746c Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 14:17:42 2018 +0200 Minor diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index c4a695ab..e4e1d5fa 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -731,7 +731,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_arabic = nullptr, /* decompose */ nullptr, /* compose */ setup_masks_arabic, - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ reorder_marks_arabic, HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-default.cc b/src/hb-ot-shape-complex-default.cc index 45d5f434..97923ecf 100644 --- a/src/hb-ot-shape-complex-default.cc +++ b/src/hb-ot-shape-complex-default.cc @@ -39,7 +39,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default = nullptr, /* decompose */ nullptr, /* compose */ nullptr, /* setup_masks */ - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-hangul.cc b/src/hb-ot-shape-complex-hangul.cc index 96fd4267..0e7abadb 100644 --- a/src/hb-ot-shape-complex-hangul.cc +++ b/src/hb-ot-shape-complex-hangul.cc @@ -424,7 +424,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul = nullptr, /* decompose */ nullptr, /* compose */ setup_masks_hangul, - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ 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 ddb25ef2..90c36c02 100644 --- a/src/hb-ot-shape-complex-hebrew.cc +++ b/src/hb-ot-shape-complex-hebrew.cc @@ -154,18 +154,6 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c, return found; } -static bool -disable_otl_hebrew (const hb_ot_shape_plan_t *plan) -{ - /* For Hebrew shaper, use fallback if GPOS does not have 'hebr' - * script. This matches Uniscribe better, and makes fonts like - * Arial that have GSUB/GPOS/GDEF but no data for Hebrew work. - * See: - * https://github.com/harfbuzz/harfbuzz/issues/347#issuecomment-267838368 - */ - return plan->map.chosen_script[1] != HB_TAG ('h','e','b','r'); -} - const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = { @@ -179,7 +167,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hebrew = nullptr, /* decompose */ compose_hebrew, nullptr, /* setup_masks */ - disable_otl_hebrew, + HB_TAG ('h','e','b','r'), /* gpos_tag. https://github.com/harfbuzz/harfbuzz/issues/347#issuecomment-267838368 */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index e6c9ba8d..9824d756 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -1620,7 +1620,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_indic = decompose_indic, compose_indic, setup_masks_indic, - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, false, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-indic.hh b/src/hb-ot-shape-complex-indic.hh index b0f88e8b..dcc2a7a6 100644 --- a/src/hb-ot-shape-complex-indic.hh +++ b/src/hb-ot-shape-complex-indic.hh @@ -29,9 +29,7 @@ #include "hb.hh" - #include "hb-ot-shape-complex.hh" -#include "hb-ot-shape.hh" /* XXX Remove */ /* buffer var allocations */ diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc index 9c766be1..88d16267 100644 --- a/src/hb-ot-shape-complex-khmer.cc +++ b/src/hb-ot-shape-complex-khmer.cc @@ -496,7 +496,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_khmer = decompose_khmer, compose_khmer, setup_masks_khmer, - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE, false, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc index 532ebfdc..b0ca3c74 100644 --- a/src/hb-ot-shape-complex-myanmar.cc +++ b/src/hb-ot-shape-complex-myanmar.cc @@ -389,7 +389,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar_old = nullptr, /* decompose */ nullptr, /* compose */ nullptr, /* setup_masks */ - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ @@ -407,7 +407,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_myanmar = nullptr, /* decompose */ nullptr, /* compose */ setup_masks_myanmar, - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, false, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc index 1d18760e..34110684 100644 --- a/src/hb-ot-shape-complex-thai.cc +++ b/src/hb-ot-shape-complex-thai.cc @@ -376,7 +376,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_thai = nullptr, /* decompose */ nullptr, /* compose */ nullptr, /* setup_masks */ - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, false,/* fallback_position */ diff --git a/src/hb-ot-shape-complex-tibetan.cc b/src/hb-ot-shape-complex-tibetan.cc index 27c60b11..5d6dfeae 100644 --- a/src/hb-ot-shape-complex-tibetan.cc +++ b/src/hb-ot-shape-complex-tibetan.cc @@ -56,7 +56,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_tibetan = nullptr, /* decompose */ nullptr, /* compose */ nullptr, /* setup_masks */ - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE, true, /* fallback_position */ diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc index 929d60d9..bdcad409 100644 --- a/src/hb-ot-shape-complex-use.cc +++ b/src/hb-ot-shape-complex-use.cc @@ -597,7 +597,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_use = nullptr, /* decompose */ compose_use, setup_masks_use, - nullptr, /* disable_otl */ + HB_TAG_NONE, /* gpos_tag */ nullptr, /* reorder_marks */ HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_EARLY, false, /* fallback_position */ diff --git a/src/hb-ot-shape-complex.hh b/src/hb-ot-shape-complex.hh index e0be8d3c..c18f1b96 100644 --- a/src/hb-ot-shape-complex.hh +++ b/src/hb-ot-shape-complex.hh @@ -34,7 +34,6 @@ #include "hb-ot-shape-normalize.hh" - /* buffer var allocations, used by complex shapers */ #define complex_var_u8_0() var2.u8[2] #define complex_var_u8_1() var2.u8[3] @@ -148,13 +147,11 @@ struct hb_ot_complex_shaper_t hb_buffer_t *buffer, hb_font_t *font); - /* disable_otl() - * Called during shape(). - * If set and returns true, GDEF/GSUB/GPOS of the font are ignored - * and fallback operations used. - * May be nullptr. + /* gpos_tag() + * If not HB_TAG_NONE, then must match found GPOS script tag for + * GPOS to be applied. Otherwise, fallback positioning will be used. */ - bool (*disable_otl) (const hb_ot_shape_plan_t *plan); + hb_tag_t gpos_tag; /* reorder_marks() * Called during shape(). diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index df1b86fe..bcb5b72f 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -63,10 +63,10 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, plan.kerning_requested = !!plan.kern_mask; plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); - bool disable_otl = plan.shaper->disable_otl && plan.shaper->disable_otl (&plan); - //plan.fallback_substitute = disable_otl || !hb_ot_layout_has_substitution (face); - plan.fallback_positioning = disable_otl || !hb_ot_layout_has_positioning (face); - plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face); + bool disable_gpos = plan.shaper->gpos_tag && + plan.shaper->gpos_tag != plan.map.chosen_script[1]; + plan.fallback_positioning = disable_gpos || !hb_ot_layout_has_positioning (face); + plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face); } commit cca757ae56d6a82cfad35edc6dbae58049a34f91 Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 13:27:11 2018 +0200 Minor diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 4b7c2efa..df1b86fe 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -66,7 +66,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, bool disable_otl = plan.shaper->disable_otl && plan.shaper->disable_otl (&plan); //plan.fallback_substitute = disable_otl || !hb_ot_layout_has_substitution (face); plan.fallback_positioning = disable_otl || !hb_ot_layout_has_positioning (face); - plan.fallback_glyph_classes = disable_otl || !hb_ot_layout_has_glyph_classes (face); + plan.fallback_glyph_classes = !hb_ot_layout_has_glyph_classes (face); } @@ -652,7 +652,7 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c) hb_ot_layout_substitute_start (c->font, buffer); - if (!hb_ot_layout_has_glyph_classes (c->face)) + if (c->plan->fallback_glyph_classes) hb_synthesize_glyph_classes (c); c->plan->substitute (c->font, buffer); commit 96eca87f89588126d3fa5c7f3884ae2f302a91e1 Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 13:24:40 2018 +0200 Move things diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 7f4e442d..4b7c2efa 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -62,6 +62,11 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); plan.kerning_requested = !!plan.kern_mask; plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); + + bool disable_otl = plan.shaper->disable_otl && plan.shaper->disable_otl (&plan); + //plan.fallback_substitute = disable_otl || !hb_ot_layout_has_substitution (face); + plan.fallback_positioning = disable_otl || !hb_ot_layout_has_positioning (face); + plan.fallback_glyph_classes = disable_otl || !hb_ot_layout_has_glyph_classes (face); } @@ -257,8 +262,6 @@ struct hb_ot_shape_context_t unsigned int num_user_features; /* Transient stuff */ - bool fallback_positioning; - bool fallback_glyph_classes; hb_direction_t target_direction; }; @@ -634,7 +637,7 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c) hb_ot_shape_setup_masks (c); /* This is unfortunate to go here, but necessary... */ - if (c->fallback_positioning) + if (c->plan->fallback_positioning) _hb_ot_shape_fallback_position_recategorize_marks (c->plan, c->font, buffer); hb_ot_map_glyphs_fast (buffer); @@ -748,7 +751,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) * If fallback positinoing happens or GPOS is present, we don't * care. */ - bool adjust_offsets_when_zeroing = c->fallback_positioning && + bool adjust_offsets_when_zeroing = c->plan->fallback_positioning && !c->plan->shaper->fallback_position && HB_DIRECTION_IS_FORWARD (c->buffer->props.direction); @@ -775,7 +778,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) break; } - if (likely (!c->fallback_positioning)) + if (likely (!c->plan->fallback_positioning)) c->plan->position (c->font, c->buffer); switch (c->plan->shaper->zero_width_marks) @@ -812,7 +815,7 @@ hb_ot_position (hb_ot_shape_context_t *c) hb_ot_position_complex (c); - if (c->fallback_positioning && c->plan->shaper->fallback_position) + if (c->plan->fallback_positioning && c->plan->shaper->fallback_position) _hb_ot_shape_fallback_position (c->plan, c->font, c->buffer); if (HB_DIRECTION_IS_BACKWARD (c->buffer->props.direction)) @@ -820,7 +823,7 @@ hb_ot_position (hb_ot_shape_context_t *c) /* Visual fallback goes here. */ - if (c->fallback_positioning) + if (c->plan->fallback_positioning) _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer); _hb_buffer_deallocate_gsubgpos_vars (c->buffer); @@ -872,11 +875,6 @@ hb_ot_shape_internal (hb_ot_shape_context_t *c) (unsigned) HB_BUFFER_MAX_OPS_MIN); } - bool disable_otl = c->plan->shaper->disable_otl && c->plan->shaper->disable_otl (c->plan); - //c->fallback_substitute = disable_otl || !hb_ot_layout_has_substitution (c->face); - c->fallback_positioning = disable_otl || !hb_ot_layout_has_positioning (c->face); - c->fallback_glyph_classes = disable_otl || !hb_ot_layout_has_glyph_classes (c->face); - /* Save the original direction, we use it later. */ c->target_direction = c->buffer->props.direction; diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index 52e6b110..88c72dc1 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -42,9 +42,12 @@ struct hb_ot_shape_plan_t const void *data; hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; hb_mask_t kern_mask; + bool has_frac : 1; bool kerning_requested : 1; bool has_gpos_mark : 1; + bool fallback_positioning : 1; + bool fallback_glyph_classes : 1; inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const { commit 588a4ac8bc9fd20464c7a77ead27ae34478c9bc8 Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 13:13:47 2018 +0200 Rename diff --git a/src/hb-ot-face.cc b/src/hb-ot-face.cc index 388a5972..1bc68d36 100644 --- a/src/hb-ot-face.cc +++ b/src/hb-ot-face.cc @@ -40,19 +40,19 @@ void hb_ot_face_data_t::init0 (hb_face_t *face) { this->face = face; -#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 (); -#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type) - HB_OT_LAYOUT_TABLES -#undef HB_OT_LAYOUT_ACCELERATOR -#undef HB_OT_LAYOUT_TABLE +#define HB_OT_TABLE(Namespace, Type) Type.init0 (); +#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type) + HB_OT_TABLES +#undef HB_OT_ACCELERATOR +#undef HB_OT_TABLE } void hb_ot_face_data_t::fini (void) { -#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini (); -#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type) - HB_OT_LAYOUT_TABLES -#undef HB_OT_LAYOUT_ACCELERATOR -#undef HB_OT_LAYOUT_TABLE +#define HB_OT_TABLE(Namespace, Type) Type.fini (); +#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type) + HB_OT_TABLES +#undef HB_OT_ACCELERATOR +#undef HB_OT_TABLE } hb_ot_face_data_t * diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh index 5ac3538e..e3059221 100644 --- a/src/hb-ot-face.hh +++ b/src/hb-ot-face.hh @@ -43,66 +43,66 @@ /* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*. * This is as good as any place. */ -#define HB_OT_LAYOUT_TABLES \ +#define HB_OT_TABLES \ /* OpenType shaping. */ \ - HB_OT_LAYOUT_TABLE(OT, JSTF) \ - HB_OT_LAYOUT_TABLE(OT, BASE) \ + HB_OT_TABLE(OT, JSTF) \ + HB_OT_TABLE(OT, BASE) \ /* AAT shaping. */ \ - HB_OT_LAYOUT_TABLE(AAT, morx) \ - HB_OT_LAYOUT_TABLE(AAT, kerx) \ - HB_OT_LAYOUT_TABLE(AAT, ankr) \ - HB_OT_LAYOUT_TABLE(AAT, trak) \ + HB_OT_TABLE(AAT, morx) \ + HB_OT_TABLE(AAT, kerx) \ + HB_OT_TABLE(AAT, ankr) \ + HB_OT_TABLE(AAT, trak) \ /* OpenType variations. */ \ - HB_OT_LAYOUT_TABLE(OT, fvar) \ - HB_OT_LAYOUT_TABLE(OT, avar) \ - HB_OT_LAYOUT_TABLE(OT, MVAR) \ + HB_OT_TABLE(OT, fvar) \ + HB_OT_TABLE(OT, avar) \ + HB_OT_TABLE(OT, MVAR) \ /* OpenType math. */ \ - HB_OT_LAYOUT_TABLE(OT, MATH) \ + HB_OT_TABLE(OT, MATH) \ /* OpenType fundamentals. */ \ - HB_OT_LAYOUT_ACCELERATOR(OT, GDEF) \ - HB_OT_LAYOUT_ACCELERATOR(OT, GSUB) \ - HB_OT_LAYOUT_ACCELERATOR(OT, GPOS) \ - HB_OT_LAYOUT_ACCELERATOR(OT, cmap) \ - HB_OT_LAYOUT_ACCELERATOR(OT, hmtx) \ - HB_OT_LAYOUT_ACCELERATOR(OT, vmtx) \ - HB_OT_LAYOUT_ACCELERATOR(OT, post) \ - HB_OT_LAYOUT_ACCELERATOR(OT, kern) \ - HB_OT_LAYOUT_ACCELERATOR(OT, glyf) \ - HB_OT_LAYOUT_ACCELERATOR(OT, CBDT) \ + HB_OT_ACCELERATOR(OT, GDEF) \ + HB_OT_ACCELERATOR(OT, GSUB) \ + HB_OT_ACCELERATOR(OT, GPOS) \ + HB_OT_ACCELERATOR(OT, cmap) \ + HB_OT_ACCELERATOR(OT, hmtx) \ + HB_OT_ACCELERATOR(OT, vmtx) \ + HB_OT_ACCELERATOR(OT, post) \ + HB_OT_ACCELERATOR(OT, kern) \ + HB_OT_ACCELERATOR(OT, glyf) \ + HB_OT_ACCELERATOR(OT, CBDT) \ /* */ /* Declare tables. */ -#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } -#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type##_accelerator_t) -HB_OT_LAYOUT_TABLES -#undef HB_OT_LAYOUT_ACCELERATOR -#undef HB_OT_LAYOUT_TABLE +#define HB_OT_TABLE(Namespace, Type) namespace Namespace { struct Type; } +#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type##_accelerator_t) +HB_OT_TABLES +#undef HB_OT_ACCELERATOR +#undef HB_OT_TABLE struct hb_ot_face_data_t { HB_INTERNAL void init0 (hb_face_t *face); HB_INTERNAL void fini (void); -#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \ +#define HB_OT_TABLE_ORDER(Namespace, Type) \ HB_PASTE (ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type))) enum order_t { ORDER_ZERO, -#define HB_OT_LAYOUT_TABLE(Namespace, Type) HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), -#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) HB_OT_LAYOUT_TABLE (Namespace, Type) - HB_OT_LAYOUT_TABLES -#undef HB_OT_LAYOUT_ACCELERATOR -#undef HB_OT_LAYOUT_TABLE +#define HB_OT_TABLE(Namespace, Type) HB_OT_TABLE_ORDER (Namespace, Type), +#define HB_OT_ACCELERATOR(Namespace, Type) HB_OT_TABLE (Namespace, Type) + HB_OT_TABLES +#undef HB_OT_ACCELERATOR +#undef HB_OT_TABLE }; hb_face_t *face; /* MUST be JUST before the lazy loaders. */ -#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ - hb_table_lazy_loader_t<Namespace::Type, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type; -#define HB_OT_LAYOUT_ACCELERATOR(Namespace, Type) \ - hb_face_lazy_loader_t<Namespace::Type##_accelerator_t, HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type)> Type; - HB_OT_LAYOUT_TABLES -#undef HB_OT_LAYOUT_ACCELERATOR -#undef HB_OT_LAYOUT_TABLE +#define HB_OT_TABLE(Namespace, Type) \ + hb_table_lazy_loader_t<Namespace::Type, HB_OT_TABLE_ORDER (Namespace, Type)> Type; +#define HB_OT_ACCELERATOR(Namespace, Type) \ + hb_face_lazy_loader_t<Namespace::Type##_accelerator_t, HB_OT_TABLE_ORDER (Namespace, Type)> Type; + HB_OT_TABLES +#undef HB_OT_ACCELERATOR +#undef HB_OT_TABLE }; commit 10b6c7c63870fa04cd8adcf9f38644c2a799db8a Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 13:11:18 2018 +0200 Minor include cleanup diff --git a/src/hb-ot-shape-complex.hh b/src/hb-ot-shape-complex.hh index a48a38a2..e0be8d3c 100644 --- a/src/hb-ot-shape-complex.hh +++ b/src/hb-ot-shape-complex.hh @@ -29,6 +29,7 @@ #include "hb.hh" +#include "hb-ot-layout.hh" #include "hb-ot-shape.hh" #include "hb-ot-shape-normalize.hh" diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index f0e3c8be..7f4e442d 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -36,11 +36,9 @@ #include "hb-ot-shape-normalize.hh" #include "hb-ot-face.hh" -#include "hb-ot-layout.hh" -#include "hb-unicode.hh" + #include "hb-set.hh" -#include "hb-ot-layout-gsubgpos.hh" #include "hb-aat-layout.hh" diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index a6a315a4..52e6b110 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -30,7 +30,7 @@ #include "hb.hh" #include "hb-ot-map.hh" -#include "hb-ot-layout.hh" +#include "hb-shape-plan.hh" commit 1d1734e985e1f2a746b4fff0cd82d96d477577d5 Author: Behdad Esfahbod <[email protected]> Date: Tue Oct 2 13:04:05 2018 +0200 Shuffle code around diff --git a/src/hb-ot-shape-complex-hebrew.cc b/src/hb-ot-shape-complex-hebrew.cc index ba25258a..ddb25ef2 100644 --- a/src/hb-ot-shape-complex-hebrew.cc +++ b/src/hb-ot-shape-complex-hebrew.cc @@ -70,7 +70,7 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c, bool found = (bool) c->unicode->compose (a, b, ab); - if (!found && !c->plan->has_mark) + if (!found && !c->plan->has_gpos_mark) { /* Special-case Hebrew presentation forms that are excluded from * standard normalization, but wanted for old fonts. */ diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index f7409e8b..6673abd1 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -441,7 +441,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { - if (!plan->has_kern) return; + if (!plan->kerning_requested) return; OT::hb_ot_apply_context_t c (1, font, buffer); hb_mask_t kern_mask = plan->kern_mask; diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 2f0cba18..0e13707e 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -296,7 +296,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference; if (mode == HB_OT_SHAPE_NORMALIZATION_MODE_AUTO) { - if (plan->has_mark) + if (plan->has_gpos_mark) // https://github.com/harfbuzz/harfbuzz/issues/653#issuecomment-423905920 //mode = HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED; mode = HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 5404a5c3..f0e3c8be 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -43,7 +43,32 @@ #include "hb-ot-layout-gsubgpos.hh" #include "hb-aat-layout.hh" -static hb_tag_t common_features[] = { + +void +hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan, + const int *coords, + unsigned int num_coords) +{ + plan.props = props; + plan.shaper = shaper; + map.compile (plan.map, coords, num_coords); + + plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); + plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); + plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); + plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); + + plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? + HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); + + plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); + plan.kerning_requested = !!plan.kern_mask; + plan.has_gpos_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); +} + + +static hb_tag_t common_features[] = +{ HB_TAG('c','c','m','p'), HB_TAG('l','o','c','l'), HB_TAG('m','a','r','k'), @@ -52,7 +77,8 @@ static hb_tag_t common_features[] = { }; -static hb_tag_t horizontal_features[] = { +static hb_tag_t horizontal_features[] = +{ HB_TAG('c','a','l','t'), HB_TAG('c','l','i','g'), HB_TAG('c','u','r','s'), @@ -61,8 +87,6 @@ static hb_tag_t horizontal_features[] = { HB_TAG('r','c','l','t'), }; - - static void hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, const hb_segment_properties_t *props, diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index b3a490a3..a6a315a4 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -42,9 +42,9 @@ struct hb_ot_shape_plan_t const void *data; hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; hb_mask_t kern_mask; - unsigned int has_frac : 1; - unsigned int has_kern : 1; - unsigned int has_mark : 1; + bool has_frac : 1; + bool kerning_requested : 1; + bool has_gpos_mark : 1; inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const { @@ -83,26 +83,9 @@ struct hb_ot_shape_planner_t shaper (nullptr), map (face, &props) {} - inline void compile (hb_ot_shape_plan_t &plan, - const int *coords, - unsigned int num_coords) - { - plan.props = props; - plan.shaper = shaper; - map.compile (plan.map, coords, num_coords); - - plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); - plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); - plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); - plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); - - plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? - HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); - - plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); - plan.has_kern = !!plan.kern_mask; - plan.has_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); - } + HB_INTERNAL void compile (hb_ot_shape_plan_t &plan, + const int *coords, + unsigned int num_coords); private: HB_DISALLOW_COPY_AND_ASSIGN (hb_ot_shape_planner_t); commit bf5088b3dcd94106937290c180f3f40bc8524b48 Author: Ebrahim Byagowi <[email protected]> Date: Tue Oct 2 11:07:06 2018 +0330 Minor, fix -Weverthing bot warnings (#1210) diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c index 5c98a9a1..5fba3b22 100644 --- a/test/api/test-buffer.c +++ b/test/api/test-buffer.c @@ -92,14 +92,14 @@ fixture_init (fixture_t *fixture, gconstpointer user_data) } static void -fixture_finish (fixture_t *fixture, gconstpointer user_data) +fixture_finish (fixture_t *fixture, gconstpointer user_data HB_UNUSED) { hb_buffer_destroy (fixture->buffer); } static void -test_buffer_properties (fixture_t *fixture, gconstpointer user_data) +test_buffer_properties (fixture_t *fixture, gconstpointer user_data HB_UNUSED) { hb_buffer_t *b = fixture->buffer; hb_unicode_funcs_t *ufuncs; @@ -294,7 +294,7 @@ test_buffer_contents (fixture_t *fixture, gconstpointer user_data) } static void -test_buffer_positions (fixture_t *fixture, gconstpointer user_data) +test_buffer_positions (fixture_t *fixture, gconstpointer user_data HB_UNUSED) { hb_buffer_t *b = fixture->buffer; unsigned int i, len, len2; @@ -319,7 +319,7 @@ test_buffer_positions (fixture_t *fixture, gconstpointer user_data) } static void -test_buffer_allocation (fixture_t *fixture, gconstpointer user_data) +test_buffer_allocation (fixture_t *fixture, gconstpointer user_data HB_UNUSED) { hb_buffer_t *b = fixture->buffer; diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c index de288b6a..e1e7eb53 100644 --- a/test/api/test-multithread.c +++ b/test/api/test-multithread.c @@ -49,7 +49,7 @@ static int num_iters = 200; static hb_font_t *font; static hb_buffer_t *ref_buffer; -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static void fill_the_buffer (hb_buffer_t *buffer) @@ -105,7 +105,6 @@ static void test_body (void) { int i; - int num_threads = 30; pthread_t *threads = calloc (num_threads, sizeof (pthread_t)); hb_buffer_t **buffers = calloc (num_threads, sizeof (hb_buffer_t *)); commit d27e5ec3a236b8eb37ef9ce558ad54077e46b003 Author: Khaled Hosny <[email protected]> Date: Tue Oct 2 08:25:29 2018 +0200 Skip BOM in the Python sample file Fixes https://github.com/harfbuzz/harfbuzz/issues/1208 diff --git a/src/sample.py b/src/sample.py index 8f97195f..5d65aa09 100755 --- a/src/sample.py +++ b/src/sample.py @@ -54,11 +54,11 @@ if False: # buffer: hb.buffer_add_utf8 (buf, text.encode('utf-8'), 0, -1) # Otherwise, then following handles both narrow and wide - # Python builds: + # Python builds (the first item in the array is BOM, so we skip it): elif sys.maxunicode == 0x10FFFF: - hb.buffer_add_utf32 (buf, array.array('I', text.encode('utf-32')), 0, -1) + hb.buffer_add_utf32 (buf, array.array('I', text.encode('utf-32'))[1:], 0, -1) else: - hb.buffer_add_utf16 (buf, array.array('H', text.encode('utf-16')), 0, -1) + hb.buffer_add_utf16 (buf, array.array('H', text.encode('utf-16'))[1:], 0, -1) hb.buffer_guess_segment_properties (buf) commit f9ea3dc4c6e85c417dd4c8546e5ebe02b67131b9 Author: HinTak <[email protected]> Date: Tue Oct 2 06:43:06 2018 +0100 Missing "out" indicator (#1209) Missing "out" indicator. Affect gobject introspection. diff --git a/src/hb-font.cc b/src/hb-font.cc index c0beea66..5c259dca 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1005,7 +1005,7 @@ hb_font_get_glyph_from_name (hb_font_t *font, * hb_font_get_extents_for_direction: * @font: a font. * @direction: - * @extents: + * @extents: (out): * * * commit 9742679b8253919f8bfec8a77532092044e951aa Author: Ebrahim Byagowi <[email protected]> Date: Tue Oct 2 03:20:48 2018 +0330 [circleci] Remove some of the not needed flags diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a0bfe39..670efa5a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,7 +91,7 @@ jobs: - run: apt update || true - run: apt install -y clang lld binutils libtool autoconf automake make pkg-config gtk-doc-tools ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip - run: pip install fonttools - - run: CFLAGS="-Weverything -Wno-unused-parameter -Wno-missing-variable-declarations -Wno-padded -Wno-cast-qual -Wno-sign-conversion -Wno-conversion -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-shadow -Wno-reserved-id-macro -Wno-disabled-macro-expansion -Wno-missing-variable-declarations -Wno-unused-macros -Wno-unreachable-code-return" CXXFLAGS="-Weverything -Wno-undef -Wno-deprecated-declarations -Wno-weak-vtables -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-conversion -Wno-sign-conversion -Wno-c++98-compat -Wno-extra-semi -Wno-c++98-compat-pedantic -Wno-padded -Wno-shift-sign-overflow -Wno-missing-field-initializers -Wno-double-promotion -Wno-reserved-id-macro -Wno-cast-qual -Wno-unused-parameter -Wno-comma -Wno-shadow -Wno-used-but-marked-unused -Wno-format-pedantic -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansion -Wno-covered-switch-default -Wno-conditional-uninitialized -Wno-unreachable -code -Wno-unused-macros -Wno-float-equal -Wno-missing-prototypes" CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 + - run: CFLAGS="-Weverything -Wno-padded -Wno-cast-qual -Wno-sign-conversion -Wno-conversion -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro" CXXFLAGS="-Weverything -Wno-undef -Wno-deprecated-declarations -Wno-weak-vtables -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-conversion -Wno-sign-conversion -Wno-c++98-compat -Wno-extra-semi -Wno-c++98-compat-pedantic -Wno-padded -Wno-shift-sign-overflow -Wno-missing-field-initializers -Wno-double-promotion -Wno-reserved-id-macro -Wno-cast-qual -Wno-unused-parameter -Wno-comma -Wno-shadow -Wno-used-but-marked-unused -Wno-format-pedantic -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansion -Wno-covered-switch-default -Wno-conditional-uninitialized -Wno-unreachable-code -Wno-unused-macros -Wno-float-equal -Wno-missing-prototypes" CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 - run: make -j32 CPPFLAGS="-Werror" - run: make check CPPFLAGS="-Werror" || .ci/fail.sh commit f72b748371da2d7ce327a5d15feea46960aa7dd3 Author: Ebrahim Byagowi <[email protected]> Date: Tue Oct 2 00:16:08 2018 +0330 [circleci] Fix "msan" and "everything" bots (#1205) diff --git a/.circleci/config.yml b/.circleci/config.yml index 450b62be..9a0bfe39 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,9 +91,9 @@ jobs: - run: apt update || true - run: apt install -y clang lld binutils libtool autoconf automake make pkg-config gtk-doc-tools ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip - run: pip install fonttools - - run: CFLAGS="-Weverything -Werror -fPIC -Wno-unused-parameter -Wno-missing-variable-declarations -Wno-padded -Wno-cast-qual -Wno-sign-conversion -Wno-conversion -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-shadow -Wno-reserved-id-macro -Wno-disabled-macro-expansion -Wno-missing-variable-declarations -Wno-unused-macros -Wno-unreachable-code-return" CXXFLAGS="-Weverything -Werror -fPIC -Wno-undef -Wno-deprecated-declarations -Wno-weak-vtables -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-conversion -Wno-sign-conversion -Wno-c++98-compat -Wno-extra-semi -Wno-c++98-compat-pedantic -Wno-padded -Wno-shift-sign-overflow -Wno-missing-field-initializers -Wno-double-promotion -Wno-reserved-id-macro -Wno-cast-qual -Wno-unused-parameter -Wno-comma -Wno-shadow -Wno-used-but-marked-unused -Wno-format-pedantic -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansion -Wno-covered-switch-default -Wno-conditional-un initialized -Wno-unreachable-code -Wno-unused-macros -Wno-float-equal -Wno-missing-prototypes" CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 - - run: make -j32 - - run: make check || .ci/fail.sh + - run: CFLAGS="-Weverything -Wno-unused-parameter -Wno-missing-variable-declarations -Wno-padded -Wno-cast-qual -Wno-sign-conversion -Wno-conversion -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro -Wno-shadow -Wno-reserved-id-macro -Wno-disabled-macro-expansion -Wno-missing-variable-declarations -Wno-unused-macros -Wno-unreachable-code-return" CXXFLAGS="-Weverything -Wno-undef -Wno-deprecated-declarations -Wno-weak-vtables -Wno-old-style-cast -Wno-documentation -Wno-documentation-unknown-command -Wno-conversion -Wno-sign-conversion -Wno-c++98-compat -Wno-extra-semi -Wno-c++98-compat-pedantic -Wno-padded -Wno-shift-sign-overflow -Wno-missing-field-initializers -Wno-double-promotion -Wno-reserved-id-macro -Wno-cast-qual -Wno-unused-parameter -Wno-comma -Wno-shadow -Wno-used-but-marked-unused -Wno-format-pedantic -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansion -Wno-covered-switch-default -Wno-conditional-uninitialized -Wno-unreachable -code -Wno-unused-macros -Wno-float-equal -Wno-missing-prototypes" CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2 + - run: make -j32 CPPFLAGS="-Werror" + - run: make check CPPFLAGS="-Werror" || .ci/fail.sh clang-asan: docker: @@ -121,14 +121,13 @@ jobs: - run: echo "deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic main" > /etc/apt/sources.list.d/llvmdev.list - run: echo "deb-src http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic main" > /etc/apt/sources.list.d/llvmdevsrc.list - run: apt update || true - - run: apt install -y clang lld binutils libtool autoconf automake automake1.11 gtk-doc-tools gettext make pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip + - run: apt install -y clang lld binutils libtool autoconf automake gtk-doc-tools gettext make pkg-config ragel libcairo2-dev libicu-dev libmount-dev libgraphite2-dev python python-pip - run: pip install fonttools - run: update-alternatives --install "/usr/bin/ld" "ld" "/usr/bin/ld.lld" 10 - - run: wget https://ftp.gnome.org/pub/gnome/sources/glib/2.28/glib-2.28.0.tar.bz2 && tar xf glib-2.28.0.tar.bz2 && cd glib-2.28.0 && ./autogen.sh || true && ./configure CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory" CFLAGS="-fsanitize=memory" CXXFLAGS="-fsanitize=memory" LD=ld.lld CC=clang CXX=clang++ && make -j32 && make install && cd .. + - run: wget https://ftp.gnome.org/pub/gnome/sources/glib/2.58/glib-2.58.1.tar.xz && tar xf glib-2.58.1.tar.xz && cd glib-2.58.1 && ./autogen.sh --with-pcre CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory" CFLAGS="-fsanitize=memory" CXXFLAGS="-fsanitize=memory" LD=ld.lld CC=clang CXX=clang++ && make -j32 && make install && cd .. - run: wget http://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.bz2 && tar xf freetype-2.9.tar.bz2 && cd freetype-2.9 && ./autogen.sh && ./configure CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ && make -j32 && make install && cd .. - run: CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --without-icu - - run: make -j32 - - run: MSAN_OPTIONS=exitcode=42 SKIPCHECKSYMBOLS=1 SKIPFUZZERTESTS=1 make check || .ci/fail.sh | asan_symbolize | c++filt + - run: make -j32 && MSAN_OPTIONS=exitcode=42 make check || .ci/fail.sh | asan_symbolize | c++filt clang-tsan: docker: diff --git a/src/check-symbols.sh b/src/check-symbols.sh index d197e8e3..cea86848 100755 --- a/src/check-symbols.sh +++ b/src/check-symbols.sh @@ -3,8 +3,6 @@ LC_ALL=C export LC_ALL -test -z "$SKIPCHECKSYMBOLS" || exit 77 - test -z "$srcdir" && srcdir=. test -z "$libs" && libs=.libs stat=0 diff --git a/test/fuzzing/main.cc b/test/fuzzing/main.cc index 4692f7b5..3ff8803e 100644 --- a/test/fuzzing/main.cc +++ b/test/fuzzing/main.cc @@ -1,21 +1,17 @@ #include "hb-fuzzer.hh" -#include <iostream> -#include <iterator> -#include <fstream> +#include <stdio.h> #include <assert.h> -std::string FileToString(const std::string &Path) { - /* TODO This silently passes if file does not exist. Fix it! */ - std::ifstream T(Path.c_str()); - return std::string((std::istreambuf_iterator<char>(T)), - std::istreambuf_iterator<char>()); -} - int main(int argc, char **argv) { + hb_blob_t *blob = hb_blob_create_from_file (argv[1]); + unsigned int len; + const char *font_data = hb_blob_get_data (blob, &len); + for (int i = 1; i < argc; i++) { - std::string s = FileToString(argv[i]); - std::cout << argv[i] << std::endl; - LLVMFuzzerTestOneInput((const unsigned char*)s.data(), s.size()); + printf ("%s\n", argv[i]); + LLVMFuzzerTestOneInput((const uint8_t *) font_data, len); } + + hb_blob_destroy (blob); } diff --git a/test/fuzzing/run-shape-fuzzer-tests.py b/test/fuzzing/run-shape-fuzzer-tests.py index e87cd09d..fea0b01b 100755 --- a/test/fuzzing/run-shape-fuzzer-tests.py +++ b/test/fuzzing/run-shape-fuzzer-tests.py @@ -4,8 +4,6 @@ from __future__ import print_function, division, absolute_import import sys, os, subprocess -if os.environ.get ("SKIPFUZZERTESTS", "") != "": sys.exit (0) - srcdir = os.environ.get ("srcdir", ".") EXEEXT = os.environ.get ("EXEEXT", "") top_builddir = os.environ.get ("top_builddir", ".") diff --git a/test/fuzzing/run-subset-fuzzer-tests.py b/test/fuzzing/run-subset-fuzzer-tests.py index aa045fed..01362886 100755 --- a/test/fuzzing/run-subset-fuzzer-tests.py +++ b/test/fuzzing/run-subset-fuzzer-tests.py @@ -4,8 +4,6 @@ from __future__ import print_function, division, absolute_import import sys, os, subprocess -if os.environ.get ("SKIPFUZZERTESTS", "") != "": sys.exit (0) - srcdir = os.environ.get ("srcdir", ".") EXEEXT = os.environ.get ("EXEEXT", "") top_builddir = os.environ.get ("top_builddir", ".") _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
