DECLARE_SCHEME_CALLBACK (y_offset_callback, (SCM));
DECLARE_SCHEME_CALLBACK (calc_cross_staff, (SCM));
DECLARE_GROB_INTERFACE ();
- static string glyph_name (Grob *, int, string, bool);
+ static string glyph_name (Grob *, int, string, bool, Real);
static Real staff_position_internal (Grob *, int /* duration_log */,
int /* dir */);
static SCM brew_internal_stencil (Grob *, bool);
Font_metric *musfont = Font_interface::get_default_font (me);
int mdl = calc_measure_duration_log (me, true);
- if (me->get_property ("staff-position") == SCM_EOL)
- {
- int dir = get_grob_direction (me);
- Real pos = Rest::staff_position_internal (me, mdl, dir);
- me->set_property ("staff-position", scm_from_double (pos));
- }
-
if (measure_count == 1)
{
+ if (me->get_property ("staff-position") == SCM_EOL)
+ {
+ int dir = get_grob_direction (me);
+ Real pos = Rest::staff_position_internal (me, mdl, dir);
+ me->set_property ("staff-position", scm_from_double (pos));
+ }
- Stencil s = musfont->find_by_name (Rest::glyph_name (me, mdl, "", true));
+ Stencil s = musfont->find_by_name (Rest::glyph_name (me, mdl, "", true, 0.0));
s.translate_axis ((space - s.extent (X_AXIS).length ()) / 2, X_AXIS);
return s;
Real symbols_width = 0.0;
double total_duration = measure_count * pow (2.0, -calc_measure_duration_log (me, true));
+ SCM staff_position = me->get_property ("staff-position");
+
+ if (!scm_is_number (staff_position))
+ {
+ // 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, true);
total_duration -= duration;
- Stencil r = musfont->find_by_name (Rest::glyph_name (me, dl, "", true));
+ 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)
{
- Real staff_space = Staff_symbol_referencer::staff_space (me);
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++;
make this function easily usable in C++
*/
string
-Rest::glyph_name (Grob *me, int durlog, string style, bool try_ledgers)
+Rest::glyph_name (Grob *me, int durlog, string style, bool try_ledgers,
+ Real offset)
{
bool is_ledgered = false;
if (try_ledgers && (durlog == -1 || durlog == 0 || durlog == 1))
{
- int const pos = int (Staff_symbol_referencer::get_position (me));
-
+ int const pos = int (Staff_symbol_referencer::get_position (me)
+ + offset);
/*
half rests need ledger if not lying on a staff line,
whole rests need ledger if not hanging from a staff line,
string style = robust_symbol2string (me->get_property ("style"), "default");
Font_metric *fm = Font_interface::get_default_font (me);
- string font_char = glyph_name (me, durlog, style, ledgered);
+ string font_char = glyph_name (me, durlog, style, ledgered, 0.0);
Stencil out = fm->find_by_name (font_char);
if (out.is_empty ())
me->warning (_f ("rest `%s' not found", font_char.c_str ()));