Dear all,

in case there are people like me interested in having a basic syntax for
inputting text spanners, I wrote three simple functions for that matter:
\textSpan, \textSpanArrow and \textSpanDoubleArrow. They replace in
practice following overrides with user input:

\override TextSpanner.bound-details.left.text
\override TextSpanner.bound-details.right.text
\override TextSpanner.style
\override TextSpanner.bound-details.right.arrow
\override TextSpanner.bound-details.left.arrow

The syntax of these three functions is:
\textSpan "text" #'linestyle "text", and are used in combination with
\startTextSpan and \stopTextSpan. Overrides and tweaks can still be used,
preferably after and not before, so that what you change is not changed
again by these functions.

\version "2.20.0"

textSpan = #(define-music-function
                   (parser location leftmarkup style rightmarkup)
                   (markup? symbol? markup?)
                   #{
\override TextSpanner.bound-details.left.text = \markup { \upright
#leftmarkup }
\override TextSpanner.bound-details.right.text = \markup { \upright
#rightmarkup }
\override TextSpanner.bound-details.left-broken.text = ##f
\override TextSpanner.bound-details.right-broken.text = ##f
\override TextSpanner.style = #style
\override TextSpanner.bound-details.right.arrow = ##f
\override TextSpanner.bound-details.left.arrow = ##f
                   #})

textSpanArrow = #(define-music-function
                   (parser location leftmarkup style rightmarkup)
                   (markup? symbol? markup?)
                   #{
\override TextSpanner.style = #style
\override TextSpanner.bound-details.right.stencil-align-dir-y = #CENTER
\override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
\override TextSpanner.bound-details.right.arrow = ##t
\override TextSpanner.bound-details.left.text = \markup { \upright
#leftmarkup }
\override TextSpanner.bound-details.right.text = \markup { \upright
#rightmarkup }
\override TextSpanner.bound-details.left-broken.text = ##f
\override TextSpanner.bound-details.right-broken.text = ##f
\override TextSpanner.dash-period = 1.0
                   #})

textSpanDoubleArrow = #(define-music-function
                   (parser location leftmarkup style rightmarkup)
                   (markup? symbol? markup?)
                   #{
\override TextSpanner.style = #style
\override TextSpanner.bound-details.right.stencil-align-dir-y = #CENTER
\override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
\override TextSpanner.bound-details.right.arrow = ##t
\override TextSpanner.bound-details.left.arrow = ##t
\override TextSpanner.bound-details.left.text = \markup { \upright
#leftmarkup }
\override TextSpanner.bound-details.right.text = \markup { \upright
#rightmarkup }
\override TextSpanner.bound-details.left-broken.text = ##f
\override TextSpanner.bound-details.right-broken.text = ##f
\override TextSpanner.dash-period = 1.0
                   #})

%EXAMPLE

\relative c' {
  \textSpan \markup { \bold "press." } #'trill \markup { \italic
\center-align "norm." }
  c1\startTextSpan
  c1
  c1\stopTextSpan
  \textSpanArrow "m. vib." #'dashed-line \markup { \center-align "senza
vib."}
  \break
  c1\startTextSpan
  c1
  c1\stopTextSpan
  \break
  \textSpanDoubleArrow \markup { \box "sul pont."} #'line "sul tasto"
  c1\startTextSpan
  c1
  c1
  c1\stopTextSpan
  \textSpan \markup {\italic "air"} #'zigzag " "
  c1\startTextSpan
  c4 c2.\stopTextSpan
}

[image: image.png]

Cheers,
Martín.




Am So., 20. Sept. 2020 um 18:57 Uhr schrieb Thomas Morley <
[email protected]>:

> Am So., 20. Sept. 2020 um 17:30 Uhr schrieb Xavier Scheuer
> <[email protected]>:
> >
> > On Sun, 20 Sep 2020 at 13:03, Thomas Morley <[email protected]>
> wrote:
> > >
> > > Hi Martin,
> > >
> > > in general I'm more with Aaron.
> > > P.e., I have no clue which default text one could think of for
> > > TextSpanner's left/right-text!?
> > > Otoh, I'd wish we'd have a LilyPond-data-structure to assign a list of
> > > key/value pairs in ly-syntax to a variable. Right now we can do so at
> > > top-level, in layout, paper and \with.
> > >
> > > That said, find attached a TempoSpanner-coding.
> > > I'm not sure it's the best approach at all. For sure there's wide room
> > > for improvements.
> > > Probably the best one could say: it's a proof of concept.
> >
> > Hi,
> >
> > Great! Could you add this to issue 3176 (a proof of concept is not yet a
> proper solution, but is anyway better than nothing, especially for a 7
> years old issue)?
> > https://gitlab.com/lilypond/lilypond/-/issues/3176
> >
> > Thank you!
> >
> > Cheers,
> > Xavier
> >
> > --
> > Xavier Scheuer <[email protected]>
> >
>
> Done, with a slightly improved and commented code:
> https://gitlab.com/lilypond/lilypond/-/issues/3176#note_415526421
>
> Cheers,
>   Harm
>


-- 
www.martinrinconbotero.com

Reply via email to