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