[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: adjusting horizontal spacing - a function dedicated to Graham
From: |
Janek Warchoł |
Subject: |
Re: adjusting horizontal spacing - a function dedicated to Graham |
Date: |
Sat, 21 Sep 2013 12:52:13 +0200 |
*Please* always reply to the whole list.
2013/9/21 Peter Gentry <address@hidden>:
> Thanks Janek
>
> Strangely as I said on the list the problem is not visible today. Errors that
> are not repeatable are notoriously difficult to track
> down. I will continue playinf with a cut down example to see if I can get
> repeatability.
For what it's worth, this minimal example is working for me (both 2.16
and 2.17.27):
stretchHorizontalSpacing =
#(define-music-function (parser location exponent) (number?)
(_i "This function determines the default value of the property
@var{common-shortest-duration} and multiplies it by a moment
derived from the @var{exponent} passed as an argument.
Negative values of @var{exponent} make the spacing tighter,
while positive values make the spacing looser.
")
#{
\override Score.SpacingSpanner #'common-shortest-duration =
#(lambda (grob)
(let* ((func (assoc-get 'common-shortest-duration
(reverse (ly:grob-basic-properties grob))))
(default-value (func grob))
;; When dealing with moments, we need to operate on an
;; exponential scale. We use 'inexact->exact' to make sure
;; that 'rationalize' will return an exact result as well.
(factor (inexact->exact (expt 2 (- 0 exponent))))
;; The second argument to 'rationalize' has to be fairly
;; small to allow lots of stretching/squeezing.
(multiplier (ly:make-moment (rationalize factor 1/2000))))
(ly:moment-mul default-value multiplier)))
#})
horizontalSpacingLoose = \stretchHorizontalSpacing #1
horizontalSpacingTight = \stretchHorizontalSpacing #-1
\layout {
\horizontalSpacingLoose
}
\bookpart {
\score {
{ c'4 d' e' f' }
}
}
\bookpart {
\score {
{ c'8 d' e' f' g' a' b' c'' }
}
}
As well as this one:
% function definitions...
\bookpart {
\score {
{ c'4 d' e' f' }
\layout {
\horizontalSpacingLoose
}
}
}
\bookpart {
\score {
{ c'8 d' e' f' g' a' b' c'' }
\layout {
\horizontalSpacingLoose
}
}
}
Note that you *cannot* place \layout block like this:
\bookpart {
\score {
{ c'4 d' e' f' }
}
\layout {
\horizontalSpacingLoose
}
}
hth, and please reply to the list,
Janek