Revert "Imported Upstream version 1.2.7"
[platform/upstream/harfbuzz.git] / src / hb-ot-shape-complex-hangul.cc
index 5f4d98b..6ac18b0 100644 (file)
@@ -188,7 +188,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
                                    */
   unsigned int count = buffer->len;
 
-  for (buffer->idx = 0; buffer->idx < count && !buffer->in_error;)
+  for (buffer->idx = 0; buffer->idx < count;)
   {
     hb_codepoint_t u = buffer->cur().codepoint;
 
@@ -205,12 +205,17 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
        buffer->next_glyph ();
        if (!is_zero_width_char (font, u))
        {
-         buffer->merge_out_clusters (start, end + 1);
          hb_glyph_info_t *info = buffer->out_info;
          hb_glyph_info_t tone = info[end];
          memmove (&info[start + 1], &info[start], (end - start) * sizeof (hb_glyph_info_t));
          info[start] = tone;
        }
+       /* Merge clusters across the (possibly reordered) syllable+tone.
+        * We want to merge even in the zero-width tone mark case here,
+        * so that clustering behavior isn't dependent on how the tone mark
+        * is handled by the font.
+        */
+       buffer->merge_out_clusters (start, end + 1);
       }
       else
       {
@@ -291,8 +296,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
        }
        else
          end = start + 2;
-       if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
-         buffer->merge_out_clusters (start, end);
+       buffer->merge_out_clusters (start, end);
        continue;
       }
     }
@@ -364,8 +368,7 @@ preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
          info[i++].hangul_shaping_feature() = VJMO;
          if (i < end)
            info[i++].hangul_shaping_feature() = TJMO;
-         if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
-           buffer->merge_out_clusters (start, end);
+         buffer->merge_out_clusters (start, end);
          continue;
        }
       }
@@ -411,14 +414,13 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul =
   "hangul",
   collect_features_hangul,
   override_features_hangul,
-  data_create_hangul,
-  data_destroy_hangul,
+  data_create_hangul, /* data_create */
+  data_destroy_hangul, /* data_destroy */
   preprocess_text_hangul,
-  NULL, /* postprocess_glyphs */
   HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
   NULL, /* decompose */
   NULL, /* compose */
-  setup_masks_hangul,
+  setup_masks_hangul, /* setup_masks */
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
   false, /* fallback_position */
 };