Disable automatic segment properties guessing
authorBehdad Esfahbod <behdad@behdad.org>
Fri, 15 Feb 2013 12:51:47 +0000 (07:51 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Fri, 15 Feb 2013 12:51:47 +0000 (07:51 -0500)
Before, if one called hb_shape() without setting script, language, and
direction on the buffer, hb_shape() was calling
hb_buffer_guess_segment_properties() on the user's behalf to guess
these.

This is very dangerous, since any serious user of HarfBuzz must set
these properly (specially important is direction).  So now, we don't
guess properties by default.  People not setting direction will get
an abort() now.  If the old behavior is desired (fragile, good for
simple testing only), users can call
hb_buffer_guess_segment_properties() on the buffer just before calling
hb_shape().

src/hb-fallback-shape.cc
src/hb-ot-shape.cc
src/hb-shape.cc
util/options.hh

index bdc8a80..1a1fcfb 100644 (file)
@@ -98,7 +98,6 @@ _hb_fallback_shape (hb_shape_plan_t    *shape_plan HB_UNUSED,
   hb_codepoint_t space;
   font->get_glyph (' ', 0, &space);
 
-  buffer->guess_segment_properties ();
   buffer->clear_positions ();
 
   unsigned int count = buffer->len;
index 66d51e3..32d7afc 100644 (file)
@@ -663,8 +663,6 @@ hb_ot_shape_glyphs_closure (hb_font_t          *font,
 {
   hb_ot_shape_plan_t plan;
 
-  buffer->guess_segment_properties ();
-
   const char *shapers[] = {"ot", NULL};
   hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props,
                                                             features, num_features, shapers);
index 7ae56e3..7d748d7 100644 (file)
@@ -255,8 +255,6 @@ hb_shape_full (hb_font_t          *font,
 
   assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
 
-  buffer->guess_segment_properties ();
-
   hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, features, num_features, shaper_list);
   hb_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features);
   hb_shape_plan_destroy (shape_plan);
index 8944067..35ea0bc 100644 (file)
@@ -170,6 +170,7 @@ struct shape_options_t : option_group_t
                         (bot ? HB_BUFFER_FLAG_BOT : 0) |
                         (eot ? HB_BUFFER_FLAG_EOT : 0) |
                         (preserve_default_ignorables ? HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES : 0)));
+    hb_buffer_guess_segment_properties (buffer);
   }
 
   void populate_buffer (hb_buffer_t *buffer, const char *text, int text_len,