src/hb-shape.c |   89 ++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 76 insertions(+), 13 deletions(-)

New commits:
commit 51f141a7f38a73f671b23f58cadf97a72c43b625
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sun Dec 20 18:22:28 2009 +0100

    Avoid overflow

diff --git a/src/hb-shape.c b/src/hb-shape.c
index 0ee6fa8..e3f35ee 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -93,6 +93,8 @@ hb_map_glyphs (hb_font_t    *font,
 {
   unsigned int count;
 
+  if (HB_UNLIKELY (!buffer->in_length))
+    return;
   count = buffer->in_length - 1;
   for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) {
     if (HB_UNLIKELY (is_variation_selector (IN_NEXTGLYPH()))) {
commit 26d7a75752631b2596a5bcb7e645b34cc3d139ab
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sun Dec 20 17:58:25 2009 +0100

    Refactor hb_shape a bit

diff --git a/src/hb-shape.c b/src/hb-shape.c
index e641df4..0ee6fa8 100644
--- a/src/hb-shape.c
+++ b/src/hb-shape.c
@@ -30,6 +30,9 @@
 
 #include "hb-buffer-private.h"
 
+
+/* Prepare */
+
 static inline hb_bool_t
 is_variation_selector (hb_codepoint_t unicode)
 {
@@ -65,6 +68,9 @@ hb_ensure_native_direction (hb_buffer_t *buffer)
   return original_direction;
 }
 
+
+/* Substitute */
+
 static void
 hb_mirror_chars (hb_buffer_t *buffer)
 {
@@ -100,6 +106,35 @@ hb_map_glyphs (hb_font_t    *font,
 }
 
 static void
+hb_substitute_default (hb_font_t    *font,
+                      hb_face_t    *face,
+                      hb_buffer_t  *buffer)
+{
+  hb_mirror_chars (buffer);
+  hb_map_glyphs (font, face, buffer);
+}
+
+static gboolean
+hb_substitute_complex (hb_font_t    *font,
+                      hb_face_t    *face,
+                      hb_buffer_t  *buffer)
+{
+  /* TODO GSUB */
+ return FALSE;
+}
+
+static void
+hb_substitute_fallback (hb_font_t    *font,
+                       hb_face_t    *face,
+                       hb_buffer_t  *buffer)
+{
+  /* TODO Arabic */
+}
+
+
+/* Position */
+
+static void
 hb_position_default (hb_font_t    *font,
                     hb_face_t    *face,
                     hb_buffer_t  *buffer)
@@ -117,6 +152,23 @@ hb_position_default (hb_font_t    *font,
   }
 }
 
+static gboolean
+hb_position_complex (hb_font_t    *font,
+                    hb_face_t    *face,
+                    hb_buffer_t  *buffer)
+{
+  /* TODO GPOS */
+  return FALSE;
+}
+
+static void
+hb_position_fallback (hb_font_t    *font,
+                     hb_face_t    *face,
+                     hb_buffer_t  *buffer)
+{
+  /* TODO Mark pos */
+}
+
 static void
 hb_truetype_kern (hb_font_t    *font,
                  hb_face_t    *face,
@@ -136,6 +188,17 @@ hb_truetype_kern (hb_font_t    *font,
   }
 }
 
+static void
+hb_position_fallback_visual (hb_font_t    *font,
+                            hb_face_t    *face,
+                            hb_buffer_t  *buffer)
+{
+  hb_truetype_kern (font, face, buffer);
+}
+
+
+/* Shape */
+
 void
 hb_shape (hb_font_t    *font,
          hb_face_t    *face,
@@ -144,32 +207,30 @@ hb_shape (hb_font_t    *font,
          unsigned int  num_features)
 {
   hb_direction_t original_direction;
-  hb_bool_t complex_positioning_applied;
+  hb_bool_t substitute_fallback, position_fallback;
 
   hb_form_clusters (buffer);
   original_direction = hb_ensure_native_direction (buffer);
 
-  hb_mirror_chars (buffer);
+  hb_substitute_default (font, face, buffer);
 
-  /* OT preprocess */
+  substitute_fallback = !hb_substitute_complex (font, face, buffer);
 
-  hb_map_glyphs (font, face, buffer);
-  /* ccmp+... */
-
-  /* script-specific */
-
-  /* GSUB */
+  if (substitute_fallback)
+    hb_substitute_fallback (font, face, buffer);
 
   hb_position_default (font, face, buffer);
 
-  /* GPOS */
-  complex_positioning_applied = FALSE;
+  position_fallback = !hb_position_complex (font, face, buffer);
+
+  if (position_fallback)
+    hb_position_fallback (font, face, buffer);
 
   if (HB_DIRECTION_IS_BACKWARD (buffer->direction))
     hb_buffer_reverse (buffer);
 
-  if (!complex_positioning_applied)
-    hb_truetype_kern (font, face, buffer);
+  if (position_fallback)
+    hb_position_fallback_visual (font, face, buffer);
 
   buffer->direction = original_direction;
 }
_______________________________________________
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to