TextSpanner shortcut

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

TextSpanner shortcut

foxfanfare
Hi all,

Could anyone could tell me what's wrong with my shortcut?
It's printing the spanner correctly but not the text:

rit =
  #(make-music 'TextSpanEvent
               'span-direction -1
               'span-type 'text
               'span-text "rit.")

\score {
  \new Staff \relative c'' {
    c4\<\rit
    d e f
    g1\!\stopTextSpan
  }
}



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

Reply | Threaded
Open this post in threaded view
|

Re: TextSpanner shortcut

Aaron Hill
On 2020-03-17 10:05 am, foxfanfare wrote:

> Hi all,
>
> Could anyone could tell me what's wrong with my shortcut?
> It's printing the spanner correctly but not the text:
>
> rit =
>   #(make-music 'TextSpanEvent
>                'span-direction -1
>                'span-type 'text
>                'span-text "rit.")
>
> \score {
>   \new Staff \relative c'' {
>     c4\<\rit
>     d e f
>     g1\!\stopTextSpan
>   }
> }

span-type and span-text are for dynamic text spanners (e.g.
CrescendoEvent).  You can set these music properties for a
TextSpanEvent, but Text_spanner_engraver will just ignore them.

Instead, you should \override or \tweak the bound-details of TextSpanner
to attach text to the left or right end of the span.  Something like
this avoids the need to use make-music:

%%%%
\version "2.20.0"

rit = -\tweak bound-details.left.text "rit." \startTextSpan

{ a'4\rit g'8 f' b'2\stopTextSpan }
%%%%


-- Aaron Hill

Reply | Threaded
Open this post in threaded view
|

Re: TextSpanner shortcut

foxfanfare
Aaron Hill wrote
> span-type and span-text are for dynamic text spanners (e.g.
> CrescendoEvent).  You can set these music properties for a
> TextSpanEvent, but Text_spanner_engraver will just ignore them.
>
> Instead, you should \override or \tweak the bound-details of TextSpanner
> to attach text to the left or right end of the span.  Something like
> this avoids the need to use make-music:

Thank you Aaron for the explanation. I was trying the make-music solution as
I was also trying to make a generic function, something like:

c4-\mySpan "molto rit." d e f g1\stopTextSpan

Unfortunately, your solution doesn't allow that:
mySpan = -\tweak bound-details.left.text \etc \startTextSpan

I'm curretly re-writing my shortcuts and configuration files in lilypond. I
try to rationalize it and avoid the massive recourse of independent
shortcuts (for instance, rit=... , moltoRit=... etc.). Maybe that has
already been discussed somewhere else but I wasn't able to find the
solution?



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

Reply | Threaded
Open this post in threaded view
|

Re: TextSpanner shortcut

Aaron Hill
On 2020-03-18 3:51 am, foxfanfare wrote:
> Thank you Aaron for the explanation. I was trying the make-music
> solution as
> I was also trying to make a generic function, something like:
>
> c4-\mySpan "molto rit." d e f g1\stopTextSpan

No worries.  Does this help?

%%%%
\version "2.20.0"

startTextSpanWithLeftText =
   #(define-music-function (text) (markup?)
     #{ -\tweak bound-details.left.text #text
         \startTextSpan #})

% startTextSpanWithLeftText =
%   #(define-music-function (text) (markup?)
%     (make-music
%       'TextSpanEvent
%       'tweaks `(((#t bound-details left text) . ,text))
%       'span-direction START))

rit = \startTextSpanWithLeftText "rit."

{ a'4\rit g'8 f' b'2\stopTextSpan }
%%%%

NOTE: I provided a version that shows the equivalent make-music usage.


-- Aaron Hill

Reply | Threaded
Open this post in threaded view
|

Re: TextSpanner shortcut

foxfanfare
Aaron Hill wrote
> No worries.  Does this help?

That's perfect! Thank you very much :)




--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html