From c462b32dcb883a7aca066af24c4d28c7a2b7fa28 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 15 Feb 2013 07:51:47 -0500 Subject: [PATCH] Disable automatic segment properties guessing 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 | 1 - src/hb-ot-shape.cc | 2 -- src/hb-shape.cc | 2 -- util/options.hh | 1 + 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc index bdc8a80c4..1a1fcfbda 100644 --- a/src/hb-fallback-shape.cc +++ b/src/hb-fallback-shape.cc @@ -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; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 66d51e333..32d7afcf2 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -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); diff --git a/src/hb-shape.cc b/src/hb-shape.cc index 7ae56e39f..7d748d7d3 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc @@ -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); diff --git a/util/options.hh b/util/options.hh index 89440671f..35ea0bc14 100644 --- a/util/options.hh +++ b/util/options.hh @@ -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,