Move setting lig_id/component out of buffer and to the gsub code
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 27 Oct 2010 20:51:02 +0000 (16:51 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 2 Nov 2010 23:12:58 +0000 (19:12 -0400)
src/hb-buffer-private.hh
src/hb-buffer.cc
src/hb-ot-layout-gsub-private.hh

index b5ba57d..97da610 100644 (file)
@@ -62,23 +62,17 @@ HB_INTERNAL void
 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
                              unsigned int num_in,
                              unsigned int num_out,
-                             const hb_codepoint_t *glyph_data,
-                             unsigned short component,
-                             unsigned short ligID);
+                             const hb_codepoint_t *glyph_data);
 
 HB_INTERNAL void
 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
                                   unsigned int num_in,
                                   unsigned int num_out,
-                                  const uint16_t *glyph_data_be,
-                                  unsigned short component,
-                                  unsigned short ligID);
+                                  const uint16_t *glyph_data_be);
 
 HB_INTERNAL void
 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
-                            hb_codepoint_t glyph_index,
-                            unsigned short component,
-                            unsigned short ligID);
+                            hb_codepoint_t glyph_index);
 
 HB_INTERNAL void
 _hb_buffer_next_glyph (hb_buffer_t *buffer);
@@ -136,20 +130,14 @@ struct _hb_buffer_t {
   inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
   inline void add_output_glyphs (unsigned int num_in,
                                 unsigned int num_out,
-                                const hb_codepoint_t *glyph_data,
-                                unsigned short component,
-                                unsigned short ligID)
-  { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data, component, ligID); }
+                                const hb_codepoint_t *glyph_data)
+  { _hb_buffer_add_output_glyphs (this, num_in, num_out, glyph_data); }
   inline void add_output_glyphs_be16 (unsigned int num_in,
                                      unsigned int num_out,
-                                     const uint16_t *glyph_data_be,
-                                     unsigned short component,
-                                     unsigned short ligID)
-  { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be, component, ligID); }
-  inline void add_output_glyph (hb_codepoint_t glyph_index,
-                               unsigned short component = 0xFFFF,
-                               unsigned short ligID = 0xFFFF)
-  { _hb_buffer_add_output_glyph (this, glyph_index, component, ligID); }
+                                     const uint16_t *glyph_data_be)
+  { _hb_buffer_add_output_glyphs_be16 (this, num_in, num_out, glyph_data_be); }
+  inline void add_output_glyph (hb_codepoint_t glyph_index)
+  { _hb_buffer_add_output_glyph (this, glyph_index); }
   inline void replace_glyph (hb_codepoint_t glyph_index) { add_output_glyph (glyph_index); }
 
   inline void reset_masks (hb_mask_t mask)
index 7b15de4..7eb0370 100644 (file)
@@ -314,14 +314,8 @@ void
 _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
                              unsigned int num_in,
                              unsigned int num_out,
