]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/text.itely
Doc: Perform fold on itely files for linelength
[lilypond.git] / Documentation / notation / text.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.13.36"
11
12 @node Text
13 @section Text
14
15 @lilypondfile[quote]{text-headword.ly}
16
17 This section explains how to include text (with various
18 formatting) in music scores.
19
20 @noindent
21 Some text elements that are not dealt with here are discussed in other
22 specific sections: @ref{Vocal music}, @ref{Titles and headers}.
23
24 @menu
25 * Writing text::
26 * Formatting text::
27 * Fonts::
28 @end menu
29
30 @node Writing text
31 @subsection Writing text
32
33 This section introduces different ways of adding text to a score.
34
35 @cindex Text, other languages
36 @warning{To write accented and special text (such as characters
37 from other languages), simply insert the characters directly into
38 the LilyPond file.  The file must be saved as UTF-8.  For more
39 information, see @ref{Text encoding}.}
40
41 @menu
42 * Text scripts::
43 * Text spanners::
44 * Text marks::
45 * Separate text::
46 @end menu
47
48
49 @node Text scripts
50 @unnumberedsubsubsec Text scripts
51
52 @cindex Text scripts
53 @cindex text items, non-empty
54 @cindex non-empty texts
55 @cindex quoted text
56
57 Simple @qq{quoted text} indications may be added to a score, as
58 demonstrated in the following example.  Such indications may be
59 manually placed above or below the staff, using the syntax described
60 in @ref{Direction and placement}.
61
62 @lilypond[quote,verbatim,relative=2]
63 a8^"pizz." g f e a4-"scherz." f
64 @end lilypond
65
66 This syntax is actually a shorthand; more complex text formatting may be
67 added to a note by explicitly using a @code{\markup} block, as described
68 in @ref{Formatting text}.
69
70 @lilypond[quote,verbatim,relative=2]
71 a8^\markup { \italic pizz. } g f e
72 a4_\markup { \tiny scherz. \bold molto } f
73 @end lilypond
74
75 By default, text indications do not influence the note spacing. However,
76 their widths can be taken into account: in the following example, the
77 first text string does not affect spacing, whereas the second one does.
78
79 @lilypond[quote,verbatim,relative=2]
80 a8^"pizz." g f e
81 \textLengthOn
82 a4_"scherzando" f
83 @end lilypond
84
85 In addition to text scripts, articulations can be attached to notes.
86 For more information, see @ref{Articulations and ornamentations}.
87
88 For more information about the relative ordering of text scripts and
89 articulations, see @rlearning{Placement of objects}.
90
91 @funindex \textLengthOn
92 @funindex textLengthOn
93 @funindex \textLengthOff
94 @funindex textLengthOff
95
96 @predefined
97 @code{\textLengthOn},
98 @code{\textLengthOff}.
99 @endpredefined
100
101
102 @seealso
103 Learning Manual:
104 @rlearning{Placement of objects}.
105
106 Notation Reference:
107 @ref{Formatting text},
108 @ref{Direction and placement},
109 @ref{Articulations and ornamentations}.
110
111 Snippets:
112 @rlsr{Text}.
113
114 Internals Reference:
115 @rinternals{TextScript}.
116
117
118 @cindex text outside margin
119 @cindex margin, text running over
120 @cindex text, keeping inside margin
121 @cindex lyrics, keeping inside margin
122
123
124 @knownissues
125 Checking to make sure that text scripts and lyrics are within the
126 margins is a relatively large computational task.  To speed up
127 processing, LilyPond does not perform such calculations by
128 default; to enable it, use
129
130 @example
131 \override Score.PaperColumn #'keep-inside-line = ##t
132 @end example
133
134
135 @node Text spanners
136 @unnumberedsubsubsec Text spanners
137
138 @cindex text spanners
139
140 Some performance indications, e.g., @notation{rallentando} or
141 @notation{accelerando}, are written as text and are extended over
142 multiple notes with dotted lines.  Such objects, called
143 @qq{spanners}, may be created from one note to another using the
144 following syntax:
145
146 @lilypond[verbatim,quote,relative=2]
147 \override TextSpanner #'(bound-details left text) = "rit."
148 b1\startTextSpan
149 e,\stopTextSpan
150 @end lilypond
151
152 @cindex text spanners, formatting
153 @cindex formatting text spanners
154
155 @noindent
156 The string to be printed is set through object properties.  By default
157 it is printed in italic characters, but different formatting can be
158 obtained using @code{\markup} blocks, as described in
159 @ref{Formatting text}.
160
161 @lilypond[quote,relative=2,verbatim]
162 \override TextSpanner #'(bound-details left text) =
163   \markup { \upright "rit." }
164 b1\startTextSpan c
165 e,\stopTextSpan
166 @end lilypond
167
168 The line style, as well as the text string, can be defined as an
169 object property.  This syntax is described in @ref{Line styles}.
170
171 @funindex \textSpannerUp
172 @funindex textSpannerUp
173 @funindex \textSpannerDown
174 @funindex textSpannerDown
175 @funindex \textSpannerNeutral
176 @funindex textSpannerNeutral
177
178
179 @predefined
180 @code{\textSpannerUp},
181 @code{\textSpannerDown},
182 @code{\textSpannerNeutral}.
183 @endpredefined
184
185 @knownissues
186 LilyPond is only able to handle one text spanner per voice.
187
188 @snippets
189
190 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
191 {dynamics-text-spanner-postfix.ly}
192
193 @lilypondfile[verbatim,lilyquote,texidoc,doctitle]
194 {dynamics-custom-text-spanner-postfix.ly}
195
196 @seealso
197 Notation Reference:
198 @ref{Line styles},
199 @ref{Dynamics},
200 @ref{Formatting text}.
201
202 Snippets:
203 @rlsr{Text},
204 @rlsr{Expressive marks}.
205
206 Internals Reference:
207 @rinternals{TextSpanner}.
208
209
210 @node Text marks
211 @unnumberedsubsubsec Text marks
212
213
214 @cindex text marks
215 @cindex marks, text
216 @cindex text on bar line
217 @cindex coda on bar line
218 @cindex segno on bar line
219 @cindex fermata on bar line
220 @cindex bar lines, symbols on
221
222 @funindex \mark
223 @funindex mark
224 @funindex \markup
225 @funindex markup
226
227 Various text elements may be added to a score using the syntax described
228 in @ref{Rehearsal marks}:
229
230 @c \mark needs to be placed on a separate line (it's not
231 @c attached to an object like \markup is). -vv
232
233 @lilypond[verbatim,quote,relative=2]
234 c4
235 \mark "Allegro"
236 c c c
237 @end lilypond
238
239 This syntax makes it possible to put any text on a bar line;
240 more complex text formatting may be added using a @code{\markup}
241 block, as described in @ref{Formatting text}:
242
243 @lilypond[quote,verbatim,relative=1]
244 <c e>1
245 \mark \markup { \italic { colla parte } }
246 <d f>2 <e g>
247 <c f aes>1
248 @end lilypond
249
250 @noindent
251 This syntax also allows to print special signs, like coda, segno
252 or fermata, by specifying the appropriate symbol name as explained in
253 @ref{Music notation inside markup}:
254
255 @lilypond[quote,verbatim,relative=2]
256 <bes f>2 <aes d>
257 \mark \markup { \musicglyph #"scripts.ufermata" }
258 <e g>1
259 @end lilypond
260
261 @noindent
262 Such objects are only typeset above the top staff of the score;
263 depending on whether they are specified at the end or the middle of a
264 bar, they can be placed above the bar line or between notes.  When
265 specified at a line break, the mark will be printed at the beginning of
266 the next line.
267
268 @lilypond[quote,verbatim,relative=2]
269 \mark "Allegro"
270 c1 c
271 \mark "assai" \break
272 c  c
273 @end lilypond
274
275
276 @snippets
277
278 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
279 {printing-marks-at-the-end-of-a-line.ly}
280
281 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
282 {aligning-marks-with-various-notation-objects.ly}
283
284 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
285 {printing-marks-on-every-staff.ly}
286
287
288 @seealso
289 Notation Reference:
290 @ref{Rehearsal marks},
291 @ref{Formatting text},
292 @ref{Music notation inside markup},
293 @ref{The Feta font}.
294
295 Snippets:
296 @rlsr{Text}.
297
298 Internals Reference:
299 @rinternals{MarkEvent},
300 @rinternals{Mark_engraver},
301 @rinternals{RehearsalMark}.
302
303
304 @node Separate text
305 @unnumberedsubsubsec Separate text
306
307 @cindex separate text
308 @cindex text, separate
309 @cindex standalone text
310 @cindex top-level text
311 @cindex text, top-level
312 @cindex text, standalone
313
314 @funindex \markup
315 @funindex markup
316
317 A @code{\markup} block can exist by itself, outside of any
318 @code{\score} block, as a @qq{top-level expression}.  This syntax
319 is described in @ref{File structure}.
320
321 @lilypond[verbatim,quote]
322 \markup {
323   Tomorrow, and tomorrow, and tomorrow...
324 }
325 @end lilypond
326
327 @noindent
328 This allows printing text separately from the music, which is
329 particularly useful when the input file contains several music pieces,
330 as described in @ref{Multiple scores in a book}.
331
332 @lilypond[quote,verbatim]
333 \score {
334   c'1
335 }
336 \markup {
337   Tomorrow, and tomorrow, and tomorrow...
338 }
339 \score {
340   c'1
341 }
342 @end lilypond
343
344 Separate text blocks can be spread over multiple pages,
345 making it possible to print text documents or books entirely
346 within LilyPond.  This feature, and the specific syntax it
347 requires, are described in @ref{Multi-page markup}.
348
349
350 @funindex \markup
351 @funindex markup
352 @funindex \markuplines
353 @funindex markuplines
354
355 @predefined
356 @code{\markup},
357 @code{\markuplines}.
358 @endpredefined
359
360
361 @snippets
362
363 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
364 {stand-alone-two-column-markup.ly}
365
366
367 @seealso
368 Notation Reference:
369 @ref{Formatting text},
370 @ref{File structure},
371 @ref{Multiple scores in a book},
372 @ref{Multi-page markup}.
373
374 Snippets:
375 @rlsr{Text}.
376
377 Internals Reference:
378 @rinternals{TextScript}.
379
380
381 @node Formatting text
382 @subsection Formatting text
383
384 This section presents basic and advanced text formatting,
385 using the @code{\markup} mode specific syntax.
386
387 @menu
388 * Text markup introduction::
389 * Selecting font and font size::
390 * Text alignment::
391 * Graphic notation inside markup::
392 * Music notation inside markup::
393 * Multi-page markup::
394 @end menu
395
396 @node Text markup introduction
397 @unnumberedsubsubsec Text markup introduction
398
399 @cindex markup
400 @cindex text markup
401 @cindex markup text
402 @cindex typeset text
403
404 @funindex \markup
405 @funindex markup
406
407 A @code{\markup} block is used to typeset text with an extensible
408 syntax called @qq{markup mode}.
409
410 @cindex markup expressions
411 @cindex expressions, markup
412 @cindex markup syntax
413 @cindex syntax, markup
414
415 The markup syntax is similar to LilyPond's usual syntax: a
416 @code{\markup} expression is enclosed in curly braces
417 @code{@{@dots{} @}}.  A single word is regarded as a minimal expression,
418 and therefore does not need to be enclosed with braces.
419
420 Unlike simple @qq{quoted text} indications, @code{\markup} blocks may
421 contain nested expressions or markup commands, entered using the
422 backslash @code{\} character.  Such commands only affect the first
423 following expression.
424
425 @lilypond[quote,verbatim,relative=2]
426 a1-\markup intenso
427 a2^\markup { poco \italic più forte  }
428 c e1
429 d2_\markup { \italic "string. assai" }
430 e
431 b1^\markup { \bold { molto \italic  agitato } }
432 c
433 @end lilypond
434
435 @cindex special characters in markup mode
436 @cindex markup mode, special characters
437 @cindex reserved characters, printing
438 @cindex printing reserved characters
439 @cindex printing special characters
440 @cindex quoted text in markup mode
441 @cindex markup mode, quoted text
442
443 A @code{\markup} block may also contain quoted text strings.  Such
444 strings are treated as minimal text expressions, and therefore any
445 markup command or special character (such as @code{\} and @code{#})
446 will be printed verbatim without affecting the formatting of the text.
447 Double quotation marks themselves may be printed by preceding them
448 with backslashes.
449
450 @lilypond[quote,verbatim,relative=2]
451 a1^"\italic markup..."
452 a_\markup { \italic "... prints \"italic\" letters!" }
453 a a
454 @end lilypond
455
456 To be treated as a distinct expression, a list of words needs to be
457 enclosed with double quotes or preceded by a command.  The way markup
458 expressions are defined affects how these expressions will be stacked,
459 centered and aligned; in the following example, the second
460 @code{\markup} expression is treated the same as the first one:
461
462 @lilypond[quote,verbatim,relative=2]
463 c1^\markup { \center-column { a bbb c } }
464 c1^\markup { \center-column { a { bbb c } } }
465 c1^\markup { \center-column { a \line { bbb c } } }
466 c1^\markup { \center-column { a "bbb c" } }
467 @end lilypond
468
469 Markups can be stored in variables.  Such variables may be
470 directly attached to notes:
471
472 @lilypond[quote,verbatim]
473 allegro = \markup { \bold \large Allegro }
474
475 {
476   d''8.^\allegro
477   d'16 d'4 r2
478 }
479 @end lilypond
480
481
482 @noindent
483 An exhaustive list of @code{\markup}-specific commands can be found in
484 @ref{Text markup commands}.
485
486
487 @seealso
488 Notation Reference:
489 @ref{Text markup commands}.
490
491 Snippets:
492 @rlsr{Text}.
493
494 Installed Files:
495 @file{scm/markup.scm}.
496
497
498 @knownissues
499 Syntax errors for markup mode can be confusing.
500
501
502 @node Selecting font and font size
503 @unnumberedsubsubsec Selecting font and font size
504
505 @cindex font switching
506 @cindex changing fonts
507 @cindex switching fonts
508
509 @funindex \italic
510 @funindex italic
511 @funindex \bold
512 @funindex bold
513 @funindex \underline
514 @funindex underline
515
516 Basic font switching is supported in markup mode:
517
518 @lilypond[quote,verbatim,relative=2]
519 d1^\markup {
520   \bold { Più mosso }
521   \italic { non troppo \underline Vivo }
522 }
523 r2 r4 r8
524 d,_\markup { \italic quasi \smallCaps Tromba }
525 f1 d2 r
526 @end lilypond
527
528 @cindex font size
529 @cindex text size
530
531 @funindex \fontsize
532 @funindex fontsize
533 @funindex \smaller
534 @funindex smaller
535 @funindex \larger
536 @funindex larger
537 @funindex \magnify
538 @funindex magnify
539
540 The size of the characters can also be altered in different ways:
541 @itemize
542 @item
543 the font size can be set to predefined standard sizes,
544
545 @item
546 the font size can be set to an absolute value,
547
548 @item
549 the font size can also be changed relatively to its previous value.
550 @end itemize
551
552 @noindent
553 The following example demonstrates these three methods:
554
555 @lilypond[quote,verbatim,relative=1]
556 f1_\markup {
557   \tiny espressivo
558   \large e
559   \normalsize intenso
560 }
561 a^\markup {
562   \fontsize #5 Sinfonia
563   \fontsize #2 da
564   \fontsize #3 camera
565 }
566 bes^\markup { (con
567   \larger grande
568   \smaller emozione
569   \magnify #0.6 { e sentimento } )
570 }
571 d c2 r8 c bes a g1
572 @end lilypond
573
574 @cindex subscript
575 @cindex superscript
576
577 @funindex \super
578 @funindex super
579 @funindex \sub
580 @funindex sub
581
582 Text may be printed as subscript or superscript.  By default these are
583 printed in a smaller size, but a normal size can be used as well:
584
585 @lilypond[quote,verbatim]
586 \markup {
587   \column {
588     \line { 1 \super st movement }
589     \line { 1 \normal-size-super st movement
590       \sub { (part two) }  }
591   }
592 }
593 @end lilypond
594
595 @cindex font families
596
597 The markup mode provides an easy way to select alternate font
598 families.  The default serif font, of roman type, is automatically
599 selected unless specified otherwise; on the last line of the following
600 example, there is no difference between the first and the second word.
601
602 @lilypond[quote,verbatim]
603 \markup {
604   \column {
605     \line { Act \number 1 }
606     \line { \sans { Scene I. } }
607     \line { \typewriter { Verona. An open place. } }
608     \line { Enter \roman Valentine and Proteus. }
609   }
610 }
611 @end lilypond
612
613 @noindent
614 Some of these font families, used for specific items such as numbers
615 or dynamics, do not provide all characters, as mentioned in
616 @ref{New dynamic marks} and @ref{Manual repeat marks}.
617
618 @c \concat is actually documented in Align (it is not
619 @c a font-switching command).  But we need it here. -vv
620
621 When used inside a word, some font-switching or formatting commands
622 may produce an unwanted blank space.  This can easily be solved by
623 concatenating the text elements together:
624
625 @lilypond[quote,verbatim]
626 \markup {
627   \column {
628     \line {
629       \concat { 1 \super st }
630       movement
631     }
632     \line {
633       \concat { \dynamic p , }
634       \italic { con dolce espressione }
635     }
636   }
637 }
638 @end lilypond
639
640 An exhaustive list of font switching commands and custom font usage
641 commands can be found in @ref{Font}.
642
643 Defining custom font sets is also possible, as explained in
644 @ref{Fonts}.
645
646 @funindex \teeny
647 @funindex teeny
648 @funindex \tiny
649 @funindex tiny
650 @funindex \small
651 @funindex small
652 @funindex \normalsize
653 @funindex normalsize
654 @funindex \large
655 @funindex large
656 @funindex \huge
657 @funindex huge
658 @funindex \smaller
659 @funindex smaller
660 @funindex \larger
661 @funindex larger
662
663
664 @predefined
665 @code{\teeny},
666 @code{\tiny},
667 @code{\small},
668 @code{\normalsize},
669 @code{\large},
670 @code{\huge},
671 @code{\smaller},
672 @code{\larger}.
673 @endpredefined
674
675
676 @seealso
677 Notation Reference:
678 @ref{Font},
679 @ref{New dynamic marks},
680 @ref{Manual repeat marks},
681 @ref{Fonts}.
682
683 Snippets:
684 @rlsr{Text}.
685
686 Internals Reference:
687 @rinternals{TextScript}.
688
689 Installed Files:
690 @file{scm/define-markup-commands.scm}.
691
692 @knownissues
693 Using the font sizing commands @code{\teeny}, @code{\tiny},
694 @code{\small}, @code{\normalsize}, @code{\large}, and
695 @code{\huge} will lead to inconsistent line spacing compared to
696 using @code{\fontsize}.
697
698
699 @node Text alignment
700 @unnumberedsubsubsec Text alignment
701
702 @cindex text, aligning
703 @cindex aligning text
704 @cindex aligning markup text
705 @cindex aligning markups
706 @cindex markups, aligning
707 @cindex markup text, aligning
708
709 This subsection discusses how to place text in markup mode.  Markup
710 objects can also be moved as a whole, using the syntax described in
711 @rlearning{Moving objects}.
712
713 @c Padding commands should be mentioned on this page, but
714 @c most of these require \box to be more clearly illustrated. -vv
715
716 @cindex text, horizontal alignment
717 @cindex horizontal text alignment
718
719 @funindex \left-align
720 @funindex left-align
721 @funindex \center-align
722 @funindex center-align
723 @funindex \right-align
724 @funindex right-align
725
726 Markup objects may be aligned in different ways.  By default, a text
727 indication is aligned on its left edge: in the following example,
728 there is no difference between the first and the second markup.
729
730 @lilypond[quote,verbatim,relative=2]
731 d1-\markup { poco }
732 f
733 d-\markup { \left-align poco }
734 f
735 d-\markup { \center-align { poco } }
736 f
737 d-\markup { \right-align poco }
738 @end lilypond
739
740 @funindex \halign
741 @funindex halign
742
743 Horizontal alignment may be fine-tuned using a numeric value:
744
745 @lilypond[quote,verbatim,relative=2]
746 a1-\markup { \halign #-1 poco }
747 e'
748 a,-\markup { \halign #0 poco }
749 e'
750 a,-\markup { \halign #0.5 poco }
751 e'
752 a,-\markup { \halign #2 poco }
753 @end lilypond
754
755 @noindent
756 Some objects may have alignment procedures of their own, and therefore
757 are not affected by these commands.  It is possible to move such
758 markup objects as a whole, as shown for instance in
759 @ref{Text marks}.
760
761 @cindex text, vertical alignment
762 @cindex vertical text alignment
763
764 @funindex \raise
765 @funindex raise
766 @funindex \lower
767 @funindex lower
768 @funindex \null
769 @funindex null
770
771 @c QUERY Should the function of ``\null'' be clarified? rp
772
773 Vertical alignment is a bit more complex.  As stated above, markup
774 objects can be moved as a whole; however, it is also possible to move
775 specific elements inside a markup block.  In this case, the element to
776 be moved needs to be preceded with an @emph{anchor point}, that can be
777 another markup element or an invisible object.  The following example
778 demonstrates these two possibilities; the last markup in this example
779 has no anchor point, and therefore is not moved.
780
781 @lilypond[quote,verbatim,relative=1]
782 d2^\markup {
783   Acte I
784   \raise #2 { Scène 1 }
785 }
786 a'
787 g_\markup {
788   \null
789   \lower #4 \bold { Très modéré }
790 }
791 a
792 d,^\markup {
793   \raise #4 \italic { Une forêt. }
794 }
795 a'4 a g2 a
796 @end lilypond
797
798 @funindex \general-align
799 @funindex general-align
800 @funindex \translate
801 @funindex translate
802 @funindex \translate-scaled
803 @funindex translate-scaled
804
805 Some commands can affect both the horizontal and vertical alignment of
806 text objects in markup mode.  Any object affected by these commands
807 must be preceded with an anchor point:
808
809 @lilypond[quote,verbatim,relative=1]
810 d2^\markup {
811   Acte I
812   \translate #'(-1 . 2) "Scène 1"
813 }
814 a'
815 g_\markup {
816   \null
817   \general-align #Y #3.2 \bold "Très modéré"
818 }
819 a
820 d,^\markup {
821   \null
822   \translate-scaled #'(-1 . 2) \teeny "Une forêt."
823 }
824 a'4 a g2 a
825 @end lilypond
826
827 @cindex multi-line markup
828 @cindex markup, multi-line
829 @cindex multi-line text
830 @cindex text, multi-line
831 @cindex text in columns
832 @cindex columns, text
833
834 @funindex \column
835 @funindex column
836 @funindex \center-column
837 @funindex center-column
838
839 A markup object may include several lines of text.  In the following
840 example, each element or expression is placed on its own line, either
841 left-aligned or centered:
842
843 @lilypond[quote,verbatim]
844 \markup {
845   \column {
846     a
847     "b c"
848     \line { d e f }
849   }
850   \hspace #10
851   \center-column {
852     a
853     "b c"
854     \line { d e f }
855   }
856 }
857 @end lilypond
858
859 @cindex centering text on the page
860 @cindex text, centering on the page
861 @cindex markup, centering on the page
862
863 @funindex \fill-line
864 @funindex fill-line
865
866 Similarly, a list of elements or expressions may be spread to fill the
867 entire horizontal line width (if there is only one element, it will be
868 centered on the page).  These expressions can, in turn, include
869 multi-line text or any other markup expression:
870
871 @lilypond[quote,verbatim]
872 \markup {
873   \fill-line {
874     \line { William S. Gilbert }
875     \center-column {
876       \huge \smallCaps "The Mikado"
877       or
878       \smallCaps "The Town of Titipu"
879     }
880     \line { Sir Arthur Sullivan }
881   }
882 }
883 \markup {
884   \fill-line { 1885 }
885 }
886 @end lilypond
887
888 @cindex wordwrapped text
889 @cindex justified text
890 @cindex text, justified
891 @cindex text, wordwrapped
892 @cindex markup text, wordwrapped
893 @cindex markup text, justified
894
895 @funindex \wordwrap
896 @funindex wordwrap
897 @funindex \justify
898 @funindex justify
899
900 Long text indications can also be automatically wrapped accordingly to
901 the given line width.  These will be either left-aligned or justified,
902 as shown in the following example.
903
904 @lilypond[quote,verbatim]
905 \markup {
906   \column {
907     \line  \smallCaps { La vida breve }
908     \line \bold { Acto I }
909     \wordwrap \italic {
910       (La escena representa el corral de una casa de
911       gitanos en el Albaicín de Granada.  Al fondo una
912       puerta por la que se ve el negro interior de
913       una Fragua, iluminado por los rojos resplandores
914       del fuego.)
915     }
916     \hspace #0
917
918     \line \bold { Acto II }
919     \override #'(line-width . 50)
920     \justify \italic {
921       (Calle de Granada.  Fachada de la casa de Carmela
922       y su hermano Manuel con grandes ventanas abiertas
923       a través de las que se ve el patio
924       donde se celebra una alegre fiesta)
925     }
926   }
927 }
928 @end lilypond
929
930 @cindex text alignment commands
931 @cindex markup text alignment commands
932 @cindex alignment, text, commands
933
934 An exhaustive list of text alignment commands can be found in
935 @ref{Align}.
936
937
938 @seealso
939 Learning Manual:
940 @rlearning{Moving objects}.
941
942 Notation Reference:
943 @ref{Align},
944 @ref{Text marks}.
945
946 Snippets:
947 @rlsr{Text}.
948
949 Internals Reference:
950 @rinternals{TextScript}.
951
952 Installed Files:
953 @file{scm/define-markup-commands.scm}.
954
955
956 @node Graphic notation inside markup
957 @unnumberedsubsubsec Graphic notation inside markup
958
959 @cindex graphics, embedding
960 @cindex drawing graphic objects
961 @cindex graphic objects, drawing
962 @cindex embedding graphic objects
963 @cindex graphic objects, embedding
964
965 Various graphic objects may be added to a score, using markup
966 commands.
967
968 @cindex decorating text
969 @cindex framing text
970 @cindex text, framing
971 @cindex text, decorating
972 @cindex markup text, decorating
973 @cindex markup text, framing
974
975 @funindex \box
976 @funindex box
977 @funindex \circle
978 @funindex circle
979 @funindex \rounded-box
980 @funindex rounded-box
981 @funindex \bracket
982 @funindex bracket
983 @funindex \hbracket
984 @funindex hbracket
985
986 Some markup commands allow decoration of text elements with graphics,
987 as demonstrated in the following example.
988
989 @lilypond[quote,verbatim]
990 \markup \fill-line {
991   \center-column {
992     \circle Jack
993     \box "in the box"
994     \null
995     \line {
996       Erik Satie
997       \hspace #3
998       \bracket "1866 - 1925"
999     }
1000     \null
1001     \rounded-box \bold Prelude
1002   }
1003 }
1004 @end lilypond
1005
1006 @cindex padding around text
1007 @cindex text padding
1008 @cindex markup text padding
1009
1010 @funindex \pad-markup
1011 @funindex pad-markup
1012 @funindex \pad-x
1013 @funindex pad-x
1014 @funindex \pad-to-box
1015 @funindex pad-to-box
1016 @funindex \pad-around
1017 @funindex pad-around
1018
1019 Some commands may require an increase in the padding around the text;
1020 this is achieved with some markup commands exhaustively described in
1021 @ref{Align}.
1022
1023 @lilypond[quote,verbatim]
1024 \markup \fill-line {
1025   \center-column {
1026     \box "Charles Ives (1874 - 1954)"
1027     \null
1028     \box \pad-markup #2 "THE UNANSWERED QUESTION"
1029     \box \pad-x #8 "A Cosmic Landscape"
1030     \null
1031   }
1032 }
1033 \markup \column {
1034   \line {
1035     \hspace #10
1036     \box \pad-to-box #'(-5 . 20) #'(0 . 5)
1037       \bold "Largo to Presto"
1038   }
1039   \pad-around #3
1040       "String quartet keeps very even time,
1041 Flute quartet keeps very uneven time."
1042 }
1043 @end lilypond
1044
1045 @cindex graphic notation
1046 @cindex symbols, non-musical
1047 @cindex non-musical symbols
1048 @cindex notation, graphic
1049
1050 @funindex \combine
1051 @funindex combine
1052 @funindex \draw-circle
1053 @funindex draw-circle
1054 @funindex \filled-box
1055 @funindex filled-box
1056 @funindex \triangle
1057 @funindex triangle
1058 @funindex \draw-line
1059 @funindex draw-line
1060 @funindex \arrow-head
1061 @funindex arrow-head
1062
1063 Other graphic elements or symbols may be printed without requiring any
1064 text.  As with any markup expression, such objects can be combined.
1065
1066 @lilypond[quote,verbatim]
1067 \markup {
1068   \combine
1069     \draw-circle #4 #0.4 ##f
1070     \filled-box #'(-4 . 4) #'(-0.5 . 0.5) #1
1071   \hspace #5
1072
1073   \center-column {
1074     \triangle ##t
1075     \combine
1076       \draw-line #'(0 . 4)
1077       \arrow-head #Y #DOWN ##f
1078   }
1079 }
1080 @end lilypond
1081
1082 @cindex embedded graphics
1083 @cindex images, embedding
1084 @cindex graphics, embedding
1085 @cindex postscript
1086
1087 @funindex \epsfile
1088 @funindex epsfile
1089 @funindex \postscript
1090 @funindex postscript
1091
1092 Advanced graphic features include the ability to include external
1093 image files converted to the Encapsulated PostScript format
1094 (@emph{eps}), or to directly embed graphics into the input file, using
1095 native PostScript code.  In such a case, it may be useful to
1096 explicitly specify the size of the drawing, as demonstrated below:
1097
1098 @lilypond[quote,verbatim,relative=1]
1099 c1^\markup {
1100   \combine
1101     \epsfile #X #10 #"./context-example.eps"
1102     \with-dimensions #'(0 . 6) #'(0 . 10)
1103     \postscript #"
1104       -2 3 translate
1105       2.7 2 scale
1106       newpath
1107       2 -1 moveto
1108       4 -2 4 1 1 arct
1109       4 2 3 3 1 arct
1110       0 4 0 3 1 arct
1111       0 0 1 -1 1 arct
1112       closepath
1113       stroke"
1114   }
1115 c
1116 @end lilypond
1117
1118 An exhaustive list of graphics-specific commands can be found in
1119 @ref{Graphic}.
1120
1121
1122 @seealso
1123 Notation Reference:
1124 @ref{Graphic},
1125 @ref{Editorial annotations},
1126 @ref{Align}.
1127
1128 Snippets:
1129 @rlsr{Text}.
1130
1131 Internals Reference:
1132 @rinternals{TextScript}.
1133
1134 Installed Files:
1135 @file{scm/define-markup-commands.scm},
1136 @file{scm/stencil.scm}.
1137
1138
1139 @node Music notation inside markup
1140 @unnumberedsubsubsec Music notation inside markup
1141
1142 @cindex notation inside markup
1143 @cindex music inside markup
1144 @cindex markup, music notation inside
1145
1146 Various musical notation elements may be added to a score, inside a
1147 markup object.
1148
1149 Notes and accidentals can be entered using markup commands:
1150
1151 @lilypond[quote,verbatim,relative=2]
1152 a2 a^\markup {
1153   \note #"4" #1
1154   =
1155   \note-by-number #1 #1 #1.5
1156 }
1157 b1_\markup {
1158   \natural \semiflat \flat
1159   \sesquiflat \doubleflat
1160 }
1161 \glissando
1162 a1_\markup {
1163   \natural \semisharp \sharp
1164   \sesquisharp \doublesharp
1165 }
1166 \glissando b
1167 @end lilypond
1168
1169 Other notation objects may also be printed
1170 in markup mode:
1171
1172 @lilypond[quote,verbatim,relative=1]
1173 g1 bes
1174 ees-\markup {
1175   \finger 4
1176   \tied-lyric #"~"
1177   \finger 1
1178 }
1179 fis_\markup { \dynamic rf }
1180 bes^\markup {
1181   \beam #8 #0.1 #0.5
1182 }
1183 cis
1184 d-\markup {
1185   \markalphabet #8
1186   \markletter #8
1187 }
1188 @end lilypond
1189
1190 More generally, any available musical symbol may be included
1191 separately in a markup object, as demonstrated below; an exhaustive
1192 list of these symbols and their names can be found in
1193 @ref{The Feta font}.
1194
1195 @lilypond[quote,verbatim,relative=2]
1196 c2
1197 c'^\markup { \musicglyph #"eight" }
1198 c,4
1199 c,8._\markup { \musicglyph #"clefs.G_change" }
1200 c16
1201 c2^\markup { \musicglyph #"timesig.neomensural94" }
1202 @end lilypond
1203
1204 Another way of printing non-text glyphs is described in
1205 @ref{Fonts explained}.  This is useful for printing braces of various
1206 sizes.
1207
1208 The markup mode also supports diagrams for specific
1209 instruments:
1210
1211 @lilypond[quote,verbatim,relative=2]
1212 c1^\markup {
1213   \fret-diagram-terse #"x;x;o;2;3;2;"
1214 }
1215 c^\markup {
1216   \harp-pedal #"^-v|--ov^"
1217 }
1218 c
1219 c^\markup {
1220   \combine
1221     \musicglyph #"accordion.discant"
1222     \combine
1223       \raise #0.5 \musicglyph #"accordion.dot"
1224       \raise #1.5 \musicglyph #"accordion.dot"
1225 }
1226 @end lilypond
1227
1228 @c The accordion diagram is actually taken from a snippet.
1229
1230 @noindent
1231 Such diagrams are documented in @ref{Instrument Specific Markup}.
1232
1233 @cindex score inside markup
1234 @cindex markup, score inside
1235
1236 A whole score can even be nested inside a markup object.  In such a
1237 case, the nested @code{\score} block must contain a @code{\layout}
1238 block, as demonstrated here:
1239
1240 @lilypond[quote,verbatim,relative=1]
1241 c4 d^\markup {
1242   \score {
1243     \relative c' { c4 d e f }
1244     \layout { }
1245   }
1246 }
1247 e f |
1248 c d e f
1249 @end lilypond
1250
1251 An exhaustive list of music notation related commands can be found in
1252 @ref{Music}.
1253
1254
1255 @seealso
1256 Notation Reference:
1257 @ref{Music},
1258 @ref{The Feta font},
1259 @ref{Fonts explained}.
1260
1261 Snippets:
1262 @rlsr{Text}.
1263
1264 Internals Reference:
1265 @rinternals{TextScript}.
1266
1267 Installed Files:
1268 @file{scm/define-markup-commands.scm},
1269 @file{scm/fret-diagrams.scm},
1270 @file{scm/harp-pedals.scm}.
1271
1272
1273 @node Multi-page markup
1274 @unnumberedsubsubsec Multi-page markup
1275
1276 @cindex multi-page markup
1277 @cindex markup, multi-page
1278 @cindex markup text, multi-page
1279 @cindex text spread over multiple pages
1280
1281 @funindex \markuplines
1282 @funindex markuplines
1283 @funindex \justified-lines
1284 @funindex justified-lines
1285 @funindex \wordwrap-lines
1286 @funindex wordwrap-lines
1287
1288 Although standard markup objects are not breakable, a specific syntax
1289 makes it possible to enter lines of text that can spread over multiple
1290 pages:
1291
1292 @lilypond[quote,verbatim]
1293 \markuplines {
1294   \justified-lines {
1295     A very long text of justified lines.
1296     ...
1297   }
1298   \wordwrap-lines {
1299     Another very long paragraph.
1300     ...
1301   }
1302   ...
1303 }
1304 @end lilypond
1305
1306 This syntax accepts a list of markups, that can be
1307 @itemize
1308 @item
1309 the result of a markup list command,
1310 @item
1311 a list of markups,
1312 @item
1313 a list of markup lists.
1314 @end itemize
1315
1316 An exhaustive list of markup list commands can be found in
1317 @ref{Text markup list commands}.
1318
1319
1320 @seealso
1321 Notation Reference:
1322 @ref{Text markup list commands},
1323
1324 Snippets:
1325 @rlsr{Text}.
1326
1327 Extending:
1328 @rextend{New markup list command definition}.
1329
1330 Internals Reference:
1331 @rinternals{TextScript}.
1332
1333 Installed Files:
1334 @file{scm/define-markup-commands.scm}.
1335
1336
1337 @funindex \markuplines
1338 @funindex markuplines
1339
1340 @predefined
1341 @code{\markuplines}.
1342 @endpredefined
1343
1344
1345 @node Fonts
1346 @subsection Fonts
1347
1348 This section presents the way fonts are handled, and how they may be
1349 changed in scores.
1350
1351 @menu
1352 * Fonts explained::
1353 * Single entry fonts::
1354 * Entire document fonts::
1355 @end menu
1356
1357 @node Fonts explained
1358 @unnumberedsubsubsec Fonts explained
1359
1360 @cindex Pango
1361 @cindex fonts, explained
1362 @cindex braces, various sizes
1363 @cindex fonts, non-text in markup
1364 @cindex non-text fonts in markup
1365
1366 @funindex font-interface
1367
1368 Fonts are handled through several libraries.  FontConfig is used to
1369 detect available fonts on the system; the selected fonts are rendered
1370 using Pango.
1371
1372 Music notation fonts can be described as a set of specific glyphs,
1373 ordered in several families.  The following syntax allows various
1374 LilyPond @code{feta} non-text fonts to be used directly in markup
1375 mode:
1376
1377 @lilypond[quote,verbatim,relative=2]
1378 a1^\markup {
1379   \vcenter {
1380     \override #'(font-encoding . fetaBraces)
1381     \lookup #"brace120"
1382     \override #'(font-encoding . fetaText)
1383     \column { 1 3 sf }
1384     \override #'(font-encoding . fetaMusic)
1385     \lookup #"noteheads.s0petrucci"
1386   }
1387 }
1388 @end lilypond
1389
1390 @noindent
1391 However, all these glyphs except the braces of various sizes contained
1392 in @code{fetaBraces} are available using the simpler syntax described
1393 in @ref{Music notation inside markup}.
1394
1395 When using the glyphs contained in @code{fetaBraces}, the size of the
1396 brace is specified by the numerical part of the glyph name, in
1397 arbitrary units.  Any integer from @code{0} to @code{575} inclusive
1398 may be specified, @code{0} giving the smallest brace.  The optimum
1399 value must be determined by trial and error.  These glyphs are all
1400 left braces; right braces may be obtained by rotation, see
1401 @ref{Rotating objects}.
1402
1403 Three families of text fonts are made available: the @emph{roman}
1404 (serif) font, that defaults to New Century Schoolbook, the
1405 @emph{sans} font and the monospaced @emph{typewriter} font -- these
1406 last two families are determined by the Pango installation.
1407
1408 Each family may include different shapes and series.  The following
1409 example demonstrates the ability to select alternate families, shapes,
1410 series and sizes.  The value supplied to @code{font-size} is the
1411 required change from the default size.
1412
1413 @lilypond[quote,verbatim,relative=2]
1414 \override Score.RehearsalMark #'font-family = #'typewriter
1415 \mark \markup "Ouverture"
1416 \override Voice.TextScript #'font-shape = #'italic
1417 \override Voice.TextScript #'font-series = #'bold
1418 d2.^\markup "Allegro"
1419 \override Voice.TextScript #'font-size = #-3
1420 c4^smaller
1421 @end lilypond
1422
1423 @noindent
1424 A similar syntax may be used in markup mode; however in this case it
1425 is preferable to use the simpler syntax explained in
1426 @ref{Selecting font and font size}:
1427
1428 @lilypond[quote,verbatim]
1429 \markup {
1430   \column {
1431     \line {
1432       \override #'(font-shape . italic)
1433       \override #'(font-size . 4)
1434       Idomeneo,
1435     }
1436     \line {
1437       \override #'(font-family . typewriter)
1438       {
1439         \override #'(font-series . bold)
1440         re
1441         di
1442       }
1443       \override #'(font-family . sans)
1444       Creta
1445     }
1446   }
1447 }
1448 @end lilypond
1449
1450 Although it is easy to switch between preconfigured fonts, it is also
1451 possible to use other fonts, as explained in the following sections:
1452 @ref{Single entry fonts} and @ref{Entire document fonts}.
1453
1454
1455 @seealso
1456 Notation Reference:
1457 @ref{The Feta font},
1458 @ref{Music notation inside markup},
1459 @ref{Rotating objects},
1460 @ref{Selecting font and font size},
1461 @ref{Font}.
1462
1463
1464 @node Single entry fonts
1465 @unnumberedsubsubsec Single entry fonts
1466
1467 Any font that is installed on the operating system and recognized by
1468 FontConfig may be used in a score, using the following syntax:
1469
1470 @lilypond[quote,verbatim,relative=2]
1471 \override Staff.TimeSignature #'font-name = #"Bitstream Charter"
1472 \override Staff.TimeSignature #'font-size = #2
1473 \time 3/4
1474
1475 a1_\markup {
1476   \override #'(font-name . "Vera Bold")
1477     { Vera Bold }
1478 }
1479 @end lilypond
1480
1481 @cindex fonts, finding available
1482 @cindex finding available fonts
1483 @cindex listing available fonts
1484 @cindex available fonts, listing
1485
1486 @funindex show-available-fonts
1487
1488 The following command displays a list of all available fonts on the
1489 operating system:
1490
1491 @example
1492 lilypond -dshow-available-fonts x
1493 @end example
1494
1495
1496 @seealso
1497 Notation Reference:
1498 @ref{Fonts explained},
1499 @ref{Entire document fonts}.
1500
1501 Snippets:
1502 @rlsr{Text}.
1503
1504 @c A source file gets never installed...
1505 @c Installed Files:
1506 @c @file{lily/font-config-scheme.cc}.
1507
1508
1509 @node Entire document fonts
1510 @unnumberedsubsubsec Entire document fonts
1511
1512 It is possible to change the fonts to be used as the default fonts in
1513 the @emph{roman}, @emph{sans} and @emph{typewriter} font families by
1514 specifying them, in that order, as shown in the example below.  For an
1515 explanation of fonts, see @ref{Fonts explained}.
1516
1517 @cindex font families, setting
1518 @cindex fonts, changing for entire document
1519
1520 @funindex make-pango-font-tree
1521
1522 @lilypond[verbatim,quote]
1523 \paper  {
1524   myStaffSize = #20
1525   #(define fonts
1526     (make-pango-font-tree "Times New Roman"
1527                           "Nimbus Sans"
1528                           "Luxi Mono"
1529                            (/ myStaffSize 20)))
1530 }
1531
1532 \relative c'{
1533   c1-\markup {
1534     roman,
1535     \sans sans,
1536     \typewriter typewriter. }
1537 }
1538 @end lilypond
1539
1540 @c we don't do Helvetica / Courier, since GS incorrectly loads
1541 @c Apple TTF fonts
1542
1543
1544 @seealso
1545 Notation Reference:
1546 @ref{Fonts explained},
1547 @ref{Single entry fonts},
1548 @ref{Selecting font and font size},
1549 @ref{Font}.
1550