From 4f4b114a5592c2f5d128ee795f159b438ad97829 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 8 Sep 2011 16:49:02 -0400 Subject: [PATCH] [util] Move code around --- util/hb-view.cc | 8 +------- util/options.hh | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/util/hb-view.cc b/util/hb-view.cc index dd31f9455..5ffe9c10d 100644 --- a/util/hb-view.cc +++ b/util/hb-view.cc @@ -61,16 +61,10 @@ _hb_cr_text_glyphs (cairo_t *cr, hb_buffer = hb_buffer_create (); - if (shape_opts->direction) - hb_buffer_set_direction (hb_buffer, hb_direction_from_string (shape_opts->direction, -1)); - if (shape_opts->script) - hb_buffer_set_script (hb_buffer, hb_script_from_string (shape_opts->script, -1)); - if (shape_opts->language) - hb_buffer_set_language (hb_buffer, hb_language_from_string (shape_opts->language, -1)); hb_buffer_add_utf8 (hb_buffer, utf8, len, 0, len); - if (!hb_shape_full (hb_font, hb_buffer, shape_opts->features, shape_opts->num_features, NULL, shape_opts->shapers)) + if (!shape_opts->shape (hb_font, hb_buffer)) fail ("All shapers failed"); num_glyphs = hb_buffer_get_length (hb_buffer); diff --git a/util/options.hh b/util/options.hh index e4f131603..2b77d7b71 100644 --- a/util/options.hh +++ b/util/options.hh @@ -63,6 +63,20 @@ extern struct shape_options_t g_free (shapers); } + void setup_buffer (hb_buffer_t *buffer) { + if (direction) + hb_buffer_set_direction (buffer, hb_direction_from_string (direction, -1)); + if (script) + hb_buffer_set_script (buffer, hb_script_from_string (script, -1)); + if (language) + hb_buffer_set_language (buffer, hb_language_from_string (language, -1)); + } + + bool shape (hb_font_t *font, hb_buffer_t *buffer) { + setup_buffer (buffer); + return hb_shape_full (font, buffer, features, num_features, NULL, shapers); + } + const char *text; const char *direction; const char *language;