lilypond-learning: The textLengthOn command
The ‘\textLengthOn’ command
...........................
By default, text produced by markup takes up no horizontal space as far
as laying out the music is concerned. The ‘\textLengthOn’ command
reverses this behavior, causing the notes to be spaced out as far as is
necessary to accommodate the text:
\textLengthOn % Cause notes to space out to accommodate text
c2^"Text1"
c2^"Text2" |
c2^"Text3"
c2^"Text4" |
[image src="" alt="[image of music]" text="image of music" ]
The command to revert to the default behavior is ‘\textLengthOff’.
Alternatively, ‘\once’ may be used with ‘\textLengthOn’ if the effect is
to be limited to just a single musical moment. The corresponding
spacing behavior for rehearsal marks and tempo indications is
independently controlled with the commands ‘\markLengthOn’ and
‘\markLengthOff’.
Markup text will also avoid notes which project above the staff. If
this is not desired, the automatic displacement upwards may be turned
off by setting the priority to ‘#f’. Here’s an example to show how
markup text interacts with such notes.
% This markup is short enough to fit without collision
c2^"Tex" c'' |
R1 |
% This is too long to fit, so it is displaced upwards
c,,2^"Text" c'' |
R1 |
% Turn off collision avoidance
\once \override TextScript.outside-staff-priority = ##f
c,,2^"Long Text " c'' |
R1 |
% Turn off collision avoidance
\once \override TextScript.outside-staff-priority = ##f
\textLengthOn % and turn on textLengthOn
c,,2^"Long Text " % Spaces at end are honored
c''2 |
[image src="" alt="[image of music]" text="image of music" ]