src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-thai.cc
changeset 50826 f5b95be8b6e2
parent 48274 51772bf1fb0c
child 54232 7c11a7cc7c1d
equal deleted inserted replaced
50825:aa0a35b071fb 50826:f5b95be8b6e2
   258                       hb_buffer_t              *buffer,
   258                       hb_buffer_t              *buffer,
   259                       hb_font_t                *font)
   259                       hb_font_t                *font)
   260 {
   260 {
   261   /* This function implements the shaping logic documented here:
   261   /* This function implements the shaping logic documented here:
   262    *
   262    *
   263    *   http://linux.thai.net/~thep/th-otf/shaping.html
   263    *   https://linux.thai.net/~thep/th-otf/shaping.html
   264    *
   264    *
   265    * The first shaping rule listed there is needed even if the font has Thai
   265    * The first shaping rule listed there is needed even if the font has Thai
   266    * OpenType tables.  The rest do fallback positioning based on PUA codepoints.
   266    * OpenType tables.  The rest do fallback positioning based on PUA codepoints.
   267    * We implement that only if there exist no Thai GSUB in the font.
   267    * We implement that only if there exist no Thai GSUB in the font.
   268    */
   268    */
   313 #define SARA_AA_FROM_SARA_AM(x) ((x) - 1)
   313 #define SARA_AA_FROM_SARA_AM(x) ((x) - 1)
   314 #define IS_TONE_MARK(x) (hb_in_ranges<hb_codepoint_t> ((x) & ~0x0080u, 0x0E34u, 0x0E37u, 0x0E47u, 0x0E4Eu, 0x0E31u, 0x0E31u))
   314 #define IS_TONE_MARK(x) (hb_in_ranges<hb_codepoint_t> ((x) & ~0x0080u, 0x0E34u, 0x0E37u, 0x0E47u, 0x0E4Eu, 0x0E31u, 0x0E31u))
   315 
   315 
   316   buffer->clear_output ();
   316   buffer->clear_output ();
   317   unsigned int count = buffer->len;
   317   unsigned int count = buffer->len;
   318   for (buffer->idx = 0; buffer->idx < count && !buffer->in_error;)
   318   for (buffer->idx = 0; buffer->idx < count && buffer->successful;)
   319   {
   319   {
   320     hb_codepoint_t u = buffer->cur().codepoint;
   320     hb_codepoint_t u = buffer->cur().codepoint;
   321     if (likely (!IS_SARA_AM (u))) {
   321     if (likely (!IS_SARA_AM (u))) {
   322       buffer->next_glyph ();
   322       buffer->next_glyph ();
   323       continue;
   323       continue;
   325 
   325 
   326     /* Is SARA AM. Decompose and reorder. */
   326     /* Is SARA AM. Decompose and reorder. */
   327     hb_codepoint_t decomposed[2] = {hb_codepoint_t (NIKHAHIT_FROM_SARA_AM (u)),
   327     hb_codepoint_t decomposed[2] = {hb_codepoint_t (NIKHAHIT_FROM_SARA_AM (u)),
   328                                     hb_codepoint_t (SARA_AA_FROM_SARA_AM (u))};
   328                                     hb_codepoint_t (SARA_AA_FROM_SARA_AM (u))};
   329     buffer->replace_glyphs (1, 2, decomposed);
   329     buffer->replace_glyphs (1, 2, decomposed);
   330     if (unlikely (buffer->in_error))
   330     if (unlikely (!buffer->successful))
   331       return;
   331       return;
   332 
   332 
   333     /* Make Nikhahit be recognized as a ccc=0 mark when zeroing widths. */
   333     /* Make Nikhahit be recognized as a ccc=0 mark when zeroing widths. */
   334     unsigned int end = buffer->out_len;
   334     unsigned int end = buffer->out_len;
   335     _hb_glyph_info_set_general_category (&buffer->out_info[end - 2], HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK);
   335     _hb_glyph_info_set_general_category (&buffer->out_info[end - 2], HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK);