]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/text.itely
Resolve conflict, maybe?
[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: @lsrdir{Text,Text}
101
102 Internals Reference: @internalsref{TextScript}.
103
104 @knownissues
105
106 Checking to make sure that text scripts and lyrics are within the
107 margins is a relatively large computational task.  To speed up
108 processing, LilyPond does not perform such calculations by
109 default; to enable it, use
110
111 @example
112 \override Score.PaperColumn #'keep-inside-line = ##t
113 @end example
114
115
116 @node Text spanners
117 @subsubsection Text spanners
118
119 @cindex Text spanners
120
121 Some performance indications, e.g., @i{rallentando} or
122 @i{accelerando}, are written as text and are extended over many
123 measures with dotted lines.
124
125 Such objects, called @q{spanners}, may be created
126 from one note to another by 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:
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: @lsrdir{Text,Text}
164
165 Internals Reference: @internalsref{TextSpanner}.
166
167
168 @node Text marks
169 @subsubsection Text marks
170
171 @cindex coda on bar line
172 @cindex segno on bar line
173 @cindex fermata on bar line
174 @cindex bar lines, symbols on
175 @funindex \mark
176
177 Various text elements can be added to a score using
178 the syntax described in @ref{Rehearsal marks}:
179
180 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
181 c4\mark "dolce" c c c
182 @end lilypond
183
184 This syntax makes possible to put any text on a bar line;
185 more complex text formatting may be added using a @code{\markup}
186 block, as described in @ref{Formatting text}.  This can be used to print
187 signs like coda, segno or fermata, by specifying the appropriate
188 symbol name:
189
190 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
191 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
192 c1
193 @end lilypond
194
195 @noindent
196 Such objects are only typeset above the top staff of the score; they
197 can be placed above the bar line or between notes, depending on whether
198 you specify it at the end or the middle of a bar. When specified at the
199 beginning of a score or at a line break, the mark will be printed at
200 the beginning of the line (the next line, in case of a line break).
201
202 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
203 \mark "dolce" c1
204 c\mark "assai" \break
205 c c
206 @end lilypond
207
208
209 @snippets
210
211 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
212 {printing-marks-at-the-end-of-a-line-or-a-score.ly}
213
214 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
215 {aligning-marks-with-various-notation-objects.ly}
216
217 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
218 {printing-marks-on-every-staff.ly}
219
220 @seealso
221
222 Notation Reference: @ref{Rehearsal marks},
223 @ref{Formatting text}, @ref{The Feta font}.
224
225 Snippets: @lsrdir{Text,Text}
226
227 Internals Reference: @internalsref{RehearsalMark}.
228
229 @knownissues
230 @c  IMO this is a bug; hopefully it'll be fixed soon, so I can
231 @c  delete this sentence.   -gp
232 @c  A workaround is suggested in the first @snippets item -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.  This syntax is called a @q{top-level
249 expression}, and is described in @code{File structure}.
250
251 @c TODO: turn this into a @lilypond example
252
253 @example
254 \markup @{
255   @var{..}
256 @}
257 @end example
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 @example
267 \score @{
268   @var{..}
269 @}
270 \markup @{
271   @var{..}
272 @}
273 \score @{
274   @var{..}
275 @}
276 @end example
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-pages markup}.
283
284 @ignore
285 @snippets
286
287 TODO: add convenient snippets, e.g.
288 "Inserting large plain text sections"
289 (this requires the LSR to be updated) -vv
290 @end ignore
291
292 @seealso
293
294 Notation Reference: @code{Formatting text},
295 @code{File structure}, 
296 @ref{Multiple scores in a book},
297 @ref{Multi-pages markup}.
298
299 Snippets: @lsrdir{Text,Text}.
300
301 Internals Reference: @internalsref{TextScript}.
302
303 @predefined
304
305 @funindex \markup
306 @code{\markup},
307 @funindex \markuplines
308 @code{\markuplines}
309
310
311 @node Formatting text
312 @subsection Formatting text
313
314 This section presents basic and advanced text formatting,
315 using the @code{\markup} mode specific syntax.
316
317 @menu
318 * Text markup introduction::    
319 * Common markup commands::      
320 * Text alignment::              
321 * Graphic notation inside markup::  
322 * Music notation inside markup::  
323 * Multi-pages markup::          
324 @end menu
325
326 @node Text markup introduction
327 @subsubsection Text markup introduction
328
329 @cindex markup
330 @cindex text markup
331 @cindex markup text
332 @cindex typeset text
333
334 A @code{\markup} block is used to typeset text with an extensible syntax,
335 called @q{markup mode}.
336 Specific commands can be entered in this mode, using the
337 backslash @code{\} character.
338 @c TODO: move the following sentence (and add an example?) -vv
339 To @emph{print} such characters as
340 @code{\} and @code{#} in the output, use double
341 quotation marks.
342
343 @lilypond[quote,verbatim,fragment,relative=1]
344 c1^\markup { hello }
345 c1_\markup { hi there }
346 c1^\markup { hi \bold there, is \italic {anyone home?} }
347 c1_\markup { "\special {weird} #characters" }
348 @end lilypond
349
350 @noindent
351 An exhaustive list of @code{\markup}-specific commands can be found in
352 @ref{Text markup commands}.
353
354 @code{\markup} blocks can be used anywhere text is called,
355 and not only for @internalsref{TextScript}s objects.
356
357 @lilypond[quote,verbatim]
358 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
359 \score{
360   \relative c'' {
361     \override Score.RehearsalMark
362       #'break-visibility = #begin-of-line-invisible
363     \override Score.RehearsalMark #'self-alignment-X = #right
364
365     \set Staff.instrumentName = \markup{ \column{ Alto solo } }
366     c2^\markup{ don't be \flat }
367     \override TextSpanner #'bound-details #'left #'text = \markup{\italic rit }
368     b2\startTextSpan
369     a2\mark \markup{ \large \bold Fine }
370     r2\stopTextSpan
371     \bar "||"
372   }
373   \addlyrics { bar, foo \markup{ \italic bar! } }
374 }
375 @end lilypond
376
377 A @code{\markup} block can also be printed on its own at the top-level
378 of the input file, away from
379 any @code{\score} block. This syntax is described in
380 @ref{Multiple scores in a book}.
381
382 @lilypond[quote,ragged-right,verbatim]
383 \markup{ Here is some text. }
384 @end lilypond
385
386 @cindex font switching
387
388 Some font switching commands are demonstrated here. Such commands
389 apply only to the first following word; several words may be affected
390 by enclosing them in braces.
391
392 @example
393 \markup @{ \bold @{ hi there @} @}
394 @end example
395
396 @c TODO: remove the following line and example? -vv
397 @noindent
398 For clarity, you can also do this for single arguments, e.g.,
399
400 @example
401 \markup @{ is \italic @{ anyone @} home @}
402 @end example
403
404 The markup mode can be used to compose expressions, similar to
405 mathematical expressions, XML documents, and music expressions.
406 Such expressions can be vertically stacked, horizontally centered, 
407 or aligned in different ways:
408
409 @lilypond[quote,verbatim,fragment,relative=1]
410 c1^\markup { \column { a bbbb \line { c d } } }
411 c1^\markup { \center-align { a bbbb c } }
412 c1^\markup { \line { a b c } }
413 @end lilypond
414
415 Lists with no previous command are not kept distinct.  In
416 the following example, the two @code{\markup} expressions
417 are equivalent:
418
419 @c TODO: merge these two examples in a @lilypond example -vv
420
421 @example
422 \center-align @{ @{ a b @} @{ c d @} @}
423 \center-align @{ a b c d @}
424 @end example
425
426 @noindent
427
428 To keep lists of words distinct, please use quotes @code{"} or
429 the @code{\line} command
430
431 @lilypond[quote,verbatim,fragment,relative=1]
432 \textLengthOn
433 c4^\markup{ \center-align { on three lines } }
434 c4^\markup{ \center-align { "all one line" } }
435 c4^\markup{ \center-align { { on three lines } } }
436 c4^\markup{ \center-align { \line { on one line } } }
437 @end lilypond
438
439 Markups can be stored in variables and these variables may be
440 attached to notes, like
441
442 @example
443 allegro = \markup @{ \bold \large @{ Allegro @} @}
444  @{ a^\allegro b c d @}
445 @end example
446
447 Some objects have alignment procedures of their own, which cancel
448 out any effects of alignments applied to their markup arguments as
449 a whole.  For example, the @internalsref{RehearsalMark} is
450 horizontally centered, so using @code{\mark \markup @{ \left-align
451 .. @}} has no effect.
452
453 In addition, vertical placement is performed after creating the
454 text markup object.  If you wish to move an entire piece of
455 markup, you need to use the #'padding property or create an
456 @q{anchor} point inside the markup (generally with @code{\hspace
457 #0}).
458
459 @lilypond[quote,verbatim,fragment,relative=1]
460 \textLengthOn
461 c'4^\markup{ \raise #5 "not raised" }
462 \once \override TextScript #'padding = #3
463 c'4^\markup{ raised }
464 c'4^\markup{ \hspace #0 \raise #1.5 raised }
465 @end lilypond
466
467 Some situations (such as dynamic marks) have preset font-related
468 properties.  If you are creating text in such situations, it is
469 advisable to cancel those properties with @code{normal-text}.  See
470 @ref{Text markup commands}, for more details.
471
472
473 @seealso
474
475 This manual: @ref{Text markup commands}.
476
477 Snippets: @lsrdir{Text,Text}
478
479 Internals Reference: @internalsref{TextScript}.
480
481 Init files: @file{scm/@/new@/-markup@/.scm}.
482
483
484 @knownissues
485
486 Kerning or generation of ligatures is only done when the @TeX{}
487 backend is used.  In this case, LilyPond does not account for them
488 so texts will be spaced slightly too wide.
489
490 Syntax errors for markup mode are confusing.
491
492 @node Common markup commands
493 @subsubsection Common markup commands
494
495 TODO: everything
496
497 @node Text alignment
498 @subsubsection Text alignment
499
500 TODO: everything
501
502 @node Graphic notation inside markup
503 @subsubsection Graphic notation inside markup
504
505 TODO: everything
506
507 @node Music notation inside markup
508 @subsubsection Music notation inside markup
509
510 It is possible to nest music inside markups, by adding a
511 @code{\score} block to a markup expression.  Such a score must
512 contain a @code{\layout} block.
513
514 @lilypond[quote,verbatim,ragged-right]
515 \relative {
516   c4 d^\markup {
517     \score {
518       \relative { c4 d e f }
519       \layout { }
520     }
521   }
522   e f
523 }
524 @end lilypond
525
526 @seealso
527
528 Snippets: @lsrdir{Text,Text}
529
530 @node Multi-pages markup
531 @subsubsection Multi-pages markup
532
533 Whereas @code{\markup} is used to enter a non-breakable block of
534 text, @code{\markuplines} can be used at top-level to enter lines
535 of text that can spread over multiple pages:
536
537 @verbatim
538 \markuplines {
539   \justified-lines {
540     A very long text of justified lines.
541     ...
542   }
543   \justified-lines {
544     An other very long paragraph.
545     ...
546   }
547   ...
548 }
549 @end verbatim
550
551 @code{\markuplines} accepts a list of markup, that is either the
552 result of a markup list command, or a list of markups or of markup
553 lists.  The built-in markup list commands are described in
554 @ref{Text markup list commands}.
555
556 @seealso
557
558 This manual: @ref{Text markup list commands}, @ref{New
559 markup list command definition}.
560
561 Snippets: @lsrdir{Text,Text}
562
563 @predefined
564
565 @funindex \markuplines
566 @code{\markuplines}
567
568
569
570 @c TODO: move the following subsubsec into NR3 -vv
571 @c maybe.  -gp
572 @node Fonts
573 @subsection Fonts
574
575 @menu
576 * Entire document fonts::       
577 * Single entry fonts::          
578 @end menu
579
580 @node Entire document fonts
581 @subsubsection Entire document fonts
582
583 It is also possible to change the default font family for the
584 entire document.  This is done by calling the
585 @code{make-pango-font-tree} from within the @code{\paper} block.
586 The function takes names for the font families to use for roman,
587 sans serif and monospaced text.  For example,
588
589 @cindex font families, setting
590 @cindex Pango
591
592
593 @lilypond[verbatim]
594 \paper  {
595   myStaffSize = #20
596
597   #(define fonts
598     (make-pango-font-tree "Times New Roman"
599                           "Nimbus Sans"
600                           "Luxi Mono"
601                            (/ myStaffSize 20)))
602 }
603
604 {
605   c'^\markup { roman: foo \sans bla \typewriter bar }
606 }
607 @end lilypond
608
609 @c we don't do Helvetica / Courier, since GS incorrectly loads
610 @c Apple TTF fonts
611
612
613 @node Single entry fonts
614 @subsubsection Single entry fonts
615
616 @cindex font selection
617 @cindex font magnification
618 @funindex font-interface
619
620 By setting the object properties described below, you can select a
621 font from the preconfigured font families.  LilyPond has default
622 support for the feta music fonts.  Text fonts are selected through
623 Pango/FontConfig.  The serif font defaults to New Century
624 Schoolbook, the sans and typewriter to whatever the Pango
625 installation defaults to.
626
627
628 @itemize
629 @item @code{font-encoding}
630 is a symbol that sets layout of the glyphs.  This should only be
631 set to select different types of non-text fonts, e.g.
632
633 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
634 standard music font, including ancient glyphs, @code{fetaDynamic}
635 for dynamic signs and @code{fetaNumber} for the number font.
636
637 @item @code{font-family}
638 is a symbol indicating the general class of the typeface.
639 Supported are @code{roman} (Computer Modern), @code{sans}, and
640 @code{typewriter}.
641
642 @item @code{font-shape}
643 is a symbol indicating the shape of the font.  There are typically
644 several font shapes available for each font family.  Choices are
645 @code{italic}, @code{caps}, and @code{upright}.
646
647 @item @code{font-series}
648 is a symbol indicating the series of the font.  There are
649 typically several font series for each font family and shape.
650 Choices are @code{medium} and @code{bold}.
651
652 @end itemize
653
654 Fonts selected in the way sketched above come from a predefined
655 style sheet.  If you want to use a font from outside the style
656 sheet, then set the @code{font-name} property,
657
658 @lilypond[fragment,verbatim]
659 {
660   \override Staff.TimeSignature #'font-name = #"Charter"
661   \override Staff.TimeSignature #'font-size = #2
662   \time 3/4
663   c'1_\markup {
664     \override #'(font-name . "Vera Bold")
665       { This text is in Vera Bold }
666   }
667 }
668 @end lilypond
669
670 @noindent
671 Any font can be used, as long as it is available to
672 Pango/FontConfig.  To get a full list of all available fonts, run
673 the command
674
675 @example
676 lilypond -dshow-available-fonts blabla
677 @end example
678
679 (the last argument of the command can be anything, but has to be
680 present).
681
682
683 The size of the font may be set with the @code{font-size}
684 property.  The resulting size is taken relative to the
685 @code{text-font-size} as defined in the @code{\paper} block.
686
687 @cindex font size
688 @cindex font magnification
689
690
691
692
693 @seealso
694
695 Snippets: @lsrdir{Text,Text}
696
697