From bd453de7575ac808780e706734ca6dd4baa43660 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:25:48 -0600 Subject: [PATCH 1/9] [unicode] Accept a couple hacks as permanent --- src/hb-unicode.hh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/hb-unicode.hh b/src/hb-unicode.hh index 4c28bb0cd..39aaee5ba 100644 --- a/src/hb-unicode.hh +++ b/src/hb-unicode.hh @@ -105,12 +105,9 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE unsigned int modified_combining_class (hb_codepoint_t u) { - /* XXX This hack belongs to the USE shaper (for Tai Tham): - * Reorder SAKOT to ensure it comes after any tone marks. */ + /* Reorder SAKOT to ensure it comes after any tone marks. */ if (unlikely (u == 0x1A60u)) return 254; - - /* XXX This hack belongs to the Tibetan shaper: - * Reorder PADMA to ensure it comes after any vowel marks. */ + /* Reorder PADMA to ensure it comes after any vowel marks. */ if (unlikely (u == 0x0FC6u)) return 254; /* Reorder TSA -PHRU to reorder before U+0F74 */ if (unlikely (u == 0x0F39u)) return 127; From 7635568f29e8e9e32bc30f6a6c2651500991dde8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:29:15 -0600 Subject: [PATCH 2/9] [font] Remove a TODO item that's not gonna happen --- src/hb-font.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hb-font.hh b/src/hb-font.hh index e7f3eccd4..43ec73f49 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -446,7 +446,6 @@ struct hb_font_t { *x = get_glyph_h_advance (glyph) / 2; - /* TODO cache this somehow?! */ hb_font_extents_t extents; get_h_extents_with_fallback (&extents); *y = extents.ascender; From 10a8cc28fc6455482b67cf1781fe72765826c4a5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:31:06 -0600 Subject: [PATCH 3/9] [normalizer] Remove a TODO that's not going to happen --- src/hb-ot-shape-normalize.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-shape-normalize.cc b/src/hb-ot-shape-normalize.cc index 6dc317103..d844d79c1 100644 --- a/src/hb-ot-shape-normalize.cc +++ b/src/hb-ot-shape-normalize.cc @@ -223,7 +223,7 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit HB_UNUSED) { - /* TODO Currently if there's a variation-selector we give-up, it's just too hard. */ + /* Currently if there's a variation-selector we give-up on normalization, it's just too hard. */ hb_buffer_t * const buffer = c->buffer; hb_font_t * const font = c->font; for (; buffer->idx < end - 1 && buffer->successful;) { From b3f689e7e5a4272b52e4ee34fbac04e2723b2439 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:31:47 -0600 Subject: [PATCH 4/9] [serializer] Remove TODO that's not gonna happen --- src/hb-serialize.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index 6f56faafe..cecdcdeb7 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -695,7 +695,7 @@ struct hb_serialize_context_t check_assign (off, offset, HB_SERIALIZE_ERROR_OFFSET_OVERFLOW); } - public: /* TODO Make private. */ + public: char *start, *head, *tail, *end; unsigned int debug_depth; hb_serialize_error_t errors; From d09e962b9f5cbb4866e1c51b2fc967b83e323b69 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:35:16 -0600 Subject: [PATCH 5/9] [buffer] Update a TODO item --- src/hb-buffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index e6efa158b..285760274 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -552,7 +552,7 @@ hb_buffer_t::delete_glyph () goto done; } - /* TODO We need to just merge one direction, with whichever is smaller. */ + /* TODO We need to just merge one direction, with whichever is smaller but larger than our cluster. */ if (out_len) { From 689c77530a69cefbe6f142842a135988a1454315 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:37:45 -0600 Subject: [PATCH 6/9] [buffer] Actually remove TODO item In reality, one side is smaller and one side is larger. The existing code handles that just fine. --- src/hb-buffer.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 285760274..2272ecf09 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -552,8 +552,6 @@ hb_buffer_t::delete_glyph () goto done; } - /* TODO We need to just merge one direction, with whichever is smaller but larger than our cluster. */ - if (out_len) { /* Merge cluster backward. */ From e1575f23473af32816e583f4f10e6ef8899dff90 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:41:39 -0600 Subject: [PATCH 7/9] [iter] Remove a few TODO items --- src/hb-iter.hh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index 43a3098f6..d4461f166 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -43,17 +43,12 @@ * is writable, then the iterator returns lvalues, otherwise it * returns rvalues. * - * TODO Document more. - * - * If iterator implementation implements operator!=, then can be + * If iterator implementation implements operator!=, then it can be * used in range-based for loop. That already happens if the iterator * is random-access. Otherwise, the range-based for loop incurs * one traversal to find end(), which can be avoided if written * as a while-style for loop, or if iterator implements a faster - * __end__() method. - * TODO When opting in for C++17, address this by changing return - * type of .end()? - */ + * __end__() method. */ /* * Base classes for iterators. @@ -75,10 +70,6 @@ struct hb_iter_t iter_t* thiz () { return static_cast< iter_t *> (this); } public: - /* TODO: - * Port operators below to use hb_enable_if to sniff which method implements - * an operator and use it, and remove hb_iter_fallback_mixin_t completely. */ - /* Operators. */ iter_t iter () const { return *thiz(); } iter_t operator + () const { return *thiz(); } @@ -87,8 +78,7 @@ struct hb_iter_t explicit operator bool () const { return thiz()->__more__ (); } unsigned len () const { return thiz()->__len__ (); } /* The following can only be enabled if item_t is reference type. Otherwise - * it will be returning pointer to temporary rvalue. - * TODO Use a wrapper return type to fix for non-reference type. */ + * it will be returning pointer to temporary rvalue. */ template ::value)> hb_remove_reference* operator -> () const { return std::addressof (**thiz()); } From 6997d10bc0cab13103b660eb968bc49e2a0fb0f7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:43:33 -0600 Subject: [PATCH 8/9] [arabic] Remove a couple TODO items --- src/hb-ot-shaper-arabic-fallback.hh | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hb-ot-shaper-arabic-fallback.hh b/src/hb-ot-shaper-arabic-fallback.hh index 875825c96..491bc8901 100644 --- a/src/hb-ot-shaper-arabic-fallback.hh +++ b/src/hb-ot-shaper-arabic-fallback.hh @@ -168,7 +168,6 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN hb_array (component_count_list, num_ligatures), hb_array (component_list, num_ligatures)); c.end_serialize (); - /* TODO sanitize the results? */ return ret && !c.in_error () ? c.copy () : nullptr; } @@ -232,7 +231,6 @@ arabic_fallback_plan_init_win1256 (arabic_fallback_plan_t *fallback_plan HB_UNUS const Manifest &manifest = reinterpret_cast (arabic_win1256_gsub_lookups.manifest); static_assert (sizeof (arabic_win1256_gsub_lookups.manifestData) == ARABIC_FALLBACK_MAX_LOOKUPS * sizeof (ManifestLookup), ""); - /* TODO sanitize the table? */ unsigned j = 0; unsigned int count = manifest.len; From 148283d0e060c00da2a661a3e7c86f824250ccec Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 10 Jun 2022 07:48:39 -0600 Subject: [PATCH 9/9] [syllabic] Use a buffer scratch-flag for has-broken-syllable --- src/hb-buffer.hh | 1 + src/hb-ot-shaper-indic-machine.hh | 6 +++--- src/hb-ot-shaper-indic-machine.rl | 2 +- src/hb-ot-shaper-khmer-machine.hh | 6 +++--- src/hb-ot-shaper-khmer-machine.rl | 2 +- src/hb-ot-shaper-myanmar-machine.hh | 4 ++-- src/hb-ot-shaper-myanmar-machine.rl | 2 +- src/hb-ot-shaper-syllabic.cc | 15 +-------------- src/hb-ot-shaper-use-machine.hh | 4 ++-- src/hb-ot-shaper-use-machine.rl | 2 +- 10 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 89bd281a7..0f991936c 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -70,6 +70,7 @@ enum hb_buffer_scratch_flags_t { HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000010u, HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS = 0x00000020u, + HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE = 0x00000040u, /* Reserved for shapers' internal use. */ HB_BUFFER_SCRATCH_FLAG_SHAPER0 = 0x01000000u, diff --git a/src/hb-ot-shaper-indic-machine.hh b/src/hb-ot-shaper-indic-machine.hh index 5fbb2f581..b7458c842 100644 --- a/src/hb-ot-shaper-indic-machine.hh +++ b/src/hb-ot-shaper-indic-machine.hh @@ -498,7 +498,7 @@ _eof_trans: break; case 15: #line 98 "hb-ot-shaper-indic-machine.rl" - {te = p;p--;{ found_syllable (indic_broken_cluster); }} + {te = p;p--;{ found_syllable (indic_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 16: #line 99 "hb-ot-shaper-indic-machine.rl" @@ -522,7 +522,7 @@ _eof_trans: break; case 4: #line 98 "hb-ot-shaper-indic-machine.rl" - {{p = ((te))-1;}{ found_syllable (indic_broken_cluster); }} + {{p = ((te))-1;}{ found_syllable (indic_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 6: #line 1 "NONE" @@ -531,7 +531,7 @@ _eof_trans: {{p = ((te))-1;} found_syllable (indic_consonant_syllable); } break; case 5: - {{p = ((te))-1;} found_syllable (indic_broken_cluster); } + {{p = ((te))-1;} found_syllable (indic_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; } break; case 6: {{p = ((te))-1;} found_syllable (indic_non_indic_cluster); } diff --git a/src/hb-ot-shaper-indic-machine.rl b/src/hb-ot-shaper-indic-machine.rl index cc4ad9d9b..4a7f64e2f 100644 --- a/src/hb-ot-shaper-indic-machine.rl +++ b/src/hb-ot-shaper-indic-machine.rl @@ -95,7 +95,7 @@ main := |* vowel_syllable => { found_syllable (indic_vowel_syllable); }; standalone_cluster => { found_syllable (indic_standalone_cluster); }; symbol_cluster => { found_syllable (indic_symbol_cluster); }; - broken_cluster => { found_syllable (indic_broken_cluster); }; + broken_cluster => { found_syllable (indic_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }; other => { found_syllable (indic_non_indic_cluster); }; *|; diff --git a/src/hb-ot-shaper-khmer-machine.hh b/src/hb-ot-shaper-khmer-machine.hh index 10e60a9c7..8d2a64c31 100644 --- a/src/hb-ot-shaper-khmer-machine.hh +++ b/src/hb-ot-shaper-khmer-machine.hh @@ -324,7 +324,7 @@ _eof_trans: break; case 12: #line 81 "hb-ot-shaper-khmer-machine.rl" - {te = p;p--;{ found_syllable (khmer_broken_cluster); }} + {te = p;p--;{ found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 11: #line 82 "hb-ot-shaper-khmer-machine.rl" @@ -336,13 +336,13 @@ _eof_trans: break; case 5: #line 81 "hb-ot-shaper-khmer-machine.rl" - {{p = ((te))-1;}{ found_syllable (khmer_broken_cluster); }} + {{p = ((te))-1;}{ found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 3: #line 1 "NONE" { switch( act ) { case 2: - {{p = ((te))-1;} found_syllable (khmer_broken_cluster); } + {{p = ((te))-1;} found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; } break; case 3: {{p = ((te))-1;} found_syllable (khmer_non_khmer_cluster); } diff --git a/src/hb-ot-shaper-khmer-machine.rl b/src/hb-ot-shaper-khmer-machine.rl index 1593d2bcb..b343f89f6 100644 --- a/src/hb-ot-shaper-khmer-machine.rl +++ b/src/hb-ot-shaper-khmer-machine.rl @@ -78,7 +78,7 @@ other = any; main := |* consonant_syllable => { found_syllable (khmer_consonant_syllable); }; - broken_cluster => { found_syllable (khmer_broken_cluster); }; + broken_cluster => { found_syllable (khmer_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }; other => { found_syllable (khmer_non_khmer_cluster); }; *|; diff --git a/src/hb-ot-shaper-myanmar-machine.hh b/src/hb-ot-shaper-myanmar-machine.hh index cbb9235b9..a211a94d7 100644 --- a/src/hb-ot-shaper-myanmar-machine.hh +++ b/src/hb-ot-shaper-myanmar-machine.hh @@ -435,7 +435,7 @@ _eof_trans: break; case 8: #line 97 "hb-ot-shaper-myanmar-machine.rl" - {te = p+1;{ found_syllable (myanmar_broken_cluster); }} + {te = p+1;{ found_syllable (myanmar_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 3: #line 98 "hb-ot-shaper-myanmar-machine.rl" @@ -447,7 +447,7 @@ _eof_trans: break; case 7: #line 97 "hb-ot-shaper-myanmar-machine.rl" - {te = p;p--;{ found_syllable (myanmar_broken_cluster); }} + {te = p;p--;{ found_syllable (myanmar_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 9: #line 98 "hb-ot-shaper-myanmar-machine.rl" diff --git a/src/hb-ot-shaper-myanmar-machine.rl b/src/hb-ot-shaper-myanmar-machine.rl index 57f0f16ec..aec05f405 100644 --- a/src/hb-ot-shaper-myanmar-machine.rl +++ b/src/hb-ot-shaper-myanmar-machine.rl @@ -94,7 +94,7 @@ main := |* consonant_syllable => { found_syllable (myanmar_consonant_syllable); }; j => { found_syllable (myanmar_non_myanmar_cluster); }; punctuation_cluster => { found_syllable (myanmar_punctuation_cluster); }; - broken_cluster => { found_syllable (myanmar_broken_cluster); }; + broken_cluster => { found_syllable (myanmar_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }; other => { found_syllable (myanmar_non_myanmar_cluster); }; *|; diff --git a/src/hb-ot-shaper-syllabic.cc b/src/hb-ot-shaper-syllabic.cc index 58d694279..a8e0d8e8c 100644 --- a/src/hb-ot-shaper-syllabic.cc +++ b/src/hb-ot-shaper-syllabic.cc @@ -39,22 +39,9 @@ hb_syllabic_insert_dotted_circles (hb_font_t *font, { if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE)) return; - - /* Note: This loop is extra overhead, but should not be measurable. - * TODO Use a buffer scratch flag to remove the loop. */ - bool has_broken_syllables = false; - unsigned int count = buffer->len; - hb_glyph_info_t *info = buffer->info; - for (unsigned int i = 0; i < count; i++) - if ((info[i].syllable() & 0x0F) == broken_syllable_type) - { - has_broken_syllables = true; - break; - } - if (likely (!has_broken_syllables)) + if (likely (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE))) return; - hb_codepoint_t dottedcircle_glyph; if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph)) return; diff --git a/src/hb-ot-shaper-use-machine.hh b/src/hb-ot-shaper-use-machine.hh index f71a448ec..fa98f8bf7 100644 --- a/src/hb-ot-shaper-use-machine.hh +++ b/src/hb-ot-shaper-use-machine.hh @@ -753,7 +753,7 @@ _eof_trans: break; case 4: #line 176 "hb-ot-shaper-use-machine.rl" - {te = p+1;{ found_syllable (use_broken_cluster); }} + {te = p+1;{ found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 3: #line 177 "hb-ot-shaper-use-machine.rl" @@ -785,7 +785,7 @@ _eof_trans: break; case 15: #line 176 "hb-ot-shaper-use-machine.rl" - {te = p;p--;{ found_syllable (use_broken_cluster); }} + {te = p;p--;{ found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }} break; case 16: #line 177 "hb-ot-shaper-use-machine.rl" diff --git a/src/hb-ot-shaper-use-machine.rl b/src/hb-ot-shaper-use-machine.rl index 929cc0794..b05cc177a 100644 --- a/src/hb-ot-shaper-use-machine.rl +++ b/src/hb-ot-shaper-use-machine.rl @@ -173,7 +173,7 @@ main := |* numeral_cluster => { found_syllable (use_numeral_cluster); }; symbol_cluster => { found_syllable (use_symbol_cluster); }; hieroglyph_cluster => { found_syllable (use_hieroglyph_cluster); }; - broken_cluster => { found_syllable (use_broken_cluster); }; + broken_cluster => { found_syllable (use_broken_cluster); buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE; }; other => { found_syllable (use_non_cluster); }; *|;