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: Urs Liska
Subject: Re: Force text on line without using \textLengthOn
Date: Thu, 25 Oct 2018 17:49:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

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
  • \endTextSpanners parses a music _expression_ and adds a \stopTextSpan automatically for any \startTextSpan
  • \testII creates such a \startTextSpan to be processed by  \endTextSpanners

?

If so this means that all the music must be wrapped in an \endTextSpanners _expression_, isn't it? 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.)


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' ?

Best
Urs


Cheers,
  Harm


reply via email to

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