- Real ss = sp->paper_l ()->get_var ("staffspace");
- Real lt = sp->paper_l ()->get_var ("stafflinethickness");
- Real th = gh_scm2double (sp->get_elt_property ("thickness")) * lt ;
- Real h = gh_scm2double (sp->get_elt_property ("height")) * ss;
- Real l = gh_scm2double (sp->get_elt_property ("minimum-length")) * ss;
- Real w = bounds.length ();
- /* First try: just make the hyphen take 1/3 of the available space
- for length, use a geometric mean of the available space and some minimum
- */
- if(l < w)
- l = sqrt(l*w);
-
- Box b (Interval (-l/2,l/2), Interval (h,h+th));
- Molecule mol (sp->lookup_l ()->filledbox (b));
- mol.translate_axis (bounds.center ()
- -sp->relative_coordinate (common, X_AXIS),
- X_AXIS);
- return mol.create_scheme ();
+ /* for length, use a geometric mean of the available space and some minimum
+ */
+ if (l < w)
+ {
+ l = sqrt (l*w);
+ if (l > x)
+ l = x;
+ }
+ else
+ {
+ /* OK, we have a problem. Usually this means that we're on the
+ first column, and we have a long lyric which extends to near
+ the offset for stuff */
+ /* This test for being on the first column has been shamelessly
+ ripped from spanner.cc */
+ Paper_column *sc = dynamic_cast<Paper_column*> (sp->get_bound (LEFT)->column_l ());
+ if (sc != NULL &&
+ sc->break_status_dir () == RIGHT)
+ {
+ /* We are on the first column, so it's probably harmless to
+ get the minimum length back by extending leftwards into
+ the space under the clef/key sig/time sig */
+ bounds[LEFT] = bounds[RIGHT] - l;
+ }
+ else
+ {
+ /* We can't get the length desired. Maybe we should warn. */
+ l = w;
+ }
+ }
+ Box b (Interval (-l/2,l/2), Interval (h,h+th));
+ Molecule mol (Lookup::filledbox (b));
+ Real ct = bounds.empty_b () ? 0 : bounds.center () ;
+ mol.translate_axis (ct -sp->relative_coordinate (common, X_AXIS), X_AXIS);
+ return mol.smobbed_copy ();