Move code around
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 28 Oct 2010 02:48:31 +0000 (22:48 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 2 Nov 2010 23:12:59 +0000 (19:12 -0400)
src/hb-ot-layout-gpos-private.hh
src/hb-ot-layout.cc
src/hb-ot-layout.h
src/hb-ot-shape.cc

index 2cfabf9..4903709 100644 (file)
@@ -1472,6 +1472,8 @@ struct GPOS : GSUBGPOS
                               hb_mask_t     mask) const
   { return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
 
+  static inline void position_finish (hb_buffer_t *buffer);
+
   inline bool sanitize (hb_sanitize_context_t *c) {
     TRACE_SANITIZE ();
     if (unlikely (!GSUBGPOS::sanitize (c))) return false;
@@ -1482,6 +1484,63 @@ struct GPOS : GSUBGPOS
   DEFINE_SIZE_STATIC (10);
 };
 
+void
+GPOS::position_finish (hb_buffer_t *buffer)
+{
+  unsigned int i, j;
+  unsigned int len = hb_buffer_get_length (buffer);
+  hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer);
+  hb_direction_t direction = buffer->props.direction;
+
+  /* Handle cursive connections:
+   * First handle all chain-back connections, then handle all chain-forward connections. */
+  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
+  {
+    for (j = 0; j < len; j++) {
+      if (pos[j].cursive_chain() < 0)
+       pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset;
+    }
+    for (i = len; i > 0; i--) {
+      j = i - 1;
+      if (pos[j].cursive_chain() > 0)
+       pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset;
+    }
+  }
+  else
+  {
+    for (j = 0; j < len; j++) {
+      if (pos[j].cursive_chain() < 0)
+       pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset;
+    }
+    for (i = len; i > 0; i--) {
+      j = i - 1;
+      if (pos[j].cursive_chain() > 0)
+       pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset;
+    }
+  }
+
+
+  /* Handle attachments */
+  for (i = 0; i < len; i++)
+    if (pos[i].back())
+    {
+      unsigned int back = i - pos[i].back();
+      pos[i].x_offset += pos[back].x_offset;
+      pos[i].y_offset += pos[back].y_offset;
+
+      if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
+       for (j = back + 1; j < i + 1; j++) {
+         pos[i].x_offset += pos[j].x_advance;
+         pos[i].y_offset += pos[j].y_advance;
+       }
+      else
+       for (j = back; j < i; j++) {
+         pos[i].x_offset -= pos[j].x_advance;
+         pos[i].y_offset -= pos[j].y_advance;
+       }
+    }
+}
+
 
 /* Out-of-class implementation for methods recursing */
 
index 98004e9..fb6914d 100644 (file)
@@ -447,64 +447,9 @@ hb_ot_layout_position_lookup   (hb_font_t    *font,
 }
 
 void
-hb_ot_layout_position_finish (hb_font_t    *font HB_UNUSED,
-                             hb_face_t    *face HB_UNUSED,
-                             hb_buffer_t  *buffer)
+hb_ot_layout_position_finish (hb_buffer_t  *buffer)
 {
-  unsigned int i, j;
-  unsigned int len = hb_buffer_get_length (buffer);
-  hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer);
-  hb_direction_t direction = buffer->props.direction;
-
-  /* TODO: Vertical */
-
-  /* Handle cursive connections:
-   * First handle all chain-back connections, then handle all chain-forward connections. */
-  if (likely (HB_DIRECTION_IS_HORIZONTAL (direction)))
-  {
-    for (j = 0; j < len; j++) {
-      if (pos[j].cursive_chain() < 0)
-       pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset;
-    }
-    for (i = len; i > 0; i--) {
-      j = i - 1;
-      if (pos[j].cursive_chain() > 0)
-       pos[j].y_offset += pos[j + pos[j].cursive_chain()].y_offset;
-    }
-  }
-  else
-  {
-    for (j = 0; j < len; j++) {
-      if (pos[j].cursive_chain() < 0)
-       pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset;
-    }
-    for (i = len; i > 0; i--) {
-      j = i - 1;
-      if (pos[j].cursive_chain() > 0)
-       pos[j].x_offset += pos[j + pos[j].cursive_chain()].x_offset;
-    }
-  }
-
-
-  /* Handle attachments */
-  for (i = 0; i < len; i++)
-    if (pos[i].back())
-    {
-      unsigned int back = i - pos[i].back();
-      pos[i].x_offset += pos[back].x_offset;
-      pos[i].y_offset += pos[back].y_offset;
-
-      if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
-       for (j = back + 1; j < i + 1; j++) {
-         pos[i].x_offset += pos[j].x_advance;
-         pos[i].y_offset += pos[j].y_advance;
-       }
-      else
-       for (j = back; j < i; j++) {
-         pos[i].x_offset -= pos[j].x_advance;
-         pos[i].y_offset -= pos[j].y_advance;
-       }
-    }
+  GPOS::position_finish (buffer);
 }
 
 
index 58c0fbe..9619eb7 100644 (file)
@@ -188,9 +188,7 @@ hb_ot_layout_position_lookup (hb_font_t    *font,
 
 /* Should be called after all the position_lookup's are done */
 void
-hb_ot_layout_position_finish (hb_font_t    *font,
-                             hb_face_t    *face,
-                             hb_buffer_t  *buffer);
+hb_ot_layout_position_finish (hb_buffer_t  *buffer);
 
 
 HB_END_DECLS
index 06316bc..a4e568d 100644 (file)
@@ -121,7 +121,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
 
   c->plan->map.position (c->font, c->face, c->buffer);
 
-  hb_ot_layout_position_finish (c->font, c->face, c->buffer);
+  hb_ot_layout_position_finish (c->buffer);
 
   c->applied_position_complex = TRUE;
   return;