1 @c -*- coding: utf-8; mode: texinfo; -*-
6 This section explains how to include text (with various formatting) in
9 @cindex Text, other languages
10 To write accented and special text (such as characters from other languages),
12 insert the characters directly into the lilypond file. The file must be
13 saved as UTF-8. For more information, see @ref{Text encoding}.
15 @lilypond[fragment,ragged-right,staffsize=16,quote]
16 c'4^\markup { bla \bold bla }
19 @lilypond[fragment,ragged-right,staffsize=16,quote]
20 c'4^\markup { bla \bold bla }
23 @lilypond[fragment,ragged-right,staffsize=16,quote]
24 c'4^\markup { bla \bold bla }
27 @lilypond[fragment,ragged-right,staffsize=16,quote]
28 c'4^\markup { bla \bold bla }
38 @subsection Writing text
41 @unnumberedsubsubsec Text scripts
44 @cindex text items, non-empty
45 @cindex non-empty texts
47 It is possible to place arbitrary strings of text or @ref{Text markup},
48 above or below notes by using a string @code{c^"text"}. By default,
49 these indications do not influence the note spacing, but by using the
50 command @code{\fatText}, the widths will be taken into account
52 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
53 c4^"longtext" \fatText c4_"longlongtext" c4
57 To prevent text from influencing spacing, use @code{\emptyText}.
59 More complex formatting may also be added to a note by using the
62 @lilypond[fragment,ragged-right,verbatim,quote]
63 c'4^\markup { bla \bold bla }
66 The @code{\markup} is described in more detail in
80 Checking to make sure that text scripts and lyrics are within the margins is
81 a relatively large computational task. To speed up processing, lilypond does
82 not perform such calculations by default; to enable it, use
85 \override Score.PaperColumn #'keep-inside-line = ##t
91 In this manual: @ref{Text markup}.
93 Program reference: @internalsref{TextScript}.
96 @anchor{Text and line spanners}
97 @unnumberedsubsubsec Text and line spanners
99 Some performance indications, e.g., @i{rallentando} and
100 @i{accelerando} and @i{trills} are written as text and are extended
101 over many measures with lines, sometimes dotted or wavy.
103 These all use the same routines as the glissando for drawing the texts
104 and the lines, and tuning their behavior is therefore also done in the
105 same way. It is done with a spanner, and the routine responsible for
106 drawing the spanners is @code{ly:line-interface::print}. This
107 routine determines the exact location of the two @i{span
108 points} and draws a line in between, in the style requested.
110 Here is an example of the different line styles available, and how to
113 @lilypond[relative=2,ragged-right,verbatim,fragment]
115 \once \override Glissando #'dash-fraction = #0.5
117 \override Glissando #'style = #'dotted-line
119 \override Glissando #'style = #'zigzag
121 \override Glissando #'style = #'trill
125 The information that determines the end-points is computed on-the-fly
126 for every graphic object, but it is possible to override these.
128 @lilypond[relative=2,ragged-right,verbatim,fragment]
130 \once \override Glissando #'bound-details #'right #'Y = #-2
134 The @code{Glissando} object, like any other using the
135 @code{ly:line-interface::print} routine, carries a nested
136 association list. In the above statement, the value for @code{Y}
137 is set to @code{-2} for the association list corresponding to the right
138 end point. Of course, it is also possible to adjust the left side with
139 @code{left} instead of @code{right}.
141 If @code{Y} is not set, the value is computed from the vertical
142 position of right attachment point of the spanner.
144 In case of a line break, the values for the span-points are extended
145 with contents of the @code{left-broken} and @code{right-broken}
146 sublists, for example
148 @lilypond[relative=2,ragged-right,verbatim,fragment]
149 \override Glissando #'breakable = ##T
150 \override Glissando #'bound-details #'right-broken #'Y = #-3
155 The following properties can be used for the
159 This sets the Y-coordinate of the end point, in staff space. By
160 default, it is the center of the bound object, so for a glissando it
161 points to the vertical center of the note head.
163 For horizontal spanners, such as text spanner and trill spanners, it
167 This determines where the line starts and ends in X-direction,
168 relative to the bound object. So, a value of @code{-1} (or
169 @code{LEFT}) makes the line start/end at the left side of the note
170 head it is attached to.
173 This is the absolute coordinate of the end point. It is usually
174 computed on the fly, and there is little use in overriding it.
177 Line spanners may have symbols at the beginning or end, which is
178 contained in this sub-property. This is for internal use, it is
179 recommended to use @code{text}.
182 This is a markup that is evaluated to yield stencil. It is
183 used to put @i{cresc.} and @i{tr} on horizontal spanners.
185 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
186 \override TextSpanner #'bound-details #'left #'text
187 = \markup { \small \bold Slower }
188 c2\startTextSpan b c a\stopTextSpan
191 @item stencil-align-dir-y
193 Without setting this, the stencil is simply put there at the
194 end-point, as defined by the @code{X} and @code{Y} sub properties.
195 Setting either @code{stencil-align-dir-y} or @code{stencil-offset}
196 will move the symbol at the edge relative to the end point of the line
198 @lilypond[relative=1,fragment,verbatim]
199 \override TextSpanner #'bound-details #'left #'stencil-align-dir-y = #DOWN
200 \override TextSpanner #'bound-details #'right #'stencil-align-dir-y = #UP
202 \override TextSpanner #'bound-details #'left #'text = #"gggg"
203 \override TextSpanner #'bound-details #'right #'text = #"hhhh"
204 c4^\startTextSpan c c c \stopTextSpan
208 Setting this sub property to @code{#t} produce an arrowhead at the end
212 This sub property controls the space between the specified end-point
213 of the line and the actual end. Without padding, a glissando would
214 start and end in the center of each note head.
220 Program reference: @internalsref{TextSpanner},
221 @internalsref{Glissando}, @internalsref{VoiceFollower},
222 @internalsref{TrillSpanner}, @internalsref{line-spanner-interface}.
224 Examples: @lsr{expressive,line-styles.ly}, @lsr{expressive,line-arrows.ly}
227 @anchor{Text spanners}
228 @unnumberedsubsubsec Text spanners
230 @cindex Text spanners
232 Some performance indications, e.g., @i{rallentando} or @i{accelerando},
233 are written as text and are extended over many measures with dotted
234 lines. Such texts are created using text spanners; attach
235 @code{\startTextSpan} and @code{\stopTextSpan} to the first and last
236 notes of the spanner.
238 The string to be printed, as well as the style, is set through object
241 @lilypond[quote,ragged-right,fragment,relative=1,verbatim]
244 \override TextSpanner #'bound-details #'left #'text =
245 \markup { \upright "rall" }
246 c2\startTextSpan b c\stopTextSpan a
249 \override TextSpanner #'bound-details #'left #'text =
250 \markup { \italic "rit" }
251 c2\startTextSpan b c\stopTextSpan a
256 @funindex textSpannerUp
257 @code{\textSpannerUp},
258 @funindex textSpannerDown
259 @code{\textSpannerDown},
260 @funindex textSpannerNeutral
261 @code{\textSpannerNeutral}.
266 To print a solid line, use
269 \override TextSpanner #'dash-fraction = #'()
275 Program reference: @internalsref{TextSpanner}.
279 @unnumberedsubsubsec Text marks
281 @cindex coda on bar line
282 @cindex segno on bar line
283 @cindex fermata on bar line
284 @cindex bar lines, symbols on
287 The @code{\mark} command is primarily used for
288 @ref{Rehearsal marks},
289 but it can also be used to put signs like coda,
290 segno, and fermata on a bar line. Use @code{\markup} to
291 access the appropriate symbol (symbols are listed in
292 @ref{The Feta font}).
294 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
295 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
300 @code{\mark} is only typeset above the top stave of the score. If
301 you specify the @code{\mark} command at a bar line, the resulting
302 mark is placed above the bar line. If you specify it in the middle
303 of a bar, the resulting mark is positioned between notes. If it is
304 specified before the beginning of a score line, it is placed
305 before the first note of the line. Finally, if the mark occurs at
306 a line break, the mark will be printed at the
307 beginning of the next line.
308 @c IMO this is a bug; hopefully it'll be fixed soon, so I can
309 @c delete this sentence. -gp
310 If there is no next line, then the mark will not be printed at all.
315 To print the mark at the end of the current line, use
318 \override Score.RehearsalMark
319 #'break-visibility = #begin-of-line-invisible
322 @code{\mark} is often useful for adding text to the end of bar. In
323 such cases, changing the @code{#'self-alignment} is very useful
325 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
326 \override Score.RehearsalMark
327 #'break-visibility = #begin-of-line-invisible
329 \once \override Score.RehearsalMark #'self-alignment-X = #right
330 \mark "D.S. al Fine "
333 Text marks may be aligned with notation objects other than
336 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
341 \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
345 \override Score.RehearsalMark #'break-align-symbols = #'(clef)
349 \override Score.RehearsalMark #'break-align-symbols = #'(time-signature)
358 Possible symbols for the @code{break-align-symbols} list are
359 @code{ambitus}, @code{breathing-sign}, @code{clef}, @code{custos},
360 @code{staff-bar}, @code{left-edge}, @code{key-cancellation},
361 @code{key-signature}, and @code{time-signature}.
363 The text marks will, by default, be aligned with the middle of the notation
364 object, but this can be changed by overriding the
365 @code{break-align-anchor-alignment} and
366 @code{break-align-anchor} properties for the appropriate grob.
368 @lilypond[fragment,quote,ragged-right,verbatim]
370 \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
374 % the RehearsalMark will be aligned with the left edge of the KeySignature
375 \once \override Staff.KeySignature #'break-align-anchor-alignment = #LEFT
380 % the RehearsalMark will be aligned with the right edge of the KeySignature
381 \once \override Staff.KeySignature #'break-align-anchor-alignment = #RIGHT
386 % the RehearsalMark will be aligned with the left edge of the KeySignature
387 % and then shifted right by 2 units.
388 \once \override Staff.KeySignature #'break-align-anchor = #2
394 Although text marks are normally only printed above the topmost
395 staff, you may alter this to print them on every staff,
397 @lilypond[quote,ragged-right,verbatim,relative=2]
400 \remove "Mark_engraver"
404 \consists "Mark_engraver"
406 { c''1 \mark "foo" c'' }
408 \consists "Mark_engraver"
410 { c'1 \mark "foo" c' }
418 Program reference: @internalsref{RehearsalMark}.
422 @anchor{New dynamic marks}
423 @unnumberedsubsubsec New dynamic marks
425 It is possible to print new dynamic marks or text that should be aligned
426 with dynamics. Use @code{make-dynamic-script} to create these
427 marks. Note that the dynamic font only contains the characters
428 @code{f,m,p,r,s} and @code{z}.
430 Some situations (such as dynamic marks) have preset font-related
431 properties. If you are creating text in such situations, it
432 is advisable to cancel those properties with
433 @code{normal-text}. See @ref{Overview of text markup commands},
436 @cindex make-dynamic-script
438 @lilypond[quote,verbatim,ragged-right]
439 sfzp = #(make-dynamic-script "sfzp")
445 @cindex Dynamics, editorial
446 @cindex Dynamics, parenthesis
448 It is also possible to print dynamics in round parenthesis or square
449 brackets. These are often used for adding editorial dynamics.
451 @lilypond[quote,verbatim,ragged-right]
452 rndf = \markup{ \center-align {\line { \bold{\italic (}
453 \dynamic f \bold{\italic )} }} }
454 boxf = \markup{ \bracket { \dynamic f } }
455 { c'1_\rndf c'1_\boxf }
461 @subsection Text markup
463 @anchor{Text markup introduction}
464 @unnumberedsubsubsec Text markup introduction
471 Use @code{\markup} to typeset text. Commands are entered with the
472 backslash @code{\}. To enter @code{\} and @code{#}, use double
475 @lilypond[quote,verbatim,fragment,relative=1]
477 c1_\markup { hi there }
478 c1^\markup { hi \bold there, is \italic {anyone home?} }
479 c1_\markup { "\special {weird} #characters" }
483 See @ref{Overview of text markup commands}, for a list of all
486 @code{\markup} is primarily used for @internalsref{TextScript}s,
487 but it can also be used anywhere text is called in lilypond
489 @lilypond[quote,verbatim]
490 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
493 \override Score.RehearsalMark
494 #'break-visibility = #begin-of-line-invisible
495 \override Score.RehearsalMark #'self-alignment-X = #right
497 \set Staff.instrumentName = \markup{ \column{ Alto solo } }
498 c2^\markup{ don't be \flat }
499 \override TextSpanner #'bound-details #'left #'text = \markup{\italic rit }
501 a2\mark \markup{ \large \bold Fine }
505 \addlyrics { bar, foo \markup{ \italic bar! } }
509 A @code{\markup} command can also be placed on its own, away from any
510 @code{\score} block, see @ref{Multiple scores in a book}.
512 @lilypond[quote,ragged-right,verbatim]
513 \markup{ Here is some text. }
516 @cindex font switching
518 The markup in the example demonstrates font switching commands. The
519 command @code{\bold} and @code{\italic} apply to the first following
520 word only; to apply a command to more than one word, enclose the
524 \markup @{ \bold @{ hi there @} @}
528 For clarity, you can also do this for single arguments, e.g.,
531 \markup @{ is \italic @{ anyone @} home @}
534 In markup mode you can compose expressions, similar to mathematical
535 expressions, XML documents, and music expressions. You can stack
536 expressions grouped vertically with the command @code{\column}.
537 Similarly, @code{\center-align} aligns texts by their center lines:
539 @lilypond[quote,verbatim,fragment,relative=1]
540 c1^\markup { \column { a bbbb \line { c d } } }
541 c1^\markup { \center-align { a bbbb c } }
542 c1^\markup { \line { a b c } }
545 Lists with no previous command are not kept distinct. The expression
548 \center-align @{ @{ a b @} @{ c d @} @}
556 \center-align @{ a b c d @}
561 To keep lists of words distinct, please use quotes @code{"} or
562 the @code{\line} command
564 @lilypond[quote,verbatim,fragment,relative=1]
566 c4^\markup{ \center-align { on three lines } }
567 c4^\markup{ \center-align { "all one line" } }
568 c4^\markup{ \center-align { { on three lines } } }
569 c4^\markup{ \center-align { \line { on one line } } }
572 Markups can be stored in variables and these variables
573 may be attached to notes, like
575 allegro = \markup @{ \bold \large @{ Allegro @} @}
576 @{ a^\allegro b c d @}
579 Some objects have alignment procedures of their own, which cancel out
580 any effects of alignments applied to their markup arguments as a
581 whole. For example, the @internalsref{RehearsalMark} is horizontally
582 centered, so using @code{\mark \markup @{ \left-align .. @}} has no
585 In addition, vertical placement is performed after creating the
586 text markup object. If you wish to move an entire piece of markup,
587 you need to use the #'padding property or create an @q{anchor} point
588 inside the markup (generally with @code{\hspace #0}).
590 @lilypond[quote,verbatim,fragment,relative=1]
592 c'4^\markup{ \raise #5 "not raised" }
593 \once \override TextScript #'padding = #3
594 c'4^\markup{ raised }
595 c'4^\markup{ \hspace #0 \raise #1.5 raised }
598 Some situations (such as dynamic marks) have preset font-related
599 properties. If you are creating text in such situations, it
600 is advisable to cancel those properties with
601 @code{normal-text}. See @ref{Overview of text markup commands},
607 This manual: @ref{Overview of text markup commands}.
609 Program reference: @internalsref{TextScript}.
611 Init files: @file{scm/@/new@/-markup@/.scm}.
616 Kerning or generation of ligatures is only done when the @TeX{}
617 backend is used. In this case, LilyPond does not account for them so
618 texts will be spaced slightly too wide.
620 Syntax errors for markup mode are confusing.
623 @anchor{Nested scores}
624 @unnumberedsubsubsec Nested scores
626 It is possible to nest music inside markups, by adding a @code{\score}
627 block to a markup expression. Such a score must contain a @code{\layout}
630 @lilypond[quote,verbatim,ragged-right]
634 \relative { c4 d e f }
642 @anchor{Page wrapping text}
643 @unnumberedsubsubsec Page wrapping text
644 Whereas @code{\markup} is used to enter a non-breakable block of text,
645 @code{\markuplines} can be used at top-level to enter lines of text that
646 can spread over multiple pages:
651 A very long text of justified lines.
655 An other very long paragraph.
662 @code{\markuplines} accepts a list of markup, that is either the result
663 of a markup list command, or a list of markups or of markup lists. The
664 built-in markup list commands are described in
665 @ref{Overview of text markup list commands}.
669 This manual: @ref{Overview of text markup list commands},
670 @ref{New markup list command definition}.
674 @funindex \markuplines
677 @anchor{Font selection}
678 @unnumberedsubsubsec Font selection
680 @cindex font selection
681 @cindex font magnification
682 @funindex font-interface
684 By setting the object properties described below, you can select a
685 font from the preconfigured font families. LilyPond has default
686 support for the feta music fonts. Text fonts are selected through
687 Pango/FontConfig. The serif font defaults to New Century Schoolbook,
688 the sans and typewriter to whatever the Pango installation defaults
693 @item @code{font-encoding}
694 is a symbol that sets layout of the glyphs. This should only be set to
695 select different types of non-text fonts, e.g.
697 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
698 standard music font, including ancient glyphs, @code{fetaDynamic} for
699 dynamic signs and @code{fetaNumber} for the number font.
701 @item @code{font-family}
702 is a symbol indicating the general class of the typeface. Supported are
703 @code{roman} (Computer Modern), @code{sans}, and @code{typewriter}.
705 @item @code{font-shape}
706 is a symbol indicating the shape of the font. There are typically
707 several font shapes available for each font family. Choices are
708 @code{italic}, @code{caps}, and @code{upright}.
710 @item @code{font-series}
711 is a symbol indicating the series of the font. There are typically
712 several font series for each font family and shape. Choices are
713 @code{medium} and @code{bold}.
717 Fonts selected in the way sketched above come from a predefined style
718 sheet. If you want to use a font from outside the style sheet,
720 @code{font-name} property,
722 @lilypond[fragment,verbatim]
724 \override Staff.TimeSignature #'font-name = #"Charter"
725 \override Staff.TimeSignature #'font-size = #2
728 \override #'(font-name . "Vera Bold")
729 { This text is in Vera Bold }
735 Any font can be used, as long as it is available to Pango/FontConfig.
736 To get a full list of all available fonts, run the command
738 lilypond -dshow-available-fonts blabla
740 (the last argument of the command can be anything, but has to be present).
743 The size of the font may be set with the @code{font-size}
744 property. The resulting size is taken relative to the
745 @code{text-font-size} as defined in the @code{\paper} block.
748 @cindex font magnification
751 It is also possible to change the default font family for the entire
752 document. This is done by calling the @code{make-pango-font-tree} from
753 within the @code{\paper} block. The function takes names for the font
754 families to use for roman, sans serif and monospaced text. For
757 @cindex font families, setting
766 (make-pango-font-tree "Times New Roman"
773 c'^\markup { roman: foo \sans bla \typewriter bar }
777 @c we don't do Helvetica / Courier, since GS incorrectly loads
784 Examples: @lsr{text,font@/-family@/-override.ly}.