/*
This file is part of LilyPond, the GNU music typesetter.
- Copyright (C) 1996--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ Copyright (C) 1996--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "font-interface.hh"
#include "international.hh"
#include "output-def.hh"
+#include "staff-symbol.hh"
#include "staff-symbol-referencer.hh"
#include "text-interface.hh"
#include "warn.hh"
else
m = numbered_time_signature (me, n, d);
- if (Staff_symbol_referencer::line_count (me) % 2 == 0)
- m.translate_axis (Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
+ /*
+ position the signature centred on the staff line
+ nearest to the middle of the staff
+ */
+ if (Grob *staff = Staff_symbol_referencer::get_staff_symbol (me))
+ {
+ std::vector<Real> const linepos = Staff_symbol::line_positions (staff);
+ if (!linepos.empty ())
+ {
+ Interval const span = Staff_symbol::line_span (staff);
+ Real const mid = span.center ();
+ Real pos = linepos.front ();
+ Real dist = fabs (pos - mid);
+ for (std::vector<Real>::const_iterator
+ i = linepos.begin (), e = linepos.end ();
+ ++i != e;)
+ {
+ double const d = fabs (*i - mid);
+ if (d < dist)
+ {
+ pos = *i;
+ dist = d;
+ }
+ }
+
+ m.translate_axis
+ (pos * Staff_symbol_referencer::staff_space (me) / 2, Y_AXIS);
+ }
+ }
return m.smobbed_copy ();
}
Stencil
Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d)
{
- string style = ly_scm2string (scm_symbol_to_string (scm_style));
+ string style = robust_symbol2string (scm_style, "default");
if (style == "numbered")
return numbered_time_signature (me, n, d);