src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-khmer.cc
changeset 50826 f5b95be8b6e2
parent 50352 25db2c8f3cf8
child 51000 7c8841474f57
equal deleted inserted replaced
50825:aa0a35b071fb 50826:f5b95be8b6e2
   273   return a < b ? -1 : a == b ? 0 : +1;
   273   return a < b ? -1 : a == b ? 0 : +1;
   274 }
   274 }
   275 
   275 
   276 
   276 
   277 /* Rules from:
   277 /* Rules from:
   278  * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */
   278  * https://docs.microsoft.com/en-us/typography/script-development/devanagari */
   279 
   279 
   280 static void
   280 static void
   281 initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan,
   281 initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan,
   282                                        hb_face_t *face,
   282                                        hb_face_t *face,
   283                                        hb_buffer_t *buffer,
   283                                        hb_buffer_t *buffer,
   315     for (unsigned int i = start; i < end; i++)
   315     for (unsigned int i = start; i < end; i++)
   316     {
   316     {
   317       if ((FLAG_UNSAFE (info[i].khmer_category()) & (JOINER_FLAGS | FLAG (OT_N) | FLAG (OT_RS) | MEDIAL_FLAGS | FLAG (OT_Coeng))))
   317       if ((FLAG_UNSAFE (info[i].khmer_category()) & (JOINER_FLAGS | FLAG (OT_N) | FLAG (OT_RS) | MEDIAL_FLAGS | FLAG (OT_Coeng))))
   318       {
   318       {
   319         info[i].khmer_position() = last_pos;
   319         info[i].khmer_position() = last_pos;
   320         if (unlikely (info[i].khmer_category() == OT_H &&
   320         if (unlikely (info[i].khmer_category() == OT_Coeng &&
   321                       info[i].khmer_position() == POS_PRE_M))
   321                       info[i].khmer_position() == POS_PRE_M))
   322         {
   322         {
   323           /*
   323           /*
   324            * Uniscribe doesn't move the Halant with Left Matra.
   324            * Uniscribe doesn't move the Halant with Left Matra.
   325            * TEST: U+092B,U+093F,U+094DE
   325            * TEST: U+092B,U+093F,U+094DE
   483 
   483 
   484   buffer->clear_output ();
   484   buffer->clear_output ();
   485 
   485 
   486   buffer->idx = 0;
   486   buffer->idx = 0;
   487   unsigned int last_syllable = 0;
   487   unsigned int last_syllable = 0;
   488   while (buffer->idx < buffer->len && !buffer->in_error)
   488   while (buffer->idx < buffer->len && buffer->successful)
   489   {
   489   {
   490     unsigned int syllable = buffer->cur().syllable();
   490     unsigned int syllable = buffer->cur().syllable();
   491     syllable_type_t syllable_type = (syllable_type_t) (syllable & 0x0F);
   491     syllable_type_t syllable_type = (syllable_type_t) (syllable & 0x0F);
   492     if (unlikely (last_syllable != syllable && syllable_type == broken_cluster))
   492     if (unlikely (last_syllable != syllable && syllable_type == broken_cluster))
   493     {
   493     {
   498       ginfo.mask = buffer->cur().mask;
   498       ginfo.mask = buffer->cur().mask;
   499       ginfo.syllable() = buffer->cur().syllable();
   499       ginfo.syllable() = buffer->cur().syllable();
   500       /* TODO Set glyph_props? */
   500       /* TODO Set glyph_props? */
   501 
   501 
   502       /* Insert dottedcircle after possible Repha. */
   502       /* Insert dottedcircle after possible Repha. */
   503       while (buffer->idx < buffer->len && !buffer->in_error &&
   503       while (buffer->idx < buffer->len && buffer->successful &&
   504              last_syllable == buffer->cur().syllable() &&
   504              last_syllable == buffer->cur().syllable() &&
   505              buffer->cur().khmer_category() == OT_Repha)
   505              buffer->cur().khmer_category() == OT_Repha)
   506         buffer->next_glyph ();
   506         buffer->next_glyph ();
   507 
   507 
   508       buffer->output_info (ginfo);
   508       buffer->output_info (ginfo);
   536 
   536 
   537   /* This function relies heavily on halant glyphs.  Lots of ligation
   537   /* This function relies heavily on halant glyphs.  Lots of ligation
   538    * and possibly multiple substitutions happened prior to this
   538    * and possibly multiple substitutions happened prior to this
   539    * phase, and that might have messed up our properties.  Recover
   539    * phase, and that might have messed up our properties.  Recover
   540    * from a particular case of that where we're fairly sure that a
   540    * from a particular case of that where we're fairly sure that a
   541    * class of OT_H is desired but has been lost. */
   541    * class of OT_Coeng is desired but has been lost. */
   542   if (khmer_plan->virama_glyph)
   542   if (khmer_plan->virama_glyph)
   543   {
   543   {
   544     unsigned int virama_glyph = khmer_plan->virama_glyph;
   544     unsigned int virama_glyph = khmer_plan->virama_glyph;
   545     for (unsigned int i = start; i < end; i++)
   545     for (unsigned int i = start; i < end; i++)
   546       if (info[i].codepoint == virama_glyph &&
   546       if (info[i].codepoint == virama_glyph &&
   547           _hb_glyph_info_ligated (&info[i]) &&
   547           _hb_glyph_info_ligated (&info[i]) &&
   548           _hb_glyph_info_multiplied (&info[i]))
   548           _hb_glyph_info_multiplied (&info[i]))
   549       {
   549       {
   550         /* This will make sure that this glyph passes is_coeng() test. */
   550         /* This will make sure that this glyph passes is_coeng() test. */
   551         info[i].khmer_category() = OT_H;
   551         info[i].khmer_category() = OT_Coeng;
   552         _hb_glyph_info_clear_ligated_and_multiplied (&info[i]);
   552         _hb_glyph_info_clear_ligated_and_multiplied (&info[i]);
   553       }
   553       }
   554   }
   554   }
   555 
   555 
   556 
   556