Merge branch 'main' into indic-cleanup

This commit is contained in:
Behdad Esfahbod 2022-06-10 10:55:49 -06:00
commit 0daafefdd1
17 changed files with 23 additions and 53 deletions

View File

@ -552,8 +552,6 @@ hb_buffer_t::delete_glyph ()
goto done; goto done;
} }
/* TODO We need to just merge one direction, with whichever is smaller. */
if (out_len) if (out_len)
{ {
/* Merge cluster backward. */ /* Merge cluster backward. */

View File

@ -70,6 +70,7 @@ enum hb_buffer_scratch_flags_t {
HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u, HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT = 0x00000008u,
HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000010u, HB_BUFFER_SCRATCH_FLAG_HAS_CGJ = 0x00000010u,
HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS = 0x00000020u, HB_BUFFER_SCRATCH_FLAG_HAS_GLYPH_FLAGS = 0x00000020u,
HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE = 0x00000040u,
/* Reserved for shapers' internal use. */ /* Reserved for shapers' internal use. */
HB_BUFFER_SCRATCH_FLAG_SHAPER0 = 0x01000000u, HB_BUFFER_SCRATCH_FLAG_SHAPER0 = 0x01000000u,

View File

@ -446,7 +446,6 @@ struct hb_font_t
{ {
*x = get_glyph_h_advance (glyph) / 2; *x = get_glyph_h_advance (glyph) / 2;
/* TODO cache this somehow?! */
hb_font_extents_t extents; hb_font_extents_t extents;
get_h_extents_with_fallback (&extents); get_h_extents_with_fallback (&extents);
*y = extents.ascender; *y = extents.ascender;

View File

@ -43,17 +43,12 @@
* is writable, then the iterator returns lvalues, otherwise it * is writable, then the iterator returns lvalues, otherwise it
* returns rvalues. * returns rvalues.
* *
* TODO Document more. * If iterator implementation implements operator!=, then it can be
*
* If iterator implementation implements operator!=, then can be
* used in range-based for loop. That already happens if the iterator * used in range-based for loop. That already happens if the iterator
* is random-access. Otherwise, the range-based for loop incurs * is random-access. Otherwise, the range-based for loop incurs
* one traversal to find end(), which can be avoided if written * one traversal to find end(), which can be avoided if written
* as a while-style for loop, or if iterator implements a faster * as a while-style for loop, or if iterator implements a faster
* __end__() method. * __end__() method. */
* TODO When opting in for C++17, address this by changing return
* type of .end()?
*/
/* /*
* Base classes for iterators. * Base classes for iterators.
@ -75,10 +70,6 @@ struct hb_iter_t
iter_t* thiz () { return static_cast< iter_t *> (this); } iter_t* thiz () { return static_cast< iter_t *> (this); }
public: 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. */ /* Operators. */
iter_t iter () const { return *thiz(); } iter_t iter () const { return *thiz(); }
iter_t operator + () const { return *thiz(); } iter_t operator + () const { return *thiz(); }
@ -87,8 +78,7 @@ struct hb_iter_t
explicit operator bool () const { return thiz()->__more__ (); } explicit operator bool () const { return thiz()->__more__ (); }
unsigned len () const { return thiz()->__len__ (); } unsigned len () const { return thiz()->__len__ (); }
/* The following can only be enabled if item_t is reference type. Otherwise /* The following can only be enabled if item_t is reference type. Otherwise
* it will be returning pointer to temporary rvalue. * it will be returning pointer to temporary rvalue. */
* TODO Use a wrapper return type to fix for non-reference type. */
template <typename T = item_t, template <typename T = item_t,
hb_enable_if (std::is_reference<T>::value)> hb_enable_if (std::is_reference<T>::value)>
hb_remove_reference<item_t>* operator -> () const { return std::addressof (**thiz()); } hb_remove_reference<item_t>* operator -> () const { return std::addressof (**thiz()); }

View File

@ -223,7 +223,7 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c,
unsigned int end, unsigned int end,
bool short_circuit HB_UNUSED) 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_buffer_t * const buffer = c->buffer;
hb_font_t * const font = c->font; hb_font_t * const font = c->font;
for (; buffer->idx < end - 1 && buffer->successful;) { for (; buffer->idx < end - 1 && buffer->successful;) {

View File

@ -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_count_list, num_ligatures),
hb_array (component_list, num_ligatures)); hb_array (component_list, num_ligatures));
c.end_serialize (); c.end_serialize ();
/* TODO sanitize the results? */
return ret && !c.in_error () ? c.copy<OT::SubstLookup> () : nullptr; return ret && !c.in_error () ? c.copy<OT::SubstLookup> () : nullptr;
} }
@ -232,7 +231,6 @@ arabic_fallback_plan_init_win1256 (arabic_fallback_plan_t *fallback_plan HB_UNUS
const Manifest &manifest = reinterpret_cast<const Manifest&> (arabic_win1256_gsub_lookups.manifest); const Manifest &manifest = reinterpret_cast<const Manifest&> (arabic_win1256_gsub_lookups.manifest);
static_assert (sizeof (arabic_win1256_gsub_lookups.manifestData) == static_assert (sizeof (arabic_win1256_gsub_lookups.manifestData) ==
ARABIC_FALLBACK_MAX_LOOKUPS * sizeof (ManifestLookup), ""); ARABIC_FALLBACK_MAX_LOOKUPS * sizeof (ManifestLookup), "");
/* TODO sanitize the table? */
unsigned j = 0; unsigned j = 0;
unsigned int count = manifest.len; unsigned int count = manifest.len;

View File

@ -506,7 +506,7 @@ _eof_trans:
break; break;
case 15: case 15:
#line 110 "hb-ot-shaper-indic-machine.rl" #line 110 "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; break;
case 16: case 16:
#line 111 "hb-ot-shaper-indic-machine.rl" #line 111 "hb-ot-shaper-indic-machine.rl"
@ -530,7 +530,7 @@ _eof_trans:
break; break;
case 4: case 4:
#line 110 "hb-ot-shaper-indic-machine.rl" #line 110 "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; break;
case 6: case 6:
#line 1 "NONE" #line 1 "NONE"
@ -539,7 +539,7 @@ _eof_trans:
{{p = ((te))-1;} found_syllable (indic_consonant_syllable); } {{p = ((te))-1;} found_syllable (indic_consonant_syllable); }
break; break;
case 5: 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; break;
case 6: case 6:
{{p = ((te))-1;} found_syllable (indic_non_indic_cluster); } {{p = ((te))-1;} found_syllable (indic_non_indic_cluster); }

View File

@ -107,7 +107,7 @@ main := |*
vowel_syllable => { found_syllable (indic_vowel_syllable); }; vowel_syllable => { found_syllable (indic_vowel_syllable); };
standalone_cluster => { found_syllable (indic_standalone_cluster); }; standalone_cluster => { found_syllable (indic_standalone_cluster); };
symbol_cluster => { found_syllable (indic_symbol_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); }; other => { found_syllable (indic_non_indic_cluster); };
*|; *|;

View File

@ -338,7 +338,7 @@ _eof_trans:
break; break;
case 12: case 12:
#line 97 "hb-ot-shaper-khmer-machine.rl" #line 97 "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; break;
case 11: case 11:
#line 98 "hb-ot-shaper-khmer-machine.rl" #line 98 "hb-ot-shaper-khmer-machine.rl"
@ -350,13 +350,13 @@ _eof_trans:
break; break;
case 5: case 5:
#line 97 "hb-ot-shaper-khmer-machine.rl" #line 97 "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; break;
case 3: case 3:
#line 1 "NONE" #line 1 "NONE"
{ switch( act ) { { switch( act ) {
case 2: 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; break;
case 3: case 3:
{{p = ((te))-1;} found_syllable (khmer_non_khmer_cluster); } {{p = ((te))-1;} found_syllable (khmer_non_khmer_cluster); }

View File

@ -94,7 +94,7 @@ other = any;
main := |* main := |*
consonant_syllable => { found_syllable (khmer_consonant_syllable); }; 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); }; other => { found_syllable (khmer_non_khmer_cluster); };
*|; *|;

View File

@ -516,7 +516,7 @@ _eof_trans:
break; break;
case 8: case 8:
#line 116 "hb-ot-shaper-myanmar-machine.rl" #line 116 "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; break;
case 3: case 3:
#line 117 "hb-ot-shaper-myanmar-machine.rl" #line 117 "hb-ot-shaper-myanmar-machine.rl"
@ -528,7 +528,7 @@ _eof_trans:
break; break;
case 7: case 7:
#line 116 "hb-ot-shaper-myanmar-machine.rl" #line 116 "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; break;
case 9: case 9:
#line 117 "hb-ot-shaper-myanmar-machine.rl" #line 117 "hb-ot-shaper-myanmar-machine.rl"

View File

@ -113,7 +113,7 @@ main := |*
consonant_syllable => { found_syllable (myanmar_consonant_syllable); }; consonant_syllable => { found_syllable (myanmar_consonant_syllable); };
j => { found_syllable (myanmar_non_myanmar_cluster); }; j => { found_syllable (myanmar_non_myanmar_cluster); };
punctuation_cluster => { found_syllable (myanmar_punctuation_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); }; other => { found_syllable (myanmar_non_myanmar_cluster); };
*|; *|;

View File

@ -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)) if (unlikely (buffer->flags & HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE))
return; return;
if (likely (!(buffer->scratch_flags & HB_BUFFER_SCRATCH_FLAG_HAS_BROKEN_SYLLABLE)))
/* 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))
return; return;
hb_codepoint_t dottedcircle_glyph; hb_codepoint_t dottedcircle_glyph;
if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph)) if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph))
return; return;

View File

@ -753,7 +753,7 @@ _eof_trans:
break; break;
case 4: case 4:
#line 176 "hb-ot-shaper-use-machine.rl" #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; break;
case 3: case 3:
#line 177 "hb-ot-shaper-use-machine.rl" #line 177 "hb-ot-shaper-use-machine.rl"
@ -785,7 +785,7 @@ _eof_trans:
break; break;
case 15: case 15:
#line 176 "hb-ot-shaper-use-machine.rl" #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; break;
case 16: case 16:
#line 177 "hb-ot-shaper-use-machine.rl" #line 177 "hb-ot-shaper-use-machine.rl"

View File

@ -173,7 +173,7 @@ main := |*
numeral_cluster => { found_syllable (use_numeral_cluster); }; numeral_cluster => { found_syllable (use_numeral_cluster); };
symbol_cluster => { found_syllable (use_symbol_cluster); }; symbol_cluster => { found_syllable (use_symbol_cluster); };
hieroglyph_cluster => { found_syllable (use_hieroglyph_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); }; other => { found_syllable (use_non_cluster); };
*|; *|;

View File

@ -695,7 +695,7 @@ struct hb_serialize_context_t
check_assign (off, offset, HB_SERIALIZE_ERROR_OFFSET_OVERFLOW); check_assign (off, offset, HB_SERIALIZE_ERROR_OFFSET_OVERFLOW);
} }
public: /* TODO Make private. */ public:
char *start, *head, *tail, *end; char *start, *head, *tail, *end;
unsigned int debug_depth; unsigned int debug_depth;
hb_serialize_error_t errors; hb_serialize_error_t errors;

View File

@ -105,12 +105,9 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
unsigned int unsigned int
modified_combining_class (hb_codepoint_t u) 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; if (unlikely (u == 0x1A60u)) return 254;
/* Reorder PADMA to ensure it comes after any vowel marks. */
/* XXX This hack belongs to the Tibetan shaper:
* Reorder PADMA to ensure it comes after any vowel marks. */
if (unlikely (u == 0x0FC6u)) return 254; if (unlikely (u == 0x0FC6u)) return 254;
/* Reorder TSA -PHRU to reorder before U+0F74 */ /* Reorder TSA -PHRU to reorder before U+0F74 */
if (unlikely (u == 0x0F39u)) return 127; if (unlikely (u == 0x0F39u)) return 127;