< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.cc

Print this page

        

@@ -83,10 +83,11 @@
                                   hb_face_t    *face,
                                   unsigned int  table_index,
                                   unsigned int  feature_index,
                                   unsigned int  variations_index,
                                   hb_mask_t     mask,
+                                  bool          auto_zwnj,
                                   bool          auto_zwj)
 {
   unsigned int lookup_indices[32];
   unsigned int offset, len;
   unsigned int table_lookup_count;

@@ -110,10 +111,11 @@
       hb_ot_map_t::lookup_map_t *lookup = m.lookups[table_index].push ();
       if (unlikely (!lookup))
         return;
       lookup->mask = mask;
       lookup->index = lookup_indices[i];
+      lookup->auto_zwnj = auto_zwnj;
       lookup->auto_zwj = auto_zwj;
     }
 
     offset += len;
   } while (len == ARRAY_LENGTH (lookup_indices));

@@ -134,11 +136,15 @@
 void
 hb_ot_map_builder_t::compile (hb_ot_map_t  &m,
                               const int    *coords,
                               unsigned int  num_coords)
 {
-  m.global_mask = 1;
+  static_assert ((!(HB_GLYPH_FLAG_DEFINED & (HB_GLYPH_FLAG_DEFINED + 1))), "");
+  unsigned int global_bit_mask = HB_GLYPH_FLAG_DEFINED + 1;
+  unsigned int global_bit_shift = _hb_popcount32 (HB_GLYPH_FLAG_DEFINED);
+
+  m.global_mask = global_bit_mask;
 
   unsigned int required_feature_index[2];
   hb_tag_t required_feature_tag[2];
   /* We default to applying required feature in stage 0.  If the required
    * feature has a tag that is known to the shaper, we apply required feature

@@ -186,11 +192,12 @@
     feature_infos.shrink (j + 1);
   }
 
 
   /* Allocate bits now */
-  unsigned int next_bit = 1;
+  unsigned int next_bit = global_bit_shift + 1;
+
   for (unsigned int i = 0; i < feature_infos.len; i++)
   {
     const feature_info_t *info = &feature_infos[i];
 
     unsigned int bits_needed;

@@ -241,15 +248,16 @@
     map->tag = info->tag;
     map->index[0] = feature_index[0];
     map->index[1] = feature_index[1];
     map->stage[0] = info->stage[0];
     map->stage[1] = info->stage[1];
+    map->auto_zwnj = !(info->flags & F_MANUAL_ZWNJ);
     map->auto_zwj = !(info->flags & F_MANUAL_ZWJ);
     if ((info->flags & F_GLOBAL) && info->max_value == 1) {
       /* Uses the global bit */
-      map->shift = 0;
-      map->mask = 1;
+      map->shift = global_bit_shift;
+      map->mask = global_bit_mask;
     } else {
       map->shift = next_bit;
       map->mask = (1u << (next_bit + bits_needed)) - (1u << next_bit);
       next_bit += bits_needed;
       m.global_mask |= (info->default_value << map->shift) & map->mask;

@@ -259,12 +267,12 @@
 
   }
   feature_infos.shrink (0); /* Done with these */
 
 
-  add_gsub_pause (NULL);
-  add_gpos_pause (NULL);
+  add_gsub_pause (nullptr);
+  add_gpos_pause (nullptr);
 
   for (unsigned int table_index = 0; table_index < 2; table_index++)
   {
     /* Collect lookup indices for features */
 

@@ -282,19 +290,19 @@
       if (required_feature_index[table_index] != HB_OT_LAYOUT_NO_FEATURE_INDEX &&
           required_feature_stage[table_index] == stage)
         add_lookups (m, face, table_index,
                      required_feature_index[table_index],
                      variations_index,
-                     1 /* mask */,
-                     true /* auto_zwj */);
+                     global_bit_mask);
 
       for (unsigned i = 0; i < m.features.len; i++)
         if (m.features[i].stage[table_index] == stage)
           add_lookups (m, face, table_index,
                        m.features[i].index[table_index],
                        variations_index,
                        m.features[i].mask,
+                       m.features[i].auto_zwnj,
                        m.features[i].auto_zwj);
 
       /* Sort lookups and merge duplicates */
       if (last_num_lookups < m.lookups[table_index].len)
       {

@@ -305,10 +313,11 @@
           if (m.lookups[table_index][i].index != m.lookups[table_index][j].index)
             m.lookups[table_index][++j] = m.lookups[table_index][i];
           else
           {
             m.lookups[table_index][j].mask |= m.lookups[table_index][i].mask;
+            m.lookups[table_index][j].auto_zwnj &= m.lookups[table_index][i].auto_zwnj;
             m.lookups[table_index][j].auto_zwj &= m.lookups[table_index][i].auto_zwj;
           }
         m.lookups[table_index].shrink (j + 1);
       }
 
< prev index next >