lilypond-user
[Top][All Lists]
Advanced

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

Re: text block as spanner


From: Leo Correia de Verdier
Subject: Re: text block as spanner
Date: Wed, 6 Feb 2019 12:43:48 +0100

Thanks a lot to all for the help and all code you’ve written! 
I included Thomas'/Harm's multiple-text-spanners-via-id from February third.

This is what I ended up with:

\version "2.19.80"

\include "multiple-text-spanners-via-id.ly"

longTextInstr =
#(define-music-function (alongtext)
   (string?)
   #{
     -\tweak stencil 
     #(lambda (grob)
        (let* ((grob-X (interval-length
                        (ly:stencil-extent (ly:line-spanner::print grob) X)))
               (layout (ly:grob-layout grob))  
               (props (ly:grob-alist-chain grob 
                        (ly:output-def-lookup layout 
                          'text-font-defaults)))
               (padding .5))
          
          (ly:text-interface::interpret-markup layout props       
            #{ \markup { 
              \override #(cons 'line-width (- grob-X padding))
              \wordwrap-string #alongtext }
            #})
          ))
     \=10\startTextSpan
   #}
   )

wrapLongTextInstr = \=10\stopTextSpan

%{example

\layout {
  \context {
    \Voice
    \remove #"Text_spanner_engraver"
    \consists \alternateTextSpannerEngraver
  }
}

\relative c' {
  c4 d -\longTextInstr "this is a long instruction to be printed over a few notes"
  e f c d 
  g2 e \wrapLongTextInstr
  d
}
%}



4 feb. 2019 kl. 14:35 skrev David Nalesnik <address@hidden>:

Hello Harm!

On Sun, Feb 3, 2019 at 1:47 PM Thomas Morley <address@hidden> wrote:

Hi David,

Am Sa., 2. Feb. 2019 um 21:35 Uhr schrieb David Nalesnik
<address@hidden>:

Hi,

On Sat, Feb 2, 2019 at 2:13 PM Thomas Morley <address@hidden> wrote:

Am Sa., 2. Feb. 2019 um 21:09 Uhr schrieb Thomas Morley
<address@hidden>:

A bold workaround is to define the whole infrastructure for
TextSpanners with new/renamed events (class and type), grobs,
engravers and
start/stop-commands.

I forgot to point to a limitation
The provided 'text-spanner->text' doesn't care for line-breaks.

To clarify, 'text-spanner->text' has nothing to do with multiple TextSpanners.
It's a stencil-override. special line-breaking behaviour is not coded, though.

There is this: https://www.mail-archive.com/address@hidden/msg105826.html

Looks we have the same conversation every few years lol

:)

Your approach is far less invasive, so preferable.
Not sure if anything needs to be updated.


Ideally, this sort of thing could be added to the code base to avoid
the tangled history!  I never went further with this because of the
effort to rationalize spanners (GSoc?)  I figured adding something
like this would be like adding balconies onto balconies, or whatever
the architectural analogy would be.

The fix mentioned here
http://lists.gnu.org/archive/html/lilypond-user/2017-11/msg00016.html
should be applied, then it still works.

Though, I noticed a little problem here and in scheme-text-spanner
from our regtests, too:
Usually one can set the direction via direction-modifiers, i.e. for
_\startTextSpan the TextSpanner is printed below. This does not work.

The direction may be catched in listener and applied to the grob in
process-music.
So I did in the attached file, not sure whether it's the best fix ...

Thank you kindly--I now see all the colored lines in their irrelevant
glory!  I missed the change you mention and would have spent I don't
know how much time looking for a solution.


Thanks,
 Harm

Best,
David


reply via email to

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