-                             const hb_codepoint_t *glyph_data,
-                             unsigned short component,
-                             unsigned short lig_id)
+                             const hb_codepoint_t *glyph_data)
 {
-  unsigned int i;
-  unsigned int mask;
-  unsigned int cluster;
-
   if (buffer->out_info != buffer->info ||
       buffer->out_len + num_out > buffer->i + num_in)
   {
@@ -329,21 +323,13 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
       return;
   }
 
-  mask = buffer->info[buffer->i].mask;
-  cluster = buffer->info[buffer->i].cluster;
-  if (component == 0xFFFF)
-    component = buffer->info[buffer->i].component();
-  if (lig_id == 0xFFFF)
-    lig_id = buffer->info[buffer->i].lig_id();
+  hb_glyph_info_t orig_info = buffer->info[buffer->i];
 
-  for (i = 0; i < num_out; i++)
+  for (unsigned int i = 0; i < num_out; i++)
   {
     hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
+    *info = orig_info;
     info->codepoint = glyph_data[i];
-    info->mask = mask;
-    info->cluster = cluster;
-    info->component() = component;
-    info->lig_id() = lig_id;
     info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
   }
 
@@ -355,14 +341,8 @@ void
 _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
                                   unsigned int num_in,
                                   unsigned int num_out,
-                                  const uint16_t *glyph_data_be,
-                                  unsigned short component,
-                                  unsigned short lig_id)
+                                  const uint16_t *glyph_data_be)
 {
-  unsigned int i;
-  unsigned int mask;
-  unsigned int cluster;
-
   if (buffer->out_info != buffer->info ||
       buffer->out_len + num_out > buffer->i + num_in)
   {
@@ -370,21 +350,13 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
       return;
   }
 
-  mask = buffer->info[buffer->i].mask;
-  cluster = buffer->info[buffer->i].cluster;
-  if (component == 0xFFFF)
-    component = buffer->info[buffer->i].component();
-  if (lig_id == 0xFFFF)
-    lig_id = buffer->info[buffer->i].lig_id();
+  hb_glyph_info_t orig_info = buffer->info[buffer->i];
 
-  for (i = 0; i < num_out; i++)
+  for (unsigned int i = 0; i < num_out; i++)
   {
     hb_glyph_info_t *info = &buffer->out_info[buffer->out_len + i];
+    *info = orig_info;
     info->codepoint = hb_be_uint16 (glyph_data_be[i]);
-    info->mask = mask;
-    info->cluster = cluster;
-    info->component() = component;
-    info->lig_id() = lig_id;
     info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
   }
 
@@ -394,9 +366,7 @@ _hb_buffer_add_output_glyphs_be16 (hb_buffer_t *buffer,
 
 void
 _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
-                            hb_codepoint_t glyph_index,
-                            unsigned short component,
-                            unsigned short lig_id)
+                            hb_codepoint_t glyph_index)
 {
   hb_glyph_info_t *info;
 
@@ -410,10 +380,6 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
 
   info = &buffer->out_info[buffer->out_len];
   info->codepoint = glyph_index;
-  if (component != 0xFFFF)
-    info->component() = component;
-  if (lig_id != 0xFFFF)
-    info->lig_id() = lig_id;
   info->gproperty() = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
 
   buffer->i++;
index 89d2fb4..829217c 100644 (file)
@@ -164,9 +164,7 @@ struct Sequence
     if (unlikely (!substitute.len))
       return false;
 
-    c->buffer->add_output_glyphs_be16 (1,
-                                      substitute.len, (const uint16_t *) substitute.array,
-                                      0xFFFF, 0xFFFF);
+    c->buffer->add_output_glyphs_be16 (1, substitute.len, (const uint16_t *) substitute.array);
 
     /* This is a guess only ... */
     if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
@@ -392,15 +390,18 @@ struct Ligature
                                     is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
                                             : HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
 
+    /* Allocate new ligature id */
+    unsigned int lig_id = c->buffer->allocate_lig_id ();
+    c->buffer->info[c->buffer->i].component() = 0;
+    c->buffer->info[c->buffer->i].lig_id() = lig_id;
+
     if (j == c->buffer->i + i) /* No input glyphs skipped */
-      c->buffer->add_output_glyphs_be16 (i,
-                                        1, (const uint16_t *) &ligGlyph,
-                                        0,
-                                        c->buffer->allocate_lig_id ());
+    {
+      c->buffer->add_output_glyphs_be16 (i, 1, (const uint16_t *) &ligGlyph);
+    }
     else
     {
-      unsigned int lig_id = c->buffer->allocate_lig_id ();
-      c->buffer->add_output_glyph (ligGlyph, 0, lig_id);
+      c->buffer->add_output_glyph (ligGlyph);
 
       /* Now we must do a second loop to copy the skipped glyphs to
         `out' and assign component values to it.  We start with the
@@ -409,10 +410,14 @@ struct Ligature
         value it is later possible to check whether a specific
         component value really belongs to a given ligature. */
 
-      for ( i = 1; i < count; i++ )
+      for (i = 1; i < count; i++)
       {
        while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_flag, NULL))
-         c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint, i, lig_id);
+       {
+         c->buffer->info[c->buffer->i].component() = i;
+         c->buffer->info[c->buffer->i].lig_id() = lig_id;
+         c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint);
+       }
 
        /* Skip the base glyph */
        c->buffer->i++;