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