lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic text spanner after breaking


From: Thomas Morley
Subject: Re: dynamic text spanner after breaking
Date: Mon, 3 Jul 2017 11:42:30 +0200

2017-07-03 2:46 GMT+02:00 Shevek <address@hidden>:
> For some reason, TextSpanners by default repeat the text at the beginning of
> a line after breaking, while DynamicTextSpanners do not. I became very
> confused by this inconsistency when I wanted to make my crescendi and
> diminuendi show text after line breaks, because for the life of me I
> couldn't figure out where in the Lilypond source code that behavior
> originates. I also couldn't understand why this wouldn't work:
>
> test = {
>   c'1\cresc
>   \break
>   c' <>\!
> }
>
> \new Staff \with {

Looks like applying a procedure here does not work.
Don't know why ...

>   \override DynamicTextSpanner.bound-details.left-broken.text = #(lambda
> (grob) (ly:grob-property grob 'text))
> } \test
>
> In the end, I succeeded in getting cresc. and dim. to be reprinted after
> line breaks by writing the following:
>
> crescCautionaryEngraver = #(make-engraver
>   (acknowledgers
>    ((dynamic-text-spanner-interface engraver grob source-engraver)
>     (ly:grob-set-nested-property! grob '(bound-details left-broken text)
> (ly:grob-property grob 'text))
>     )
>    )
>   )
>
> Boy, that feels like overkill for what should have been a simple override or
> context property.
>
> Why was this so hard to do? Am I missing something obvious?

%% NB
%% the example returns
%% programming error: bounds of this piece aren't breakable.
%% because of ending the spanner at the end of the music-expression
%% (not discussed here)
test = {
  c'1\cresc
  \break
  c' <>\!
}

%% A procedure as argument does not work
\new Staff
 \with {
   \override DynamicTextSpanner.bound-details.left-broken.text =
    #(lambda (grob) "foo")
 }
\test

%% A string as argument does work.
%% Though, "cresc."/"dim" are set via the
%% crescendoText/decrescendoText-context-properties
%% hardcoding them like below will not do you a favor.
\new Staff
 \with {
   \override DynamicTextSpanner.bound-details.left-broken.text = "cresc."
 }
\test

%% To apply a procedure, use 'after-line-breaking
%% 'before-line-breaking would work as well, though you would have to keep
%% the default-setting for it (without example)
\new Staff
 \with {
   \override DynamicTextSpanner.after-line-breaking =
    #(lambda (grob)
      (ly:grob-set-nested-property! grob '(bound-details left-broken text)
       (ly:grob-property grob 'text)))
 }
\test


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]