Hello David,

Thanks a lot for this solution: it works for me since I have only one bar to 
span over, with LP 2.18.2 by the way.

A nice day!

JM

Le 6 oct. 2014 à 22:45:22, David Nalesnik <david.nales...@gmail.com> a écrit :

> Hi Jacques,
> 
> On Mon, Oct 6, 2014 at 1:32 PM, Jacques Menu <imj-...@bluewin.ch> wrote:
> Hello folks,
> 
> I’d like to produce the text « très vite » in the same way as this:
> 
> <TresViteCentre.png>
> 
> But I failed at finding a way with the usual spanners, that accept text at 
> both sides but not in the middle it seems.
> 
> Thanks for you help!
> 
> This has been requested before.  Unfortunately, there is currently no ability 
> to center text on spanners like this.  It is possible to hack into the 
> stencil function of the MeasureCounter grob to produce something like what 
> you're after, though.
> 
> There's a snippet on openlilylib which does this.  I've fixed it up a little 
> so that it will behave if you were to break your measure in the middle.
> 
> There are limitations.  First, it's a bit off-putting to use a grob for a 
> purpose it's not intended for.  Second, you can only use it for 
> single-measure spans.  The Measure_counter_engraver will duplicate the 
> spanner for each additional measure. 
> 
> Now, it shouldn't be too difficult to write up a new grob which addresses 
> these issues.  (I've promised this to Kieren, but I haven't had the time. 
> Hopefully, I'll have some soon.)
> 
> It would be nice to have this functionality built into TextSpanner, of 
> course. First things first.
> 
> Hope this is helpful.
> 
> David
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \version "2.19.10"
> 
> %%%%%%%%%%%%%%%%%%%
> %   THE SNIPPET   %
> %%%%%%%%%%%%%%%%%%%
> 
> % The following procedure is a modification of the function
> % `measure-counter-stencil' found in the file
> % `scm/music-functions.scm' in the LilyPond distribution.
> 
> #(define (test-stencil grob text)
>    (let* ((orig (ly:grob-original grob))
>           (siblings (ly:spanner-broken-into orig)) ; have we been split?
>           (refp (ly:grob-system grob))
>           (left-bound (ly:spanner-bound grob LEFT))
>           (right-bound (ly:spanner-bound grob RIGHT))
>           (elts-L (ly:grob-array->list (ly:grob-object left-bound 'elements)))
>           (elts-R (ly:grob-array->list (ly:grob-object right-bound 
> 'elements)))
>           (break-alignment-L
>            (filter
>             (lambda (elt) (grob::has-interface elt 
> 'break-alignment-interface))
>             elts-L))
>           (break-alignment-R
>            (filter
>             (lambda (elt) (grob::has-interface elt 
> 'break-alignment-interface))
>             elts-R))
>           (break-alignment-L-ext (ly:grob-extent (car break-alignment-L) refp 
> X))
>           (break-alignment-R-ext (ly:grob-extent (car break-alignment-R) refp 
> X))
>           (num
>            (markup text))
>           (num
>            (if (or (null? siblings)
>                    (eq? grob (car siblings)))
>                num
>                (make-parenthesize-markup num)))
>           (num (grob-interpret-markup grob num))
>           (num-stil-ext-X (ly:stencil-extent num X))
>           (num-stil-ext-Y (ly:stencil-extent num Y))
>           (num (ly:stencil-aligned-to num X (ly:grob-property grob 
> 'self-alignment-X)))
>           (num
>            (ly:stencil-translate-axis
>             num
>             (+ (interval-length break-alignment-L-ext)
>               (* 0.5
>                 (- (car break-alignment-R-ext)
>                   (cdr break-alignment-L-ext))))
>             X))
>           (bracket-L
>            (markup
>             #:path
>             0.1 ; line-thickness
>             `((moveto 0.5 ,(* 0.5 (interval-length num-stil-ext-Y)))
>               (lineto ,(* 0.5
>                          (- (car break-alignment-R-ext)
>                            (cdr break-alignment-L-ext)
>                            (interval-length num-stil-ext-X)))
>                 ,(* 0.5 (interval-length num-stil-ext-Y)))
>               (closepath)
>               (rlineto 0.0
>                 ,(if (or (null? siblings) (eq? grob (car siblings)))
>                      -1.0 0.0)))))
>           (bracket-R
>            (markup
>             #:path
>             0.1
>             `((moveto ,(* 0.5
>                          (- (car break-alignment-R-ext)
>                            (cdr break-alignment-L-ext)
>                            (interval-length num-stil-ext-X)))
>                 ,(* 0.5 (interval-length num-stil-ext-Y)))
>               (lineto 0.5
>                 ,(* 0.5 (interval-length num-stil-ext-Y)))
>               (closepath)
>               (rlineto 0.0
>                 ,(if (or (null? siblings) (eq? grob (last siblings)))
>                      -1.0 0.0)))))
>           (bracket-L (grob-interpret-markup grob bracket-L))
>           (bracket-R (grob-interpret-markup grob bracket-R))
>           (num (ly:stencil-combine-at-edge num X LEFT bracket-L 0.4))
>           (num (ly:stencil-combine-at-edge num X RIGHT bracket-R 0.4)))
>      num))
> 
> %%%%%%%%%%%%%%%%%%%%%
> %   USAGE EXAMPLE   %
> %%%%%%%%%%%%%%%%%%%%%
> <<
>   \new Voice = "notes" {
>     \relative c {
>       s1
>       \override Staff.MeasureCounter.font-encoding = #'latin1
>       \override Staff.MeasureCounter.font-size = 0
>       \override Staff.MeasureCounter.stencil =
>       #(lambda (grob) (test-stencil grob #{ \markup \italic "trés vite" #} ))
>       
>       \startMeasureCount
>       e8(\fff f! gis? bes fis?16 g! a! b! c!8^\staccato^\tenuto) r
>       \stopMeasureCount
>     }
>   }
> >>
> 
> \layout {
>   \context {
>     \Staff
>     \consists #Measure_counter_engraver
>   }
> }
>  
> %%%%%%%%%%%%%%%%%%%%%%%
> <measure-counter-hack.png>

Bien à vous,
Regards,

--

Dr Jacques MENU
SCITAS - HPC-Systems
http://scitas.epfl.ch/
mailto:1...@epfl.ch

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to