+
+ while (total_duration > 0)
+ {
+ int dl = calc_closest_duration_log (me, total_duration, false);
+ double duration = pow (2.0, -dl);
+
+ total_duration -= duration;
+
+ Stencil r = musfont->find_by_name (Rest::glyph_name (me, dl, "", true, 2));
+
+ Real staff_space = Staff_symbol_referencer::staff_space (me);
+ if (dl == 0)
+ {
+ r.translate_axis (staff_space, Y_AXIS);
+ }
+ else
+ {
+ r.translate_axis (staff_space-r.extent (Y_AXIS).at (UP), Y_AXIS);
+ }
+ symbols_width += r.extent (X_AXIS).length ();
+ mols = scm_cons (r.smobbed_copy (), mols);
+ symbol_count++;
+ }
+
+ /*
+ When symbols spread to fullest extent, outer padding is this much
+ bigger.
+ */
+ Real outer_padding_factor = 1.5;
+ /* Widest gap between symbols; to be limited by max-symbol-separation */
+ Real inner_padding = (space - symbols_width)
+ / (2 * outer_padding_factor + (symbol_count - 1));
+ if (inner_padding < 0)
+ inner_padding = 1.0;
+
+ Real max_separation = max (robust_scm2double (me->get_property ("max-symbol-separation"), 8.0),
+ 1.0);
+
+ inner_padding = min (inner_padding, max_separation);
+ Real left_offset = (space - symbols_width - (inner_padding * (symbol_count - 1)))
+ / 2;
+
+ Stencil mol;
+ for (SCM s = mols; scm_is_pair (s); s = scm_cdr (s))
+ mol.add_at_edge (X_AXIS, LEFT, *unsmob<Stencil> (scm_car (s)),
+ inner_padding);
+ mol.align_to (X_AXIS, LEFT);
+ mol.translate_axis (left_offset, X_AXIS);
+
+ return mol;