[util] Move code around
diff --git a/util/hb-view.cc b/util/hb-view.cc
index dd31f94..5ffe9c1 100644
--- a/util/hb-view.cc
+++ b/util/hb-view.cc
@@ -61,16 +61,10 @@
 
   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 e4f1316..2b77d7b 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -63,6 +63,20 @@
     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;