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