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