Remove hb_buffer_clear_positions(), add hb_ot_layout_position_start()
authorBehdad Esfahbod <behdad@behdad.org>
Fri, 15 Apr 2011 22:59:56 +0000 (18:59 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Fri, 15 Apr 2011 23:08:43 +0000 (19:08 -0400)
src/hb-buffer-private.hh
src/hb-buffer.cc
src/hb-buffer.h
src/hb-ot-layout.cc
src/hb-ot-layout.h
src/hb-ot-shape.cc

index d8834c5..4b1ff12 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1998-2004  David Turner and Werner Lemberg
  * Copyright (C) 2004,2007,2009,2010  Red Hat, Inc.
  *
- * This is part of HarfBuzz, a text shaping library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
@@ -52,6 +52,9 @@ HB_INTERNAL void
 _hb_buffer_clear_output (hb_buffer_t *buffer);
 
 HB_INTERNAL void
+_hb_buffer_clear_positions (hb_buffer_t *buffer);
+
+HB_INTERNAL void
 _hb_buffer_replace_glyphs_be16 (hb_buffer_t *buffer,
                                unsigned int num_in,
                                unsigned int num_out,
@@ -116,6 +119,7 @@ struct _hb_buffer_t {
   inline unsigned int next_serial (void) { return serial++; }
   inline void swap (void) { _hb_buffer_swap (this); }
   inline void clear_output (void) { _hb_buffer_clear_output (this); }
+  inline void clear_positions (void) { _hb_buffer_clear_positions (this); }
   inline void next_glyph (void) { _hb_buffer_next_glyph (this); }
   inline void replace_glyphs_be16 (unsigned int num_in,
                                   unsigned int num_out,
index f5dc02f..4020d2c 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2004,2007,2009,2010  Red Hat, Inc.
  * Copyright (C) 2011  Google, Inc.
  *
- * This is part of HarfBuzz, a text shaping library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
@@ -272,16 +272,6 @@ hb_buffer_add_glyph (hb_buffer_t    *buffer,
   buffer->len++;
 }
 
-void
-hb_buffer_clear_positions (hb_buffer_t *buffer)
-{
-  _hb_buffer_clear_output (buffer);
-  buffer->have_output = FALSE;
-  buffer->have_positions = TRUE;
-
-  memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->len);
-}
-
 /* HarfBuzz-Internal API */
 
 void
@@ -289,11 +279,21 @@ _hb_buffer_clear_output (hb_buffer_t *buffer)
 {
   buffer->have_output = TRUE;
   buffer->have_positions = FALSE;
+
   buffer->out_len = 0;
   buffer->out_info = buffer->info;
 }
 
 void
+_hb_buffer_clear_positions (hb_buffer_t *buffer)
+{
+  buffer->have_output = FALSE;
+  buffer->have_positions = TRUE;
+
+  memset (buffer->pos, 0, sizeof (buffer->pos[0]) * buffer->len);
+}
+
+void
 _hb_buffer_swap (hb_buffer_t *buffer)
 {
   unsigned int tmp;
@@ -477,7 +477,7 @@ hb_glyph_position_t *
 hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
 {
   if (!buffer->have_positions)
-    hb_buffer_clear_positions (buffer);
+    _hb_buffer_clear_positions (buffer);
 
   return (hb_glyph_position_t *) buffer->pos;
 }
index 49f6a49..2151a45 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2004,2007,2009  Red Hat, Inc.
  * Copyright (C) 2011  Google, Inc.
  *
- * This is part of HarfBuzz, a text shaping library.
+ *  This is part of HarfBuzz, a text shaping library.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
@@ -102,9 +102,6 @@ hb_buffer_get_language (hb_buffer_t *buffer);
 void
 hb_buffer_reset (hb_buffer_t *buffer);
 
-void
-hb_buffer_clear_positions (hb_buffer_t *buffer);
-
 hb_bool_t
 hb_buffer_ensure (hb_buffer_t  *buffer,
                  unsigned int  size);
index fc4b1d3..f1287c5 100644 (file)
@@ -462,6 +462,12 @@ hb_ot_layout_has_positioning (hb_face_t *face)
   return &_get_gpos (face) != &Null(GPOS);
 }
 
+void
+hb_ot_layout_position_start (hb_buffer_t  *buffer)
+{
+  buffer->clear_positions ();
+}
+
 hb_bool_t
 hb_ot_layout_position_lookup   (hb_font_t    *font,
                                hb_face_t    *face,
index 9619eb7..0e0d77f 100644 (file)
@@ -179,6 +179,10 @@ hb_ot_layout_substitute_lookup (hb_face_t    *face,
 hb_bool_t
 hb_ot_layout_has_positioning (hb_face_t *face);
 
+/* Should be called before all the position_lookup's are done.  Resets positions to zero. */
+void
+hb_ot_layout_position_start (hb_buffer_t  *buffer);
+
 hb_bool_t
 hb_ot_layout_position_lookup (hb_font_t    *font,
                              hb_face_t    *face,
index 76d4a56..2364d3c 100644 (file)
@@ -249,7 +249,7 @@ hb_substitute_complex_fallback (hb_ot_shape_context_t *c HB_UNUSED)
 static void
 hb_position_default (hb_ot_shape_context_t *c)
 {
-  hb_buffer_clear_positions (c->buffer);
+  hb_ot_layout_position_start (c->buffer);
 
   unsigned int count = c->buffer->len;
   for (unsigned int i = 0; i < count; i++) {