lilypond-user
[Top][All Lists]
Advanced

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

Re: Force text on line without using \textLengthOn


From: Thomas Morley
Subject: Re: Force text on line without using \textLengthOn
Date: Thu, 25 Oct 2018 23:38:33 +0200

Hi Urs,

Am Do., 25. Okt. 2018 um 17:49 Uhr schrieb Urs Liska <address@hidden>:
>
> Hi Harm,
>
> thank you for this. From the *behaviour* this seems like what I need, but I 
> have a few questions that may make it not really usable for my case.
>
>
> Am 24.10.2018 um 18:25 schrieb Thomas Morley:
>
> Am Di., 23. Okt. 2018 um 08:28 Uhr schrieb Urs Liska <address@hidden>:
>
> Hi,
>
> I want to use TextScript.staff-padding to produce markup elements that
> are aligned to their baseline. In order to prevent the texts from moving
> vertically to avoid collisions I used \textLengthOn (or its spelled-out
> variant):
>
> \version "2.19.82"
>
> test =
> #(define-event-function (text)(markup?)
>     #{
>       -\tweak extra-spacing-width #(cons -0.0 0.4)
>       -\tweak extra-spacing-height #(cons -inf.0 +inf.0)
>       -\tweak staff-padding 3
>       -\markup #text
>     #})
>
> \relative {
>    c''8 ^\test "foobar" d16 c
>    c8 ^\test "foobar" d16 ^\test "John Doe" c
> }
>
> However, this does not only push the next notes when there actually is
> some neighboring text (as in the second beat of the following example)
> but also when it wouldn't be needed (see atttached image):
>
> Uncommenting the extra-spacing... tweaks will result in the texts moving
> vertically which is not desired.
>
> Is there another approach to make the following note columns move - but
> only if there *is* something in the way?
>
> Thanks
> Urs
>
> Hi Urs,
>
> from your description it sounds you need sort of a spanner with
> adjustable length.
> Attached some coding hacking TextSpanner.
> What do you think?
>
>
> I didn't understand the code in detail, but am I right that
>
> the code basically prints the texts as the start of a TextSpanner

Yes

> \endTextSpanners parses a music expression and adds a \stopTextSpan 
> automatically for any \startTextSpan

Not exactly, the first event with \startTextSpan is disregarded, all
other events with \startTextSpan get a \stopTextSpan added. The last
note/rest/skip/eventchord gets a \stopTextSpan as well.

> \testII creates such a \startTextSpan to be processed by  \endTextSpanners

Yes

>
> ?
>
> If so this means that all the music must be wrapped in an \endTextSpanners 
> expression, isn't it?

Not exactly.
The proposed code/example does so, yes.
Though, \endTextSpanners is more for conveniance., you could drop
\endTextSpanners entirely and set \stopTextSpan manually.

> If this is true then I would be quite a stretch to integrate this solution 
> into my environment, because the input files are part of the edition in this 
> case. They will be made available within a TEI file and therefore have to be 
> extremely clean. So far there is exactly one \include and then either a 
> single music expression (for a single-voice music example) or several music 
> variables plus a custom \loadTemplate command that loads a file with a \score 
> block to make use of the music variables.
>
> For the first case (simple music expression) I can achieve the result by 
> calling \endTextSpanners at the very end of the include file so the music 
> expression will be used as the argument for the function. But for the other 
> cases I'm not sure how I could arrange my files. In addition I only need this 
> functionality in a subset of my >560 files, but such a solution could 
> probably not be optional in the way I'm doing it elsewhere in the project. 
> (The main include file loads a <filename>-include.ily file if that is present 
> on disk. Within that optional file I can place a layout block, 
> edition-engraver mods and an arbitrary number of \loadTool commands. While 
> this latter function probably isn't necessary for efficiency reasons (it 
> would probably be easier to simply include all the available code for each 
> compiled file), it is a nice way to document the specific needs of an 
> example.)


Well, I'm not familiar with TEI, the edition-engraver, etc.
Sorry.

>
>
> I think I'll do some more experiments with the code itself before trying to 
> integrate this.
>
> Hm, as said I don't fully understand the code. But if I'm not mistaken 
> \endTextSpanners works by first identifying a music expression that holds a 
> \startTextSpan event and then adding a \stopTextSpan event to the note, rest 
> or chord. Would it be possible to achieve the same thing directly from a 
> music-function or event-function? Maybe if \testII wouldn't be an event 
> function but a music-function taking the note/rest/chord as an argument, like
>
>   \testII ##t "John Doe" c'
>
> where the TextSpanner is added to the c' ?

Well, you can't start _and_ end a TextSpanner on the same event. See
the warning for { c'1\startTextSpan\stopTextSpan }.
Thus the sophisticated endTextSpanner. Ofcourse endTextSpanner can't
end a textSpanner which is started at the last note of a file as well.

It's thinkable to create a music-functions taking a musical argument
and doing something like
{ \myFunction c'1 }
-> { c'1\startTextSpan <>\stopTextSpan }
This will return a warning if at happens at the end of a file, though.

Cheers,
  Harm



reply via email to

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