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