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