< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-hangul.cc

Print this page




  15  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  16  * DAMAGE.
  17  *
  18  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  19  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  20  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  21  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  23  *
  24  * Google Author(s): Behdad Esfahbod
  25  */
  26 
  27 #include "hb-ot-shape-complex-private.hh"
  28 
  29 
  30 /* Hangul shaper */
  31 
  32 
  33 /* Same order as the feature array below */
  34 enum {
  35   NONE,
  36 
  37   LJMO,
  38   VJMO,
  39   TJMO,
  40 
  41   FIRST_HANGUL_FEATURE = LJMO,
  42   HANGUL_FEATURE_COUNT = TJMO + 1
  43 };
  44 
  45 static const hb_tag_t hangul_features[HANGUL_FEATURE_COUNT] =
  46 {
  47   HB_TAG_NONE,
  48   HB_TAG('l','j','m','o'),
  49   HB_TAG('v','j','m','o'),
  50   HB_TAG('t','j','m','o')
  51 };
  52 
  53 static void
  54 collect_features_hangul (hb_ot_shape_planner_t *plan)
  55 {


  63 override_features_hangul (hb_ot_shape_planner_t *plan)
  64 {
  65   /* Uniscribe does not apply 'calt' for Hangul, and certain fonts
  66    * (Noto Sans CJK, Source Sans Han, etc) apply all of jamo lookups
  67    * in calt, which is not desirable. */
  68   plan->map.add_feature (HB_TAG('c','a','l','t'), 0, F_GLOBAL);
  69 }
  70 
  71 struct hangul_shape_plan_t
  72 {
  73   ASSERT_POD ();
  74 
  75   hb_mask_t mask_array[HANGUL_FEATURE_COUNT];
  76 };
  77 
  78 static void *
  79 data_create_hangul (const hb_ot_shape_plan_t *plan)
  80 {
  81   hangul_shape_plan_t *hangul_plan = (hangul_shape_plan_t *) calloc (1, sizeof (hangul_shape_plan_t));
  82   if (unlikely (!hangul_plan))
  83     return NULL;
  84 
  85   for (unsigned int i = 0; i < HANGUL_FEATURE_COUNT; i++)
  86     hangul_plan->mask_array[i] = plan->map.get_1_mask (hangul_features[i]);
  87 
  88   return hangul_plan;
  89 }
  90 
  91 static void
  92 data_destroy_hangul (void *data)
  93 {
  94   free (data);
  95 }
  96 
  97 /* Constants for algorithmic hangul syllable [de]composition. */
  98 #define LBase 0x1100u
  99 #define VBase 0x1161u
 100 #define TBase 0x11A7u
 101 #define LCount 19u
 102 #define VCount 21u
 103 #define TCount 28u
 104 #define SBase 0xAC00u
 105 #define NCount (VCount * TCount)
 106 #define SCount (LCount * NCount)
 107 
 108 #define isCombiningL(u) (hb_in_range ((u), LBase, LBase+LCount-1))
 109 #define isCombiningV(u) (hb_in_range ((u), VBase, VBase+VCount-1))
 110 #define isCombiningT(u) (hb_in_range ((u), TBase+1, TBase+TCount-1))
 111 #define isCombinedS(u) (hb_in_range ((u), SBase, SBase+SCount-1))
 112 
 113 #define isL(u) (hb_in_ranges ((u), 0x1100u, 0x115Fu, 0xA960u, 0xA97Cu))
 114 #define isV(u) (hb_in_ranges ((u), 0x1160u, 0x11A7u, 0xD7B0u, 0xD7C6u))
 115 #define isT(u) (hb_in_ranges ((u), 0x11A8u, 0x11FFu, 0xD7CBu, 0xD7FBu))
 116 
 117 #define isHangulTone(u) (hb_in_range ((u), 0x302Eu, 0x302Fu))
 118 
 119 /* buffer var allocations */
 120 #define hangul_shaping_feature() complex_var_u8_0() /* hangul jamo shaping feature */
 121 
 122 static bool
 123 is_zero_width_char (hb_font_t *font,
 124                     hb_codepoint_t unicode)
 125 {
 126   hb_codepoint_t glyph;
 127   return hb_font_get_glyph (font, unicode, 0, &glyph) && hb_font_get_glyph_h_advance (font, glyph) == 0;
 128 }
 129 
 130 static void
 131 preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
 132                         hb_buffer_t              *buffer,
 133                         hb_font_t                *font)
 134 {
 135   HB_BUFFER_ALLOCATE_VAR (buffer, hangul_shaping_feature);
 136 
 137   /* Hangul syllables come in two shapes: LV, and LVT.  Of those:


 185   buffer->clear_output ();
 186   unsigned int start = 0, end = 0; /* Extent of most recently seen syllable;
 187                                     * valid only if start < end
 188                                     */
 189   unsigned int count = buffer->len;
 190 
 191   for (buffer->idx = 0; buffer->idx < count && !buffer->in_error;)
 192   {
 193     hb_codepoint_t u = buffer->cur().codepoint;
 194 
 195     if (isHangulTone (u))
 196     {
 197       /*
 198        * We could cache the width of the tone marks and the existence of dotted-circle,
 199        * but the use of the Hangul tone mark characters seems to be rare enough that
 200        * I didn't bother for now.
 201        */
 202       if (start < end && end == buffer->out_len)
 203       {
 204         /* Tone mark follows a valid syllable; move it in front, unless it's zero width. */

 205         buffer->next_glyph ();
 206         if (!is_zero_width_char (font, u))
 207         {
 208           buffer->merge_out_clusters (start, end + 1);
 209           hb_glyph_info_t *info = buffer->out_info;
 210           hb_glyph_info_t tone = info[end];
 211           memmove (&info[start + 1], &info[start], (end - start) * sizeof (hb_glyph_info_t));
 212           info[start] = tone;
 213         }
 214       }
 215       else
 216       {
 217         /* No valid syllable as base for tone mark; try to insert dotted circle. */
 218         if (font->has_glyph (0x25CCu))
 219         {
 220           hb_codepoint_t chars[2];
 221           if (!is_zero_width_char (font, u)) {
 222             chars[0] = u;
 223             chars[1] = 0x25CCu;
 224           } else {


 241                               * will only be used if we set end to a later position.
 242                               */
 243 
 244     if (isL (u) && buffer->idx + 1 < count)
 245     {
 246       hb_codepoint_t l = u;
 247       hb_codepoint_t v = buffer->cur(+1).codepoint;
 248       if (isV (v))
 249       {
 250         /* Have <L,V> or <L,V,T>. */
 251         hb_codepoint_t t = 0;
 252         unsigned int tindex = 0;
 253         if (buffer->idx + 2 < count)
 254         {
 255           t = buffer->cur(+2).codepoint;
 256           if (isT (t))
 257             tindex = t - TBase; /* Only used if isCombiningT (t); otherwise invalid. */
 258           else
 259             t = 0; /* The next character was not a trailing jamo. */
 260         }

 261 
 262         /* We've got a syllable <L,V,T?>; see if it can potentially be composed. */
 263         if (isCombiningL (l) && isCombiningV (v) && (t == 0 || isCombiningT (t)))
 264         {
 265           /* Try to compose; if this succeeds, end is set to start+1. */
 266           hb_codepoint_t s = SBase + (l - LBase) * NCount + (v - VBase) * TCount + tindex;
 267           if (font->has_glyph (s))
 268           {
 269             buffer->replace_glyphs (t ? 3 : 2, 1, &s);
 270             if (unlikely (buffer->in_error))
 271               return;
 272             end = start + 1;
 273             continue;
 274           }
 275         }
 276 
 277         /* We didn't compose, either because it's an Old Hangul syllable without a
 278          * precomposed character in Unicode, or because the font didn't support the
 279          * necessary precomposed glyph.
 280          * Set jamo features on the individual glyphs, and advance past them.


 305       unsigned int lindex = (s - SBase) / NCount;
 306       unsigned int nindex = (s - SBase) % NCount;
 307       unsigned int vindex = nindex / TCount;
 308       unsigned int tindex = nindex % TCount;
 309 
 310       if (!tindex &&
 311           buffer->idx + 1 < count &&
 312           isCombiningT (buffer->cur(+1).codepoint))
 313       {
 314         /* <LV,T>, try to combine. */
 315         unsigned int new_tindex = buffer->cur(+1).codepoint - TBase;
 316         hb_codepoint_t new_s = s + new_tindex;
 317         if (font->has_glyph (new_s))
 318         {
 319           buffer->replace_glyphs (2, 1, &new_s);
 320           if (unlikely (buffer->in_error))
 321             return;
 322           end = start + 1;
 323           continue;
 324         }


 325       }
 326 
 327       /* Otherwise, decompose if font doesn't support <LV> or <LVT>,
 328        * or if having non-combining <LV,T>.  Note that we already handled
 329        * combining <LV,T> above. */
 330       if (!has_glyph ||
 331           (!tindex &&
 332            buffer->idx + 1 < count &&
 333            isT (buffer->cur(+1).codepoint)))
 334       {
 335         hb_codepoint_t decomposed[3] = {LBase + lindex,
 336                                         VBase + vindex,
 337                                         TBase + tindex};
 338         if (font->has_glyph (decomposed[0]) &&
 339             font->has_glyph (decomposed[1]) &&
 340             (!tindex || font->has_glyph (decomposed[2])))
 341         {
 342           unsigned int s_len = tindex ? 3 : 2;
 343           buffer->replace_glyphs (1, s_len, decomposed);
 344           if (unlikely (buffer->in_error))


 351 
 352           /* If we decomposed an LV because of a non-combining T following,
 353            * we want to include this T in the syllable.
 354            */
 355           if (has_glyph && !tindex)
 356           {
 357             buffer->next_glyph ();
 358             s_len++;
 359           }
 360           end = start + s_len;
 361 
 362           unsigned int i = start;
 363           info[i++].hangul_shaping_feature() = LJMO;
 364           info[i++].hangul_shaping_feature() = VJMO;
 365           if (i < end)
 366             info[i++].hangul_shaping_feature() = TJMO;
 367           if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
 368             buffer->merge_out_clusters (start, end);
 369           continue;
 370         }


 371       }
 372 
 373       if (has_glyph)
 374       {
 375         /* We didn't decompose the S, so just advance past it. */
 376         end = start + 1;
 377         buffer->next_glyph ();
 378         continue;
 379       }
 380     }
 381 
 382     /* Didn't find a recognizable syllable, so we leave end <= start;
 383      * this will prevent tone-mark reordering happening.
 384      */
 385     buffer->next_glyph ();
 386   }
 387   buffer->swap_buffers ();
 388 }
 389 
 390 static void
 391 setup_masks_hangul (const hb_ot_shape_plan_t *plan,
 392                     hb_buffer_t              *buffer,
 393                     hb_font_t                *font HB_UNUSED)
 394 {
 395   const hangul_shape_plan_t *hangul_plan = (const hangul_shape_plan_t *) plan->data;
 396 
 397   if (likely (hangul_plan))
 398   {
 399     unsigned int count = buffer->len;
 400     hb_glyph_info_t *info = buffer->info;
 401     for (unsigned int i = 0; i < count; i++, info++)
 402       info->mask |= hangul_plan->mask_array[info->hangul_shaping_feature()];
 403   }
 404 
 405   HB_BUFFER_DEALLOCATE_VAR (buffer, hangul_shaping_feature);
 406 }
 407 
 408 
 409 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul =
 410 {
 411   "hangul",
 412   collect_features_hangul,
 413   override_features_hangul,
 414   data_create_hangul,
 415   data_destroy_hangul,
 416   preprocess_text_hangul,
 417   NULL, /* postprocess_glyphs */
 418   HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
 419   NULL, /* decompose */
 420   NULL, /* compose */
 421   setup_masks_hangul,
 422   NULL, /* disable_otl */

 423   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
 424   false, /* fallback_position */
 425 };


  15  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  16  * DAMAGE.
  17  *
  18  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  19  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  20  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  21  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  23  *
  24  * Google Author(s): Behdad Esfahbod
  25  */
  26 
  27 #include "hb-ot-shape-complex-private.hh"
  28 
  29 
  30 /* Hangul shaper */
  31 
  32 
  33 /* Same order as the feature array below */
  34 enum {
  35   _JMO,
  36 
  37   LJMO,
  38   VJMO,
  39   TJMO,
  40 
  41   FIRST_HANGUL_FEATURE = LJMO,
  42   HANGUL_FEATURE_COUNT = TJMO + 1
  43 };
  44 
  45 static const hb_tag_t hangul_features[HANGUL_FEATURE_COUNT] =
  46 {
  47   HB_TAG_NONE,
  48   HB_TAG('l','j','m','o'),
  49   HB_TAG('v','j','m','o'),
  50   HB_TAG('t','j','m','o')
  51 };
  52 
  53 static void
  54 collect_features_hangul (hb_ot_shape_planner_t *plan)
  55 {


  63 override_features_hangul (hb_ot_shape_planner_t *plan)
  64 {
  65   /* Uniscribe does not apply 'calt' for Hangul, and certain fonts
  66    * (Noto Sans CJK, Source Sans Han, etc) apply all of jamo lookups
  67    * in calt, which is not desirable. */
  68   plan->map.add_feature (HB_TAG('c','a','l','t'), 0, F_GLOBAL);
  69 }
  70 
  71 struct hangul_shape_plan_t
  72 {
  73   ASSERT_POD ();
  74 
  75   hb_mask_t mask_array[HANGUL_FEATURE_COUNT];
  76 };
  77 
  78 static void *
  79 data_create_hangul (const hb_ot_shape_plan_t *plan)
  80 {
  81   hangul_shape_plan_t *hangul_plan = (hangul_shape_plan_t *) calloc (1, sizeof (hangul_shape_plan_t));
  82   if (unlikely (!hangul_plan))
  83     return nullptr;
  84 
  85   for (unsigned int i = 0; i < HANGUL_FEATURE_COUNT; i++)
  86     hangul_plan->mask_array[i] = plan->map.get_1_mask (hangul_features[i]);
  87 
  88   return hangul_plan;
  89 }
  90 
  91 static void
  92 data_destroy_hangul (void *data)
  93 {
  94   free (data);
  95 }
  96 
  97 /* Constants for algorithmic hangul syllable [de]composition. */
  98 #define LBase 0x1100u
  99 #define VBase 0x1161u
 100 #define TBase 0x11A7u
 101 #define LCount 19u
 102 #define VCount 21u
 103 #define TCount 28u
 104 #define SBase 0xAC00u
 105 #define NCount (VCount * TCount)
 106 #define SCount (LCount * NCount)
 107 
 108 #define isCombiningL(u) (hb_in_range<hb_codepoint_t> ((u), LBase, LBase+LCount-1))
 109 #define isCombiningV(u) (hb_in_range<hb_codepoint_t> ((u), VBase, VBase+VCount-1))
 110 #define isCombiningT(u) (hb_in_range<hb_codepoint_t> ((u), TBase+1, TBase+TCount-1))
 111 #define isCombinedS(u) (hb_in_range<hb_codepoint_t> ((u), SBase, SBase+SCount-1))
 112 
 113 #define isL(u) (hb_in_ranges<hb_codepoint_t> ((u), 0x1100u, 0x115Fu, 0xA960u, 0xA97Cu))
 114 #define isV(u) (hb_in_ranges<hb_codepoint_t> ((u), 0x1160u, 0x11A7u, 0xD7B0u, 0xD7C6u))
 115 #define isT(u) (hb_in_ranges<hb_codepoint_t> ((u), 0x11A8u, 0x11FFu, 0xD7CBu, 0xD7FBu))
 116 
 117 #define isHangulTone(u) (hb_in_range<hb_codepoint_t> ((u), 0x302Eu, 0x302Fu))
 118 
 119 /* buffer var allocations */
 120 #define hangul_shaping_feature() complex_var_u8_0() /* hangul jamo shaping feature */
 121 
 122 static bool
 123 is_zero_width_char (hb_font_t *font,
 124                     hb_codepoint_t unicode)
 125 {
 126   hb_codepoint_t glyph;
 127   return hb_font_get_glyph (font, unicode, 0, &glyph) && hb_font_get_glyph_h_advance (font, glyph) == 0;
 128 }
 129 
 130 static void
 131 preprocess_text_hangul (const hb_ot_shape_plan_t *plan,
 132                         hb_buffer_t              *buffer,
 133                         hb_font_t                *font)
 134 {
 135   HB_BUFFER_ALLOCATE_VAR (buffer, hangul_shaping_feature);
 136 
 137   /* Hangul syllables come in two shapes: LV, and LVT.  Of those:


 185   buffer->clear_output ();
 186   unsigned int start = 0, end = 0; /* Extent of most recently seen syllable;
 187                                     * valid only if start < end
 188                                     */
 189   unsigned int count = buffer->len;
 190 
 191   for (buffer->idx = 0; buffer->idx < count && !buffer->in_error;)
 192   {
 193     hb_codepoint_t u = buffer->cur().codepoint;
 194 
 195     if (isHangulTone (u))
 196     {
 197       /*
 198        * We could cache the width of the tone marks and the existence of dotted-circle,
 199        * but the use of the Hangul tone mark characters seems to be rare enough that
 200        * I didn't bother for now.
 201        */
 202       if (start < end && end == buffer->out_len)
 203       {
 204         /* Tone mark follows a valid syllable; move it in front, unless it's zero width. */
 205         buffer->unsafe_to_break_from_outbuffer (start, buffer->idx);
 206         buffer->next_glyph ();
 207         if (!is_zero_width_char (font, u))
 208         {
 209           buffer->merge_out_clusters (start, end + 1);
 210           hb_glyph_info_t *info = buffer->out_info;
 211           hb_glyph_info_t tone = info[end];
 212           memmove (&info[start + 1], &info[start], (end - start) * sizeof (hb_glyph_info_t));
 213           info[start] = tone;
 214         }
 215       }
 216       else
 217       {
 218         /* No valid syllable as base for tone mark; try to insert dotted circle. */
 219         if (font->has_glyph (0x25CCu))
 220         {
 221           hb_codepoint_t chars[2];
 222           if (!is_zero_width_char (font, u)) {
 223             chars[0] = u;
 224             chars[1] = 0x25CCu;
 225           } else {


 242                               * will only be used if we set end to a later position.
 243                               */
 244 
 245     if (isL (u) && buffer->idx + 1 < count)
 246     {
 247       hb_codepoint_t l = u;
 248       hb_codepoint_t v = buffer->cur(+1).codepoint;
 249       if (isV (v))
 250       {
 251         /* Have <L,V> or <L,V,T>. */
 252         hb_codepoint_t t = 0;
 253         unsigned int tindex = 0;
 254         if (buffer->idx + 2 < count)
 255         {
 256           t = buffer->cur(+2).codepoint;
 257           if (isT (t))
 258             tindex = t - TBase; /* Only used if isCombiningT (t); otherwise invalid. */
 259           else
 260             t = 0; /* The next character was not a trailing jamo. */
 261         }
 262         buffer->unsafe_to_break (buffer->idx, buffer->idx + (t ? 3 : 2));
 263 
 264         /* We've got a syllable <L,V,T?>; see if it can potentially be composed. */
 265         if (isCombiningL (l) && isCombiningV (v) && (t == 0 || isCombiningT (t)))
 266         {
 267           /* Try to compose; if this succeeds, end is set to start+1. */
 268           hb_codepoint_t s = SBase + (l - LBase) * NCount + (v - VBase) * TCount + tindex;
 269           if (font->has_glyph (s))
 270           {
 271             buffer->replace_glyphs (t ? 3 : 2, 1, &s);
 272             if (unlikely (buffer->in_error))
 273               return;
 274             end = start + 1;
 275             continue;
 276           }
 277         }
 278 
 279         /* We didn't compose, either because it's an Old Hangul syllable without a
 280          * precomposed character in Unicode, or because the font didn't support the
 281          * necessary precomposed glyph.
 282          * Set jamo features on the individual glyphs, and advance past them.


 307       unsigned int lindex = (s - SBase) / NCount;
 308       unsigned int nindex = (s - SBase) % NCount;
 309       unsigned int vindex = nindex / TCount;
 310       unsigned int tindex = nindex % TCount;
 311 
 312       if (!tindex &&
 313           buffer->idx + 1 < count &&
 314           isCombiningT (buffer->cur(+1).codepoint))
 315       {
 316         /* <LV,T>, try to combine. */
 317         unsigned int new_tindex = buffer->cur(+1).codepoint - TBase;
 318         hb_codepoint_t new_s = s + new_tindex;
 319         if (font->has_glyph (new_s))
 320         {
 321           buffer->replace_glyphs (2, 1, &new_s);
 322           if (unlikely (buffer->in_error))
 323             return;
 324           end = start + 1;
 325           continue;
 326         }
 327         else
 328           buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); /* Mark unsafe between LV and T. */
 329       }
 330 
 331       /* Otherwise, decompose if font doesn't support <LV> or <LVT>,
 332        * or if having non-combining <LV,T>.  Note that we already handled
 333        * combining <LV,T> above. */
 334       if (!has_glyph ||
 335           (!tindex &&
 336            buffer->idx + 1 < count &&
 337            isT (buffer->cur(+1).codepoint)))
 338       {
 339         hb_codepoint_t decomposed[3] = {LBase + lindex,
 340                                         VBase + vindex,
 341                                         TBase + tindex};
 342         if (font->has_glyph (decomposed[0]) &&
 343             font->has_glyph (decomposed[1]) &&
 344             (!tindex || font->has_glyph (decomposed[2])))
 345         {
 346           unsigned int s_len = tindex ? 3 : 2;
 347           buffer->replace_glyphs (1, s_len, decomposed);
 348           if (unlikely (buffer->in_error))


 355 
 356           /* If we decomposed an LV because of a non-combining T following,
 357            * we want to include this T in the syllable.
 358            */
 359           if (has_glyph && !tindex)
 360           {
 361             buffer->next_glyph ();
 362             s_len++;
 363           }
 364           end = start + s_len;
 365 
 366           unsigned int i = start;
 367           info[i++].hangul_shaping_feature() = LJMO;
 368           info[i++].hangul_shaping_feature() = VJMO;
 369           if (i < end)
 370             info[i++].hangul_shaping_feature() = TJMO;
 371           if (buffer->cluster_level == HB_BUFFER_CLUSTER_LEVEL_MONOTONE_GRAPHEMES)
 372             buffer->merge_out_clusters (start, end);
 373           continue;
 374         }
 375         else if ((!tindex && buffer->idx + 1 < count && isT (buffer->cur(+1).codepoint)))
 376           buffer->unsafe_to_break (buffer->idx, buffer->idx + 2); /* Mark unsafe between LV and T. */
 377       }
 378 
 379       if (has_glyph)
 380       {
 381         /* We didn't decompose the S, so just advance past it. */
 382         end = start + 1;
 383         buffer->next_glyph ();
 384         continue;
 385       }
 386     }
 387 
 388     /* Didn't find a recognizable syllable, so we leave end <= start;
 389      * this will prevent tone-mark reordering happening.
 390      */
 391     buffer->next_glyph ();
 392   }
 393   buffer->swap_buffers ();
 394 }
 395 
 396 static void
 397 setup_masks_hangul (const hb_ot_shape_plan_t *plan,
 398                     hb_buffer_t              *buffer,
 399                     hb_font_t                *font HB_UNUSED)
 400 {
 401   const hangul_shape_plan_t *hangul_plan = (const hangul_shape_plan_t *) plan->data;
 402 
 403   if (likely (hangul_plan))
 404   {
 405     unsigned int count = buffer->len;
 406     hb_glyph_info_t *info = buffer->info;
 407     for (unsigned int i = 0; i < count; i++, info++)
 408       info->mask |= hangul_plan->mask_array[info->hangul_shaping_feature()];
 409   }
 410 
 411   HB_BUFFER_DEALLOCATE_VAR (buffer, hangul_shaping_feature);
 412 }
 413 
 414 
 415 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul =
 416 {

 417   collect_features_hangul,
 418   override_features_hangul,
 419   data_create_hangul,
 420   data_destroy_hangul,
 421   preprocess_text_hangul,
 422   nullptr, /* postprocess_glyphs */
 423   HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
 424   nullptr, /* decompose */
 425   nullptr, /* compose */
 426   setup_masks_hangul,
 427   nullptr, /* disable_otl */
 428   nullptr, /* reorder_marks */
 429   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
 430   false, /* fallback_position */
 431 };
< prev index next >