]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/text.itely
Merge branch 'lilypond/translation' of ssh://pacovila@git.sv.gnu.org/srv/git/lilypond...
[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 @cindex quoted text
57
58 Simple @q{quoted text} indications may be added
59 to a score, as demonstrated in the following example.
60 Such indications can be manually placed
61 above or below the staff, using the
62 simple syntax described in @ref{Direction and
63 placement}.
64
65 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
66 d8^"pizz." e f g a4-"scherz." f
67 @end lilypond
68
69 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{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,doctitle]
213 {printing-marks-at-the-end-of-a-line-or-a-score.ly}
214
215 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
216 {aligning-marks-with-various-notation-objects.ly}
217
218 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc,doctitle]
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  To be removed when Issue 69 in the tracker gets fixed. -vv
233
234 If a mark is entered at the end of the last bar of the score (where
235 there is no next line), then the mark will not be printed at
236 all.
237
238 @node Separate text
239 @subsubsection Separate text
240
241 @cindex separate text
242 @cindex standalone text
243 @cindex top-level text
244 @cindex text, standalone
245 @funindex \markup
246
247 A @code{\markup} block can exist by itself, outside of any
248 any @code{\score} block, as a @qq{top-level
249 expression}.  This syntax is described in @ref{File structure}.
250
251 @lilypond[verbatim,quote]
252 \markup {
253   Tomorrow, and tomorrow, and tomorrow...
254 }
255 @end lilypond
256
257 @noindent
258 This allows to print text separately
259 from the music, which is particularly 
260 useful when the input file contains
261 several music pieces, as described in
262 @ref{Multiple scores in a book}.
263
264 @lilypond[quote,ragged-right,verbatim]
265 \score {
266   c'1
267 }
268 \markup {
269   Tomorrow, and tomorrow, and tomorrow...
270 }
271 \score {
272   c'1
273 }
274 @end lilypond
275
276 Using a specific syntax, text blocks can be spread
277 over multiple pages, making possible to print
278 text documents or books -- and therefore to
279 use LilyPond as a word processor.  This syntax is described in
280 @ref{Multi-page markup}.
281
282 @predefined
283
284 @code{\markup},
285 @funindex \markuplines
286 @code{\markuplines}
287
288 @ignore
289 @snippets
290
291 TODO: add convenient snippets in input/new -vv
292 @end ignore
293
294 @seealso
295
296 Notation Reference: @ref{Formatting text},
297 @ref{File structure}, 
298 @ref{Multiple scores in a book},
299 @ref{Multi-page markup}.
300
301 Snippets:
302 @rlsr{Text}.
303
304 Internals Reference: @rinternals{TextScript}.
305
306
307 @node Formatting text
308 @subsection Formatting text
309
310 This section presents basic and advanced text formatting,
311 using the @code{\markup} mode specific syntax.
312
313 @menu
314 * Text markup introduction::    
315 * Common markup commands::      
316 * Text alignment::              
317 * Graphic notation inside markup::  
318 * Music notation inside markup::  
319 * Multi-page markup::          
320 @end menu
321
322 @node Text markup introduction
323 @subsubsection Text markup introduction
324
325 @cindex markup
326 @cindex text markup
327 @cindex markup text
328 @cindex typeset text
329 @funindex \markup
330
331 A @code{\markup} block is used to typeset text with an extensible
332 specific syntax called @qq{markup mode}.
333
334 @cindex markup expressions
335 @cindex markup syntax
336
337 The markup syntax is similar to LilyPond's usual syntax: a
338 @code{\markup} expression is enclosed in curly braces @code{@{
339 @dots{} @}}.
340
341 Unlike simple @q{quoted text} indications, @code{\markup} blocks
342 may contain nested expressions or specific commands,
343 entered using the backslash @code{\} character.
344 Such commands only affect the first following expression.
345
346 @lilypond[quote,verbatim,fragment,relative=1]
347 e1-\markup "intenso"
348 a2^\markup { poco \italic più forte  }
349 c e1
350 d2_\markup { \italic "string. assai" }
351
352 b1^\markup { \bold { molto \italic  agitato } }
353 c
354 @end lilypond
355
356 @cindex special characters in markup mode
357 @cindex markup mode, special characters
358 @cindex reserved characters, printing
359 @cindex printing special characters
360 @cindex quoted text in markup mode
361
362 A @code{\markup} block may also contain quoted text, which
363 can be useful to print special characters (such as @code{\} and @code{#}).
364 Quoted text even allows to print double quotation marks, by preceding
365 them with backslashes:
366
367 @lilypond[quote,verbatim,fragment,relative=1]
368 \clef bass
369 a^\markup "##\ LEPORELLO \##"
370 a_\markup "Bravi! \"Cosa rara\"!"
371 r a8 d
372 cis a r4 r2
373 @end lilypond
374
375 The way markup expressions are defined affects 
376 how these expressions will stacked, centered and aligned
377 when using the commands explained in @ref{Text alignment}.
378
379 @lilypond[quote,verbatim,fragment,relative=1]
380 c1^\markup { \column { a bbbb \line { c d } } }
381 c1^\markup { \center-align { a bbbb c } }
382 c1^\markup { \line { a b c } }
383 @end lilypond
384
385 Lists of words that are not enclosed with double quotes
386 or preceded by a command are not kept distinct.  In
387 the following example, the first two @code{\markup} expressions
388 are equivalent:
389
390 @lilypond[quote,verbatim,fragment,relative=1]
391 c1^\markup { \center-align { a bbb c } }
392 c1^\markup { \center-align { a { bbb c } } }
393 c1^\markup { \center-align { a \line { bbb c } } }
394 @end lilypond
395
396
397 Markups can be stored in variables.  These variables may be
398 directly attached to notes:
399
400 @lilypond[quote,verbatim]
401 allegro = \markup { \bold \large Allegro }
402
403 {
404   d''8.^\allegro
405   d'16 d'4 r2
406 }
407 @end lilypond
408
409
410 @noindent
411 An exhaustive list of @code{\markup}-specific commands can be found in
412 @ref{Text markup commands}.
413
414
415 @seealso
416
417 This manual: @ref{Text markup commands}.
418
419 Snippets:
420 @rlsr{Text}.
421
422 Internals Reference: @rinternals{TextScript}.
423
424 Init files: @file{scm/@/new@/-markup@/.scm}.
425
426
427 @knownissues
428
429 Syntax errors for markup mode are confusing.
430
431
432 @node Common markup commands
433 @subsubsection Common markup commands
434
435 Markup text may be formatted using simple commands.
436
437 @cindex font switching
438 @funindex \italic
439 @funindex \bold
440 @funindex \underline
441
442 Basic font switching is supported:
443
444 @lilypond[quote,verbatim,relative=2]
445 {
446   d1^\markup { 
447       \bold { Più mosso } 
448       \italic { non troppo \underline Vivo } 
449     }
450   r2 r4 r8
451   d,_\markup { \italic quasi \smallCaps Tromba }
452   f1 d2 r
453 }
454 @end lilypond
455
456 @cindex font size
457 @cindex text size
458 @funindex \fontsize
459 @funindex \small
460 @funindex \large
461 @funindex \smaller
462 @funindex \larger
463 @funindex \magnify
464
465 The size of the characters can also be altered in different ways:
466 @itemize
467 @item
468 the font size can be defined to an absolute value,
469
470 @item
471 predefined commands allow to easily select standard sizes,
472
473 @item
474 other commands allow to change the size relatively to its previous value.
475 @end itemize
476
477 @noindent
478 The following example demonstrates these three methods:
479
480 @lilypond[quote,verbatim,relative=2]
481 {
482   f1^\markup { \fontsize #5 Sinfonia } 
483   a,_\markup { 
484          \tiny espressivo
485          \large e
486          \normalsize intenso 
487          }
488   bes^\markup { (con 
489          \larger grande 
490          \smaller emozione 
491          \magnify #0.6 { e sentimento } )
492          }
493   d c2 r8 c bes a g1
494 }
495 @end lilypond
496
497 @cindex subscript
498 @cindex superscript
499 @funindex \super
500 @funindex \sub
501
502 Text may be printed as subscript or superscript. By default
503 these are printed in a smaller size, but a normal size can be used as well:
504
505 @lilypond[quote,verbatim]
506 \markup {
507   \column {
508     \line { 1 \super st movement }
509     \line { 1 \normal-size-super st movement 
510       \sub { (part two) }  }
511   }
512 }
513 @end lilypond
514
515 The markup mode provides an easy way to select alternate
516 font families.  The default serif font, of roman type, is automatically
517 selected unless specified otherwise: on the last line of the following example,
518 there is no difference between the first word and the following words.
519
520 @lilypond[quote,verbatim]
521 \markup {
522   \column {
523     \line { Act \number 1 }
524     \line { \sans { Scene I. } }
525     \line { \typewriter { Verona. An open place. } }
526     \line { \roman Enter Valentine and Proteus. }
527   }
528 }
529 @end lilypond
530
531 @noindent
532 Some of these font families, used for specific items
533 such as numbers or dynamics, do not provide all
534 characters, as mentioned in @ref{New dynamic marks} and
535 @ref{Manual repeat marks}.
536
537
538 Defining custom font sets is also possible, as explained in
539 @ref{Fonts}.
540
541 An exhaustive list of font-switching, font-size and font-families related
542 commands can be found in @ref{Font}.
543
544 @c TODO: add @seealso
545
546 @knownissues
547 When used inside a word, some of these commands may produce an unwanted
548 blank space.  This can easily be solved by concatenating the text
549 elements together, using a specific command
550 described in @ref{Text alignment}.
551
552
553
554 @node Text alignment
555 @subsubsection Text alignment
556
557 @warning{This subsection discusses how to place text in markup mode,
558 inside a @code{\markup} block.  However, markup objects can also
559 be moved as a whole using the syntax described in
560 @rlearning{Moving objects}.}
561
562 Markup objects can be aligned in different ways.  By default,
563 a text indication is aligned on its left edge: in the following
564 example, there's no difference between the first and the second
565 markup.
566
567 @lilypond[quote,verbatim,fragment,relative=1]
568 a1-\markup { poco }
569 e'
570 a,-\markup { \left-align poco }
571 e'
572 a,-\markup { \center-align { poco } }
573 e'
574 a,-\markup { \right-align poco }
575 @end lilypond
576
577 @c FIXME: \center-align actually doesn't belong here
578 @c \center-align vs \column
579 @c \center-align vs \hcenter
580
581 Horizontal alignment:
582 \hcenter
583 \general-align
584 \halign 
585
586
587 \null
588 \hspace
589
590 \lower
591 \raise 
592 \translate 
593 \translate-scaled
594 \rotate
595 \transparent
596 \whiteout
597
598 Vertical alignment: 
599 \vcenter
600 \column 
601 \dir-column 
602
603 Building a "large" markup:
604
605 \line
606
607 \fill-line
608
609 \hcenter-in
610         
611 \pad-around
612 \pad-markup
613 \pad-to-box
614 \pad-x
615         
616 Alignment inside a "large" markup:
617
618 \justify-field 
619 \justify
620 \justify-string
621
622 \wordwrap-field
623 \wordwrap
624 \wordwrap-string
625
626
627 @ignore
628 TODO: here are some commands that could be described here.
629 I'm putting them in bulk, prior to working on this section. -vv
630
631 \simple
632
633 \char
634 \fraction
635
636 \combine
637 \concat
638 \put-adjacent
639
640
641 \page-ref (see also "Table of contents")
642 \fromproperty
643 \verbatim-file
644 \with-url
645
646 \on-the-fly 
647 \override
648
649
650
651 @end ignore
652
653
654 Some objects have alignment procedures of their own, which cancel
655 out any effects of alignments applied to their markup arguments as
656 a whole.  For example, the @rinternals{RehearsalMark} is
657 horizontally centered, so using @code{\mark \markup @{ \left-align
658 .. @}} has no effect.
659
660
661
662 @node Graphic notation inside markup
663 @subsubsection Graphic notation inside markup
664 Graphics around text:
665 \box
666 \circle
667
668 \bracket
669 \hbracket
670
671 "Standalone" graphics:
672
673 \arrow-head
674 \draw-line
675 \draw-circle
676 \filled-box
677 \triangle
678 \strut
679
680 \with-color
681
682
683 Advanced graphics:
684 \stencil
685
686 \postscript
687 \epsfile
688
689 \with-dimensions
690
691 @node Music notation inside markup
692 @subsubsection Music notation inside markup
693
694 Notes can be printed in markup mode blah blah:
695
696 \note   
697 \note-by-number
698
699 Accidental symbols can be obtained easily:
700
701 \doubleflat
702 \sesquiflat
703 \flat
704 \semiflat
705 \natural
706 \semisharp
707 \sharp
708 \sesquisharp
709 \doublesharp
710
711 Some other notation objects blah blah
712
713 \beam
714 \finger
715 \dynamic
716 \tied-lyric
717 \markalphabet
718 \markletter
719 @c TODO: add \text here? -vv
720
721 Any musical symbol can be printed
722
723 \musicglyph
724 @c TODO: add \lookup here? -vv
725
726
727 The markup mode has support for fret diagrams:
728
729 \fret-diagram 
730 \fret-diagram-terse
731 \fret-diagram-verbose
732
733 An entire @code{\score} block can even be nested in a @code{\markup}
734 block.  In such a case, the @code{\score} must contain a @code{\layout} block.
735
736
737 \score
738
739
740 @lilypond[quote,verbatim,ragged-right]
741 \relative {
742   c4 d^\markup {
743     \score {
744       \relative { c4 d e f }
745       \layout { }
746     }
747   }
748   e f
749 }
750 @end lilypond
751
752 @seealso
753
754 Snippets:
755 @rlsr{Text}.
756
757 @node Multi-page markup
758 @subsubsection Multi-page markup
759
760 Whereas @code{\markup} is used to enter a non-breakable block of
761 text, @code{\markuplines} can be used at top-level to enter lines
762 of text that can spread over multiple pages:
763
764 @verbatim
765 \markuplines {
766   \justified-lines {
767     A very long text of justified lines.
768     ...
769   }
770   \justified-lines {
771     An other very long paragraph.
772     ...
773   }
774   ...
775 }
776 @end verbatim
777
778 @code{\markuplines} accepts a list of markup, that is either the
779 result of a markup list command, or a list of markups or of markup
780 lists.  The built-in markup list commands are described in
781 @ref{Text markup list commands}.
782
783 @seealso
784
785 This manual: @ref{Text markup list commands}, @ref{New
786 markup list command definition}.
787
788 Snippets:
789 @rlsr{Text}.
790
791 @predefined
792
793 @funindex \markuplines
794 @code{\markuplines}
795
796
797 @node Fonts
798 @subsection Fonts
799
800 @menu
801 * Entire document fonts::       
802 * Single entry fonts::          
803 @end menu
804
805 @node Entire document fonts
806 @subsubsection Entire document fonts
807
808 It is also possible to change the default font family for the
809 entire document.  This is done by calling the
810 @code{make-pango-font-tree} from within the @code{\paper} block.
811 The function takes names for the font families to use for roman,
812 sans serif and monospaced text.  For example,
813
814 @cindex font families, setting
815 @cindex Pango
816
817
818 @lilypond[verbatim]
819 \paper  {
820   myStaffSize = #20
821
822   #(define fonts
823     (make-pango-font-tree "Times New Roman"
824                           "Nimbus Sans"
825                           "Luxi Mono"
826                            (/ myStaffSize 20)))
827 }
828
829 {
830   c'^\markup { roman: foo \sans bla \typewriter bar }
831 }
832 @end lilypond
833
834 @c we don't do Helvetica / Courier, since GS incorrectly loads
835 @c Apple TTF fonts
836
837
838 @node Single entry fonts
839 @subsubsection Single entry fonts
840
841 @cindex font selection
842 @cindex font magnification
843 @funindex font-interface
844
845 By setting the object properties described below, you can select a
846 font from the preconfigured font families.  LilyPond has default
847 support for the feta music fonts.  Text fonts are selected through
848 Pango/FontConfig.  The serif font defaults to New Century
849 Schoolbook, the sans and typewriter to whatever the Pango
850 installation defaults to.
851
852
853 @itemize
854 @item @code{font-encoding}
855 is a symbol that sets layout of the glyphs.  This should only be
856 set to select different types of non-text fonts, e.g.
857
858 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
859 standard music font, including ancient glyphs, @code{fetaDynamic}
860 for dynamic signs and @code{fetaNumber} for the number font.
861
862 @item @code{font-family}
863 is a symbol indicating the general class of the typeface.
864 Supported are @code{roman} (Computer Modern), @code{sans}, and
865 @code{typewriter}.
866
867 @item @code{font-shape}
868 is a symbol indicating the shape of the font.  There are typically
869 several font shapes available for each font family.  Choices are
870 @code{italic}, @code{caps}, and @code{upright}.
871
872 @item @code{font-series}
873 is a symbol indicating the series of the font.  There are
874 typically several font series for each font family and shape.
875 Choices are @code{medium} and @code{bold}.
876
877 @end itemize
878
879 Fonts selected in the way sketched above come from a predefined
880 style sheet.  If you want to use a font from outside the style
881 sheet, then set the @code{font-name} property,
882
883 @lilypond[fragment,verbatim]
884 {
885   \override Staff.TimeSignature #'font-name = #"Charter"
886   \override Staff.TimeSignature #'font-size = #2
887   \time 3/4
888   c'1_\markup {
889     \override #'(font-name . "Vera Bold")
890       { This text is in Vera Bold }
891   }
892 }
893 @end lilypond
894
895 @noindent
896 Any font can be used, as long as it is available to
897 Pango/FontConfig.  To get a full list of all available fonts, run
898 the command
899
900 @example
901 lilypond -dshow-available-fonts blabla
902 @end example
903
904 (the last argument of the command can be anything, but has to be
905 present).
906
907
908 The size of the font may be set with the @code{font-size}
909 property.  The resulting size is taken relative to the
910 @code{text-font-size} as defined in the @code{\paper} block.
911
912 @cindex font size
913 @cindex font magnification
914
915
916
917
918 @seealso
919
920 Snippets:
921 @rlsr{Text}.
922
923