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().
This commit is contained in:
Behdad Esfahbod 2013-02-15 07:51:47 -05:00
parent 7abddbb47a
commit c462b32dcb
4 changed files with 1 additions and 5 deletions

View File

@ -98,7 +98,6 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
hb_codepoint_t space; hb_codepoint_t space;
font->get_glyph (' ', 0, &space); font->get_glyph (' ', 0, &space);
buffer->guess_segment_properties ();
buffer->clear_positions (); buffer->clear_positions ();
unsigned int count = buffer->len; unsigned int count = buffer->len;

View File

@ -663,8 +663,6 @@ hb_ot_shape_glyphs_closure (hb_font_t *font,
{ {
hb_ot_shape_plan_t plan; hb_ot_shape_plan_t plan;
buffer->guess_segment_properties ();
const char *shapers[] = {"ot", NULL}; const char *shapers[] = {"ot", NULL};
hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props, hb_shape_plan_t *shape_plan = hb_shape_plan_create_cached (font->face, &buffer->props,
features, num_features, shapers); features, num_features, shapers);

View File

@ -255,8 +255,6 @@ hb_shape_full (hb_font_t *font,
assert (buffer->content_type == HB_BUFFER_CONTENT_TYPE_UNICODE); 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_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_bool_t res = hb_shape_plan_execute (shape_plan, font, buffer, features, num_features);
hb_shape_plan_destroy (shape_plan); hb_shape_plan_destroy (shape_plan);

View File

@ -170,6 +170,7 @@ struct shape_options_t : option_group_t
(bot ? HB_BUFFER_FLAG_BOT : 0) | (bot ? HB_BUFFER_FLAG_BOT : 0) |
(eot ? HB_BUFFER_FLAG_EOT : 0) | (eot ? HB_BUFFER_FLAG_EOT : 0) |
(preserve_default_ignorables ? HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES : 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, void populate_buffer (hb_buffer_t *buffer, const char *text, int text_len,