[repacker] add a maximum number of roots that can be moved in one iteration.

Set to half of the roots in a space. This prevents the repacker from moving all roots in a space to a new space if their are overflows in every root.
diff --git a/src/hb-repacker.hh b/src/hb-repacker.hh
index 862ab6b..a49e8e5 100644
--- a/src/hb-repacker.hh
+++ b/src/hb-repacker.hh
@@ -745,15 +745,6 @@
     return space_for (node.parents[0], root);
   }
 
-  void roots_with_space (unsigned space, hb_set_t* roots) const
-  {
-    for (unsigned i = 0; i < vertices_.length; i++) {
-      if (vertices_[i].space == space) {
-        roots->add (i);
-      }
-    }
-  }
-
   void err_other_error () { this->successful = false; }
 
  private:
@@ -1104,6 +1095,7 @@
     unsigned root;
     unsigned overflow_space = sorted_graph.space_for (r.parent, &root);
     if (!overflow_space) continue;
+    if (sorted_graph.num_roots_for_space (overflow_space) <= 1) continue;
 
     if (!space) {
       space = overflow_space;
@@ -1115,6 +1107,17 @@
 
   if (!roots_to_isolate) return false;
 
+  unsigned maximum_to_move = hb_max ((sorted_graph.num_roots_for_space (space) / 2u), 1u);
+  if (roots_to_isolate.get_population () > maximum_to_move) {
+    // Only move at most half of the roots in a space at a time.
+    unsigned extra = roots_to_isolate.get_population () - maximum_to_move;
+    while (extra--) {
+      unsigned root = HB_SET_VALUE_INVALID;
+      roots_to_isolate.previous (&root);
+      roots_to_isolate.del (root);
+    }
+  }
+
   DEBUG_MSG (SUBSET_REPACK, nullptr,
              "Overflow in space %d (%d roots). Moving %d roots to space %d.",
              space,