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