Massage mask setting a bit more
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 13 Oct 2010 22:33:16 +0000 (18:33 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 13 Oct 2010 22:33:16 +0000 (18:33 -0400)
Still finding the exact correct way the masks should be set.

src/hb-buffer-private.hh
src/hb-buffer.cc
src/hb-ot-shape.cc

index 8154b17..585a82a 100644 (file)
@@ -107,6 +107,10 @@ _hb_buffer_reset_masks (hb_buffer_t *buffer,
 
 HB_INTERNAL void
 _hb_buffer_add_masks (hb_buffer_t *buffer,
+                     hb_mask_t    mask);
+
+HB_INTERNAL void
+_hb_buffer_set_masks (hb_buffer_t *buffer,
                      hb_mask_t    value,
                      hb_mask_t    mask,
                      unsigned int cluster_start,
@@ -165,12 +169,21 @@ struct _hb_buffer_t {
   { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
   inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
 
-  inline void reset_masks (hb_mask_t mask) { _hb_buffer_reset_masks (this, mask); }
-  inline void add_masks (hb_mask_t value,
+  inline void reset_masks (hb_mask_t mask)
+  {
+    for (unsigned int i = 0; i < len; i++)
+      info[i].mask = mask;
+  }
+  inline void add_masks (hb_mask_t mask)
+  {
+    for (unsigned int i = 0; i < len; i++)
+      info[i].mask |= mask;
+  }
+  inline void set_masks (hb_mask_t value,
                         hb_mask_t mask,
                         unsigned int cluster_start,
                         unsigned int cluster_end)
-  { _hb_buffer_add_masks (this, value, mask, cluster_start, cluster_end); }
+  { _hb_buffer_set_masks (this, value, mask, cluster_start, cluster_end); }
 
 };
 
index c6bceeb..930f380 100644 (file)
@@ -470,6 +470,15 @@ _hb_buffer_reset_masks (hb_buffer_t *buffer,
 
 void
 _hb_buffer_add_masks (hb_buffer_t *buffer,
+                     hb_mask_t    mask)
+{
+  unsigned int count = buffer->len;
+  for (unsigned int i = 0; i < count; i++)
+    buffer->info[i].mask |= mask;
+}
+
+void
+_hb_buffer_set_masks (hb_buffer_t *buffer,
                      hb_mask_t    value,
                      hb_mask_t    mask,
                      unsigned int cluster_start,
index ee5f796..7b4a451 100644 (file)
@@ -88,13 +88,15 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
 
   hb_ot_shape_complex_setup_masks (c);
 
+  c->buffer->reset_masks (global_mask);
+
   for (unsigned int i = 0; i < c->num_user_features; i++)
   {
     const hb_feature_t *feature = &c->user_features[i];
     if (!(feature->start == 0 && feature->end == (unsigned int)-1)) {
       unsigned int shift;
       hb_mask_t mask = c->plan->map.get_mask (feature->tag, &shift);
-      c->buffer->add_masks (feature->value << shift, mask, feature->start, feature->end);
+      c->buffer->set_masks (feature->value << shift, mask, feature->start, feature->end);
     }
   }
 }
@@ -180,7 +182,7 @@ hb_mirror_chars (hb_ot_shape_context_t *c)
   for (unsigned int i = 0; i < count; i++) {
     hb_codepoint_t codepoint = get_mirroring (c->buffer->info[i].codepoint);
     if (likely (codepoint == c->buffer->info[i].codepoint))
-      c->buffer->info[i].mask |= rtlm_mask;
+      c->buffer->info[i].mask |= rtlm_mask; /* XXX this should be moved to before setting user-feature masks */
     else
       c->buffer->info[i].codepoint = codepoint;
   }