- if (sml == SCM_BOOL_T)
- {
- int k;
- if (l >= 2)
- {
- l -= 2;
- k = -2;
- }
- else
- {
- l -= 1;
- k = -1;
- }
-
- Stencil r (musfont->find_by_name ("rests." + to_string (k)));
- symbols_width += r.extent (X_AXIS).length ();
- mols = scm_cons (r.smobbed_copy (), mols);
- }
- else
- {
- int k;
- if (l >= 4)
- {
- l -= 4;
- k = -2;
- }
- else if (l>= 2)
- {
- l -= 2;
- k = -1;
- }
- else
- {
- k = 0;
- l--;
- }
-
- Stencil r (musfont->find_by_name ("rests." + to_string (k)));
- if (k == 0)
- {
- Real staff_space = Staff_symbol_referencer::staff_space (me);
- r.translate_axis (staff_space, Y_AXIS);
- }
- symbols_width += r.extent (X_AXIS).length ();
- mols = scm_cons (r.smobbed_copy (), mols);
- }
- count ++;
+ // Staff position is somewhat icky regarding its definition for
+ // compatibility reasons. It is intended to be the baseline of
+ // a breve rest. However, when the staff space is more than
+ // single space (like with tablature), it looks better if all
+ // rests are actually hanging. So staff position, in reality,
+ // is the semi-breve position - 2. Everything else is
+ // calculated from there.
+ int dir = get_grob_direction (me);
+ Real pos = Rest::staff_position_internal (me, 0, dir);
+ me->set_property ("staff-position", scm_from_double (pos - 2));
+ }
+
+ 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++;