]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/text.itely
Update from Valentin.
[lilypond.git] / Documentation / user / 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.  See TRANSLATION for details.
7 @end ignore
8
9 @c \version "2.11.38"
10
11 @node Text
12 @section Text
13
14 @lilypondfile[quote]{text-headword.ly}
15
16 This section explains how to include text (with various
17 formatting) in music scores.
18
19 @noindent
20 Some text elements that are not dealt with here are discussed in other
21 specific sections: @ref{Vocal music}, @ref{Titles and headers}.
22
23
24 @cindex Text, other languages
25 @warning{To write accented and special text (such as characters
26 from other languages), simply insert the characters directly into
27 the LilyPond file.  The file must be saved as UTF-8.  For more
28 information, see @ref{Text encoding}.}
29
30 @menu
31 * Writing text::                
32 * Formatting text::             
33 * Fonts::                       
34 @end menu
35
36
37 @node Writing text
38 @subsection Writing text
39
40 This section introduces different ways of adding text to a score.
41
42 @menu
43 * Text scripts::                
44 * Text spanners::               
45 * Text marks::                  
46 * Separate text::               
47 @end menu
48
49
50 @node Text scripts
51 @subsubsection Text scripts
52
53 @cindex Text scripts
54 @cindex text items, non-empty
55 @cindex non-empty texts
56
57 It is possible to add arbitrary text indications
58 to a score, as demonstrated in the following example.
59 Such indications can also be manually placed
60 above or below the staff, using the
61 simple syntax described in @ref{Controlling direction and
62 placement}.
63
64 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
65 d8^"pizz." e f g a4-"scherz." f
66 @end lilypond
67
68 In LilyPond, such text strings are called @command{markup}
69 objects.  This syntax is actually a shorthand; more complex text
70 formatting may be added to a note by explicitly using a
71 @code{\markup} block, as described in @ref{Formatting text}.
72
73 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
74 d8^\markup { \italic pizz. } e f g 
75 a4_\markup { \tiny scherz. \bold molto } f
76 @end lilypond
77
78 By default, text indications do not influence the note spacing.
79 However, their widths can be taken into account:
80 in the following example, the first text string does not affect 
81 spacing, whereas the second one does.
82
83 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
84 d8^"pizz." e f g \textLengthOn a4_"scherzando" f
85 @end lilypond
86
87 @predefined
88
89 @funindex \textLengthOn
90 @code{\textLengthOn},
91 @funindex \textLengthOff
92 @code{\textLengthOff}
93
94
95 @seealso
96
97 Notation Reference: @ref{Formatting text},
98 @ref{Controlling direction and placement}.
99
100 Snippets:
101 @rlsr{Text}.
102
103 Internals Reference: @rinternals{TextScript}.
104
105 @knownissues
106
107 Checking to make sure that text scripts and lyrics are within the
108 margins is a relatively large computational task.  To speed up
109 processing, LilyPond does not perform such calculations by
110 default; to enable it, use
111
112 @example
113 \override Score.PaperColumn #'keep-inside-line = ##t
114 @end example
115
116
117 @node Text spanners
118 @subsubsection Text spanners
119
120 @cindex Text spanners
121
122 Some performance indications, e.g., @i{rallentando} or
123 @i{accelerando}, are written as text and are extended over many
124 measures with dotted lines.
125 Such objects, called @q{spanners}, may be created
126 from one note to another using the following syntax:
127
128 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
129 \override TextSpanner #'bound-details #'left #'text = "rit." 
130 b1\startTextSpan 
131 e,\stopTextSpan
132 @end lilypond
133
134 @noindent
135 The string to be printed is set through
136 object properties.  By default it is printed in italic characters,
137 but different formatting can be obtained using
138 @code{\markup} blocks, as described in @ref{Formatting text}.
139
140 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
141 \override TextSpanner #'bound-details #'left #'text =
142   \markup { \upright "rit." } 
143 b1\startTextSpan c
144 e,\stopTextSpan
145 @end lilypond
146
147 The line style, as well as the text string, can be defined as an
148 object property.  This syntax is described in @ref{Line styles}.
149
150 @predefined
151
152 @funindex textSpannerUp
153 @code{\textSpannerUp},
154 @funindex textSpannerDown
155 @code{\textSpannerDown},
156 @funindex textSpannerNeutral
157 @code{\textSpannerNeutral}
158
159 @seealso
160
161 Notation Reference: @ref{Line styles}.
162
163 Snippets:
164 @rlsr{Text}.
165
166 Internals Reference: @rinternals{TextSpanner}.
167
168
169 @node Text marks
170 @subsubsection Text marks
171
172 @cindex coda on bar line
173 @cindex segno on bar line
174 @cindex fermata on bar line
175 @cindex bar lines, symbols on
176 @funindex \mark
177
178 Various text elements can be added to a score using
179 the syntax described in @ref{Rehearsal marks}:
180
181 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
182 c4\mark "Allegro" c c c
183 @end lilypond
184
185 This syntax makes possible to put any text on a bar line;
186 more complex text formatting may be added using a @code{\markup}
187 block, as described in @ref{Formatting text}.  This can be used to print
188 signs like coda, segno or fermata, by specifying the appropriate
189 symbol name:
190
191 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
192 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
193 c1
194 @end lilypond
195
196 @noindent
197 Such objects are only typeset above the top staff of the score; depending on
198 whether they are specified at the end or the middle of a bar, they 
199 can be placed above the bar line or between notes.  When specified at the
200 beginning of a score or at a line break, marks will be printed at
201 the beginning of the line (the next line, in case of a line break).
202
203 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
204 \mark "Allegro" c1
205 c\mark "assai" \break
206 c c
207 @end lilypond
208
209
210 @snippets
211
212 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
213 {printing-marks-at-the-end-of-a-line-or-a-score.ly}
214
215 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
216 {aligning-marks-with-various-notation-objects.ly}
217
218 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
219 {printing-marks-on-every-staff.ly}
220
221 @seealso
222
223 Notation Reference: @ref{Rehearsal marks},
224 @ref{Formatting text}, @ref{The Feta font}.
225
226 Snippets:
227 @rlsr{Text}.
228
229 Internals Reference: @rinternals{RehearsalMark}.
230
231 @knownissues
232 @c  IMO this is a bug; hopefully it'll be fixed soon, so I can
233 @c  delete this sentence.   -gp
234 @c  A workaround is suggested in the first @snippets item -vv
235
236 If a mark is entered at the end of the last bar of the score (where
237 there is no next line), then the mark will not be printed at
238 all.
239
240 @node Separate text
241 @subsubsection Separate text
242
243 @cindex separate text
244 @cindex standalone text
245 @cindex top-level text
246 @cindex text, standalone
247 @funindex \markup
248
249 A @code{\markup} block can exist by itself, outside of any
250 any @code{\score} block, as a @qq{top-level
251 expression}.  This syntax is described in @ref{File structure}.
252
253 @lilypond[quote,ragged-right,verbatim]
254 \markup {
255   Tomorrow, and tomorrow, and tomorrow...
256 }
257 @end lilypond
258
259 @noindent
260 This allows to print text separately
261 from the music, which is particularly 
262 useful when the input file contains
263 several music pieces, as described in
264 @ref{Multiple scores in a book}.
265
266 @lilypond[quote,ragged-right,verbatim]
267 \score {
268   c'1
269 }
270 \markup {
271   Tomorrow, and tomorrow, and tomorrow...
272 }
273 \score {
274   c'1
275 }
276 @end lilypond
277
278 Using a specific syntax, text blocks can be spread
279 over multiple pages, making possible to print
280 text documents or books -- and therefore to
281 use LilyPond as a word processor.  This syntax is described in
282 @ref{Multi-page markup}.
283
284 @predefined
285
286 @funindex \markup
287 @code{\markup},
288 @funindex \markuplines
289 @code{\markuplines}
290
291 @ignore
292 @snippets
293
294 TODO: add convenient snippets in input/new -vv
295 @end ignore
296
297 @seealso
298
299 Notation Reference: @ref{Formatting text},
300 @ref{File structure}, 
301 @ref{Multiple scores in a book},
302 @ref{Multi-page markup}.
303
304 Snippets:
305 @rlsr{Text}.
306
307 Internals Reference: @rinternals{TextScript}.
308
309
310 @node Formatting text
311 @subsection Formatting text
312
313 This section presents basic and advanced text formatting,
314 using the @code{\markup} mode specific syntax.
315
316 @menu
317 * Text markup introduction::    
318 * Common markup commands::      
319 * Text alignment::              
320 * Graphic notation inside markup::  
321 * Music notation inside markup::  
322 * Multi-page markup::          
323 @end menu
324
325 @node Text markup introduction
326 @subsubsection Text markup introduction
327
328 @cindex markup
329 @cindex text markup
330 @cindex markup text
331 @cindex typeset text
332
333 A @code{\markup} block is used to typeset text with an extensible
334 specific syntax called @qq{markup mode}.
335
336 @c TODO: make a nicer example (maybe ask Trevor B?) -vv
337 @lilypond[quote,verbatim]
338 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
339 \score{
340   \relative c'' {
341     \override Score.RehearsalMark
342       #'break-visibility = #begin-of-line-invisible
343     \override Score.RehearsalMark #'self-alignment-X = #right
344
345     \set Staff.instrumentName = \markup{ \column{ Alto solo } }
346     c2^\markup{ don't be \flat }
347     \override TextSpanner #'bound-details #'left #'text = \markup{\italic rit }
348     b2\startTextSpan
349     a2\mark \markup{ \large \bold Fine }
350     r2\stopTextSpan
351     \bar "||"
352   }
353   \addlyrics { bar, foo \markup{ \italic bar! } }
354 }
355 @end lilypond
356
357 @cindex markup expressions
358 @cindex markup syntax
359
360 The markup syntax is similar to LilyPond's usual syntax: a
361 @code{\markup} expression can be made of one word, or several words.
362 In the latter case, the expression has to be enclosed in curly braces
363 @code{@{ ... @}} or double quotes @code{"..."}.
364
365 While a text string between double quotes is regarded as an indivisible
366 single expression, markup blocks defined using braces can contain
367 smaller expressions.
368
369 In markup mode, specific commands are entered using the
370 backslash @code{\} character.  Such commands only affect
371 the first following expression: either a single word, or
372 a group of words.
373
374 @lilypond[quote,verbatim,fragment,relative=1]
375 e1-\markup intenso
376 a2^\markup { poco \italic più forte  }
377 c e1
378 d2_\markup { \italic "string. assai" }
379
380 b1^\markup { \bold { molto agitato } }
381 c
382 @end lilypond
383
384 @noindent
385 In this example, the first markup is made of one word without any
386 braces or quotes, while the following markups demonstrate the usefulness
387 of nested markup expressions using braces.
388 This syntax is prefered, as it allows both single-word and multi-word
389 markups.
390
391 @cindex special characters in markup mode
392 @cindex markup mode, special characters
393 @cindex reserved characters, printing
394 @cindex printing special characters
395
396 Special characters such as @code{\} and @code{#}
397 can be printed in the output simply using double
398 quotes.  Double quotation marks are only printed
399 in the output when preceded by backslashes:
400
401 @lilypond[quote,verbatim,fragment,relative=1]
402 \clef bass
403 a^\markup "##\ LEPORELLO \##"
404 a_\markup "Bravi! \"Cosa rara\"!"
405 r a8 d
406 cis a r4 r2
407 @end lilypond
408
409 The way markup expressions are defined affects 
410 how these expressions will stacked,centered and aligned;
411 this syntax is described in @ref{Text alignment}.
412
413 @lilypond[quote,verbatim,fragment,relative=1]
414 c1^\markup { \column { a bbbb \line { c d } } }
415 c1^\markup { \center-align { a bbbb c } }
416 c1^\markup { \line { a b c } }
417 @end lilypond
418
419 Lists of words that are not enclosed with double quotes
420 or preceded by a previous command are not kept distinct.  In
421 the following example, the first two @code{\markup} expressions
422 are equivalent:
423
424 @lilypond[quote,verbatim,fragment,relative=1]
425 c1^\markup { \center-align { a bbb c } }
426 c1^\markup { \center-align { a { bbb c } } }
427 c1^\markup { \center-align { a \line { bbb c } } }
428 @end lilypond
429
430
431 Markups can be stored in variables.  These variables may be
432 attached to notes:
433
434 @lilypond[quote,verbatim]
435 allegro = \markup { \bold \large Allegro }
436
437 {
438   d''8.^\allegro
439   d'16 d'4 r2
440 }
441 @end lilypond
442
443
444 @noindent
445 An exhaustive list of @code{\markup}-specific commands can be found in
446 @ref{Text markup commands}.
447
448 @ignore
449 TODO: here are some commands that could be described here.
450 I'm putting them in bulk, prior to working on this section. -vv
451
452 \simple
453
454 \char
455 \fraction
456
457 \combine
458 \concat
459 \put-adjacent
460
461
462 \page-ref (see also "Table of contents")
463 \fromproperty
464 \verbatim-file
465 \with-url
466
467 \on-the-fly 
468 \override
469
470
471 \null
472 \hspace
473
474 \lower
475 \raise 
476 \translate 
477 \translate-scaled
478 \rotate
479 \transparent
480 \whiteout
481
482 @end ignore
483
484 @seealso
485
486 This manual: @ref{Text markup commands}.
487
488 Snippets:
489 @rlsr{Text}.
490
491 Internals Reference: @rinternals{TextScript}.
492
493 Init files: @file{scm/@/new@/-markup@/.scm}.
494
495
496 @knownissues
497
498 Kerning or generation of ligatures is only done when the @TeX{}
499 backend is used.  In this case, LilyPond does not account for them
500 so texts will be spaced slightly too wide.
501
502 Syntax errors for markup mode are confusing.
503
504 @node Common markup commands
505 @subsubsection Common markup commands
506
507 Some basic formatting can be used blah blah
508
509
510 @cindex font switching
511
512 Some font switching commands are demonstrated here.
513
514 \italic 
515 \upright
516 \bold 
517 \medium 
518 \underline
519         
520
521 @c TODO: what's the difference between the following commands? -vv
522 \smallCaps      
523 \caps 
524 \fontCaps
525
526
527 Some alternate font families can easily be selected:
528
529 \sans
530 \typewriter
531 \roman
532 \number (only for numbers, such as fingerings and time signatures)
533 @c TODO: add \slashed-digit here? -vv
534
535 The size can be blah blah blah
536
537 \fontsize
538
539 Some predefined font sizes can be used blah blah
540
541 \teeny
542 \tiny
543 \small  
544 \normalsize
545 \large
546 \huge
547
548 Some shorcuts allow to change the font size relatively to its previous value 
549
550 \smaller
551 \bigger
552 \larger
553
554 \magnify
555
556 Text may be printed as subscript or superscript:
557
558 \sub 
559 \super
560
561 To obtain subscripts or superscripts in a normal text size, use
562 \normal-size-sub
563 \normal-size-super
564
565 All these settings (except the size) can be reverted to the default font:
566
567 \normal-text 
568
569
570 @node Text alignment
571 @subsubsection Text alignment
572
573
574 Some objects have alignment procedures of their own, which cancel
575 out any effects of alignments applied to their markup arguments as
576 a whole.  For example, the @rinternals{RehearsalMark} is
577 horizontally centered, so using @code{\mark \markup @{ \left-align
578 .. @}} has no effect.
579
580 In addition, vertical placement is performed after creating the
581 text markup object.  If you wish to move an entire piece of
582 markup, you need to use the #'padding property or create an
583 @q{anchor} point inside the markup (generally with @code{\hspace
584 #0}).
585
586 @lilypond[quote,verbatim,fragment,relative=1]
587 \textLengthOn
588 c'4^\markup{ \raise #5 "not raised" }
589 \once \override TextScript #'padding = #3
590 c'4^\markup{ raised }
591 c'4^\markup{ \hspace #0 \raise #1.5 raised }
592 @end lilypond
593
594 Some situations (such as dynamic marks) have preset font-related
595 properties.  If you are creating text in such situations, it is
596 advisable to cancel those properties with @code{normal-text}.  See
597 @ref{Text markup commands}, for more details.
598
599
600 Alignment basics:
601 \left-align
602 \center-align
603 \right-align
604
605 Horizontal alignment:
606 \hcenter
607 \general-align
608 \halign 
609
610
611 Vertical alignment: 
612 \vcenter
613 \column 
614 \dir-column 
615
616 Building a "large" markup:
617
618 \line
619
620 \fill-line
621
622 \hcenter-in
623         
624 \pad-around
625 \pad-markup
626 \pad-to-box
627 \pad-x
628         
629 Alignment inside a "large" markup:
630
631 \justify-field 
632 \justify
633 \justify-string
634
635 \wordwrap-field
636 \wordwrap
637 \wordwrap-string
638
639 @node Graphic notation inside markup
640 @subsubsection Graphic notation inside markup
641 Graphics around text:
642 \box
643 \circle
644
645 \bracket
646 \hbracket
647
648 "Standalone" graphics:
649
650 \arrow-head
651 \draw-line
652 \draw-circle
653 \filled-box
654 \triangle
655 \strut
656
657 \with-color
658
659
660 Advanced graphics:
661 \stencil
662
663 \postscript
664 \epsfile
665
666 \with-dimensions
667
668 @node Music notation inside markup
669 @subsubsection Music notation inside markup
670
671 Notes can be printed in markup mode blah blah:
672
673 \note   
674 \note-by-number
675
676 Accidental symbols can be obtained easily:
677
678 \doubleflat
679 \sesquiflat
680 \flat
681 \semiflat
682 \natural
683 \semisharp
684 \sharp
685 \sesquisharp
686 \doublesharp
687
688 Some other notation objects blah blah
689
690 \beam
691 \finger
692 \dynamic
693 \tied-lyric
694 \markalphabet
695 \markletter
696 @c TODO: add \text here? -vv
697
698 Any musical symbol can be printed
699
700 \musicglyph
701 @c TODO: add \lookup here? -vv
702
703
704 The markup mode has support for fret diagrams:
705
706 \fret-diagram 
707 \fret-diagram-terse
708 \fret-diagram-verbose
709
710 An entire @code{\score} block can even be nested in a @code{\markup}
711 block.  In such a case, the @code{\score} must contain a @code{\layout} block.
712
713
714 \score
715
716
717 @lilypond[quote,verbatim,ragged-right]
718 \relative {
719   c4 d^\markup {
720     \score {
721       \relative { c4 d e f }
722       \layout { }
723     }
724   }
725   e f
726 }
727 @end lilypond
728
729 @seealso
730
731 Snippets:
732 @rlsr{Text}.
733
734 @node Multi-page markup
735 @subsubsection Multi-page markup
736
737 Whereas @code{\markup} is used to enter a non-breakable block of
738 text, @code{\markuplines} can be used at top-level to enter lines
739 of text that can spread over multiple pages:
740
741 @verbatim
742 \markuplines {
743   \justified-lines {
744     A very long text of justified lines.
745     ...
746   }
747   \justified-lines {
748     An other very long paragraph.
749     ...
750   }
751   ...
752 }
753 @end verbatim
754
755 @code{\markuplines} accepts a list of markup, that is either the
756 result of a markup list command, or a list of markups or of markup
757 lists.  The built-in markup list commands are described in
758 @ref{Text markup list commands}.
759
760 @seealso
761
762 This manual: @ref{Text markup list commands}, @ref{New
763 markup list command definition}.
764
765 Snippets:
766 @rlsr{Text}.
767
768 @predefined
769
770 @funindex \markuplines
771 @code{\markuplines}
772
773
774
775 @c TODO: move the following subsubsec into NR3 -vv
776 @c maybe.  -gp
777 @node Fonts
778 @subsection Fonts
779
780 @menu
781 * Entire document fonts::       
782 * Single entry fonts::          
783 @end menu
784
785 @node Entire document fonts
786 @subsubsection Entire document fonts
787
788 It is also possible to change the default font family for the
789 entire document.  This is done by calling the
790 @code{make-pango-font-tree} from within the @code{\paper} block.
791 The function takes names for the font families to use for roman,
792 sans serif and monospaced text.  For example,
793
794 @cindex font families, setting
795 @cindex Pango
796
797
798 @lilypond[verbatim]
799 \paper  {
800   myStaffSize = #20
801
802   #(define fonts
803     (make-pango-font-tree "Times New Roman"
804                           "Nimbus Sans"
805                           "Luxi Mono"
806                            (/ myStaffSize 20)))
807 }
808
809 {
810   c'^\markup { roman: foo \sans bla \typewriter bar }
811 }
812 @end lilypond
813
814 @c we don't do Helvetica / Courier, since GS incorrectly loads
815 @c Apple TTF fonts
816
817
818 @node Single entry fonts
819 @subsubsection Single entry fonts
820
821 @cindex font selection
822 @cindex font magnification
823 @funindex font-interface
824
825 By setting the object properties described below, you can select a
826 font from the preconfigured font families.  LilyPond has default
827 support for the feta music fonts.  Text fonts are selected through
828 Pango/FontConfig.  The serif font defaults to New Century
829 Schoolbook, the sans and typewriter to whatever the Pango
830 installation defaults to.
831
832
833 @itemize
834 @item @code{font-encoding}
835 is a symbol that sets layout of the glyphs.  This should only be
836 set to select different types of non-text fonts, e.g.
837
838 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
839 standard music font, including ancient glyphs, @code{fetaDynamic}
840 for dynamic signs and @code{fetaNumber} for the number font.
841
842 @item @code{font-family}
843 is a symbol indicating the general class of the typeface.
844 Supported are @code{roman} (Computer Modern), @code{sans}, and
845 @code{typewriter}.
846
847 @item @code{font-shape}
848 is a symbol indicating the shape of the font.  There are typically
849 several font shapes available for each font family.  Choices are
850 @code{italic}, @code{caps}, and @code{upright}.
851
852 @item @code{font-series}
853 is a symbol indicating the series of the font.  There are
854 typically several font series for each font family and shape.
855 Choices are @code{medium} and @code{bold}.
856
857 @end itemize
858
859 Fonts selected in the way sketched above come from a predefined
860 style sheet.  If you want to use a font from outside the style
861 sheet, then set the @code{font-name} property,
862
863 @lilypond[fragment,verbatim]
864 {
865   \override Staff.TimeSignature #'font-name = #"Charter"
866   \override Staff.TimeSignature #'font-size = #2
867   \time 3/4
868   c'1_\markup {
869     \override #'(font-name . "Vera Bold")
870       { This text is in Vera Bold }
871   }
872 }
873 @end lilypond
874
875 @noindent
876 Any font can be used, as long as it is available to
877 Pango/FontConfig.  To get a full list of all available fonts, run
878 the command
879
880 @example
881 lilypond -dshow-available-fonts blabla
882 @end example
883
884 (the last argument of the command can be anything, but has to be
885 present).
886
887
888 The size of the font may be set with the @code{font-size}
889 property.  The resulting size is taken relative to the
890 @code{text-font-size} as defined in the @code{\paper} block.
891
892 @cindex font size
893 @cindex font magnification
894
895
896
897
898 @seealso
899
900 Snippets:
901 @rlsr{Text}.
902
903