]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/text.itely
Merge branch 'master' of ssh://kainhofer@git.sv.gnu.org/srv/git/lilypond into dev...
[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 @node Text
10 @section Text
11
12 @lilypondfile[quote]{text-headword.ly}
13
14 This section explains how to include text (with various
15 formatting) in your scores.
16
17 @cindex Text, other languages
18 @warning{To write accented and special text (such as characters
19 from other languages), simply insert the characters directly into
20 the LilyPond file.  The file must be saved as UTF-8.  For more
21 information, see @ref{Text encoding}.}
22
23 @menu
24 * Writing text::                
25 * Text markup::                 
26 @end menu
27
28
29 @node Writing text
30 @subsection Writing text
31
32 @menu
33 * Overview of text entry::      
34 * Text scripts::                
35 * Text spanners::               
36 * Text marks::                  
37 @end menu
38
39 @node Overview of text entry
40 @subsubsection Overview of text entry
41
42 There are four ways to add text to scores:
43
44 @itemize
45 @item
46 @ref{Text scripts}: blah blah
47
48 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
49 c4^"text" c c c
50 @end lilypond
51
52 @item
53 @ref{Text spanners}: blah blah
54
55 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
56 c1
57 \override TextSpanner #'bound-details #'left #'text =
58   \markup { \upright "rall" } 
59 c2\startTextSpan b c\stopTextSpan a
60 @end lilypond
61
62 @item
63 @ref{Text marks}: blah blah
64
65 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
66 c4\mark "foo" c c c
67 @end lilypond
68
69 @item
70 @ref{Vocal music}: blah blah, not in this section.
71
72 @lilypond[verbatim,quote,ragged-right]
73 <<
74   \relative c'' { c4 c c c }
75   \addlyrics { one two three four }
76 >>
77 @end lilypond
78
79 @end itemize
80
81 @seealso
82
83 Snippets: @lsrdir{Text,Text}
84
85
86
87 @node Text scripts
88 @subsubsection Text scripts
89
90 @cindex Text scripts
91 @cindex text items, non-empty
92 @cindex non-empty texts
93
94 It is possible to add arbitrary text indications with
95 @var{note}@code{-"}@var{text}@code{"}.
96 Such indications can also be manually placed
97 above or below the staff, using the
98 simple syntax described in @ref{Controlling direction and
99 placement}.
100
101 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
102 d8^"pizz." e f g a4-"scherz." f
103 @end lilypond
104
105 In LilyPond, such text strings are called @command{markup}
106 objects.  This syntax is actually a shorthand; more complex text
107 formatting may be added to a note by explicitly using the
108 @code{\markup} command, as described in @ref{Text markup}.
109
110 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
111 d8^\markup { \italic pizz. } e f g 
112 a4_\markup { \tiny scherz. \bold molto } f
113 @end lilypond
114
115 By default, text indications do not influence the note spacing.
116 However, their widths can be taken into account:
117 in the following example, the first text string does not affect 
118 spacing, whereas the second one does.
119
120 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
121 d8^"pizz." e f g \textLengthOn a4_"scherzando" f
122 @end lilypond
123
124 @predefined
125
126 @funindex \textLengthOn
127 @code{\textLengthOn},
128 @funindex \textLengthOff
129 @code{\textLengthOff}
130
131
132 @seealso
133
134 Notation Reference: @ref{Text markup}.
135
136 Snippets: @lsrdir{Text,Text}
137
138 Internals Reference: @internalsref{TextScript}.
139
140 @knownissues
141
142 Checking to make sure that text scripts and lyrics are within the
143 margins is a relatively large computational task.  To speed up
144 processing, LilyPond does not perform such calculations by
145 default; to enable it, use
146
147 @example
148 \override Score.PaperColumn #'keep-inside-line = ##t
149 @end example
150
151
152 @node Text spanners
153 @subsubsection Text spanners
154
155 @cindex Text spanners
156
157 Some performance indications, e.g., @i{rallentando} or
158 @i{accelerando}, are written as text and are extended over many
159 measures with dotted lines.
160
161 Such objects, called @q{spanners}, may be created
162 from one note to another by using the following syntax:
163
164 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
165 \override TextSpanner #'bound-details #'left #'text = "rit." 
166 b1\startTextSpan 
167 e,\stopTextSpan
168 @end lilypond
169
170 @noindent
171 The string to be printed is set through
172 object properties. By default it is printed in italic characters,
173 but different formatting can be obtained using
174 @code{\markup} blocks:
175
176 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
177 \override TextSpanner #'bound-details #'left #'text =
178   \markup { \upright "rit." } 
179 b1\startTextSpan c
180 e,\stopTextSpan
181 @end lilypond
182
183 The line style, as well as the text string, can be defined as an
184 object property. This syntax is described in @ref{Line styles}.
185
186 @predefined
187
188 @funindex textSpannerUp
189 @code{\textSpannerUp},
190 @funindex textSpannerDown
191 @code{\textSpannerDown},
192 @funindex textSpannerNeutral
193 @code{\textSpannerNeutral}
194
195 @seealso
196
197 Snippets: @lsrdir{Text,Text}
198
199 Internals Reference: @internalsref{TextSpanner}.
200
201
202 @node Text marks
203 @subsubsection Text marks
204
205 @cindex coda on bar line
206 @cindex segno on bar line
207 @cindex fermata on bar line
208 @cindex bar lines, symbols on
209 @funindex \mark
210
211 Various text elements can be added to a score using
212 the syntax described in @ref{Rehearsal marks}:
213
214 @lilypond[verbatim,quote,ragged-right,fragment,relative=2]
215 c4\mark "dolce" c c c
216 @end lilypond
217
218 This syntax makes possible to put any text on a bar line;
219 more complex text formatting may be added using a @code{\markup}
220 block, as described in @ref{Text markup}.  This can be used to print
221 signs like coda, segno or fermata, by specifying the appropriate
222 symbol name:
223
224 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
225 c1 \mark \markup { \musicglyph #"scripts.ufermata" }
226 c1
227 @end lilypond
228
229 @noindent
230 Such objects are only typeset above the top staff of the score; they
231 can be placed above the bar line or between notes, depending on whether
232 you specify it at the end or the middle of a bar. When specified at the
233 beginning of a score or at a line break, the mark will be printed at
234 the beginning of the line (the next line, in case of a line break).
235
236 @lilypond[fragment,quote,ragged-right,verbatim,relative=2]
237 \mark "dolce" c1
238 c\mark "assai" \break
239 c c
240 @end lilypond
241
242
243 @snippets
244
245 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
246 {printing-marks-at-the-end-of-a-line-or-a-score.ly}
247
248 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
249 {aligning-marks-with-various-notation-objects.ly}
250
251 @lilypondfile[verbatim,lilyquote,ragged-right,texidoc]
252 {printing-marks-on-every-staff.ly}
253
254 @seealso
255
256 Snippets: @lsrdir{Text,Text}
257
258 Internals Reference: @internalsref{RehearsalMark}.
259
260 @knownissues
261 @c  IMO this is a bug; hopefully it'll be fixed soon, so I can
262 @c  delete this sentence.   -gp
263 @c  A workaround is suggested in the first @snippets item -vv
264
265 If a mark is entered at the end of the last bar of the score (where
266 there is no next line), then the mark will not be printed at
267 all.
268
269 @node Text markup
270 @subsection Text markup
271
272 @menu
273 * Text markup introduction::    
274 * Nested scores::               
275 * Page wrapping text::          
276 * Font selection::              
277 @end menu
278
279 @node Text markup introduction
280 @subsubsection Text markup introduction
281
282 @cindex markup
283 @cindex text markup
284 @cindex markup text
285 @cindex typeset text
286
287 A @code{\markup} block is used to typeset text with an extensible syntax,
288 called @q{markup mode}.
289 Specific commands can be entered in this mode, using the
290 backslash @code{\} character.
291 @c TODO: move the following sentence (and add an example?) -vv
292 To @emph{print} such characters as
293 @code{\} and @code{#} in the output, use double
294 quotation marks.
295
296 @lilypond[quote,verbatim,fragment,relative=1]
297 c1^\markup { hello }
298 c1_\markup { hi there }
299 c1^\markup { hi \bold there, is \italic {anyone home?} }
300 c1_\markup { "\special {weird} #characters" }
301 @end lilypond
302
303 @noindent
304 An exhaustive list of @code{\markup}-specific commands can be found in
305 @ref{Text markup commands}.
306
307 @code{\markup} blocks can be used anywhere text is called,
308 and not only for @internalsref{TextScript}s objects.
309
310 @lilypond[quote,verbatim]
311 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
312 \score{
313   \relative c'' {
314     \override Score.RehearsalMark
315       #'break-visibility = #begin-of-line-invisible
316     \override Score.RehearsalMark #'self-alignment-X = #right
317
318     \set Staff.instrumentName = \markup{ \column{ Alto solo } }
319     c2^\markup{ don't be \flat }
320     \override TextSpanner #'bound-details #'left #'text = \markup{\italic rit }
321     b2\startTextSpan
322     a2\mark \markup{ \large \bold Fine }
323     r2\stopTextSpan
324     \bar "||"
325   }
326   \addlyrics { bar, foo \markup{ \italic bar! } }
327 }
328 @end lilypond
329
330 A @code{\markup} block can also be printed on its own at the top-level
331 of the input file, away from
332 any @code{\score} block. This syntax is described in
333 @ref{Multiple scores in a book}.
334
335 @lilypond[quote,ragged-right,verbatim]
336 \markup{ Here is some text. }
337 @end lilypond
338
339 @cindex font switching
340
341 Some font switching commands are demonstrated here. Such commands
342 apply only to the first following word; several words may be affected
343 by enclosing them in braces.
344
345 @example
346 \markup @{ \bold @{ hi there @} @}
347 @end example
348
349 @c TODO: remove the following line and example? -vv
350 @noindent
351 For clarity, you can also do this for single arguments, e.g.,
352
353 @example
354 \markup @{ is \italic @{ anyone @} home @}
355 @end example
356
357 The markup mode can be used to compose expressions, similar to
358 mathematical expressions, XML documents, and music expressions.
359 Such expressions can be vertically stacked, horizontally centered, 
360 or aligned in different ways:
361
362 @lilypond[quote,verbatim,fragment,relative=1]
363 c1^\markup { \column { a bbbb \line { c d } } }
364 c1^\markup { \center-align { a bbbb c } }
365 c1^\markup { \line { a b c } }
366 @end lilypond
367
368 Lists with no previous command are not kept distinct.  In
369 the following example, the two @code{\markup} expressions
370 are equivalent:
371
372 @c TODO: merge these two examples in a @lilypond example -vv
373
374 @example
375 \center-align @{ @{ a b @} @{ c d @} @}
376 \center-align @{ a b c d @}
377 @end example
378
379 @noindent
380
381 To keep lists of words distinct, please use quotes @code{"} or
382 the @code{\line} command
383
384 @lilypond[quote,verbatim,fragment,relative=1]
385 \textLengthOn
386 c4^\markup{ \center-align { on three lines } }
387 c4^\markup{ \center-align { "all one line" } }
388 c4^\markup{ \center-align { { on three lines } } }
389 c4^\markup{ \center-align { \line { on one line } } }
390 @end lilypond
391
392 Markups can be stored in variables and these variables may be
393 attached to notes, like
394
395 @example
396 allegro = \markup @{ \bold \large @{ Allegro @} @}
397  @{ a^\allegro b c d @}
398 @end example
399
400 Some objects have alignment procedures of their own, which cancel
401 out any effects of alignments applied to their markup arguments as
402 a whole.  For example, the @internalsref{RehearsalMark} is
403 horizontally centered, so using @code{\mark \markup @{ \left-align
404 .. @}} has no effect.
405
406 In addition, vertical placement is performed after creating the
407 text markup object.  If you wish to move an entire piece of
408 markup, you need to use the #'padding property or create an
409 @q{anchor} point inside the markup (generally with @code{\hspace
410 #0}).
411
412 @lilypond[quote,verbatim,fragment,relative=1]
413 \textLengthOn
414 c'4^\markup{ \raise #5 "not raised" }
415 \once \override TextScript #'padding = #3
416 c'4^\markup{ raised }
417 c'4^\markup{ \hspace #0 \raise #1.5 raised }
418 @end lilypond
419
420 Some situations (such as dynamic marks) have preset font-related
421 properties.  If you are creating text in such situations, it is
422 advisable to cancel those properties with @code{normal-text}.  See
423 @ref{Text markup commands}, for more details.
424
425
426 @seealso
427
428 This manual: @ref{Text markup commands}.
429
430 Snippets: @lsrdir{Text,Text}
431
432 Internals Reference: @internalsref{TextScript}.
433
434 Init files: @file{scm/@/new@/-markup@/.scm}.
435
436
437 @knownissues
438
439 Kerning or generation of ligatures is only done when the @TeX{}
440 backend is used.  In this case, LilyPond does not account for them
441 so texts will be spaced slightly too wide.
442
443 Syntax errors for markup mode are confusing.
444
445
446 @node Nested scores
447 @subsubsection Nested scores
448
449 It is possible to nest music inside markups, by adding a
450 @code{\score} block to a markup expression.  Such a score must
451 contain a @code{\layout} block.
452
453 @lilypond[quote,verbatim,ragged-right]
454 \relative {
455   c4 d^\markup {
456     \score {
457       \relative { c4 d e f }
458       \layout { }
459     }
460   }
461   e f
462 }
463 @end lilypond
464
465 @seealso
466
467 Snippets: @lsrdir{Text,Text}
468
469 @node Page wrapping text
470 @subsubsection Page wrapping text
471
472 Whereas @code{\markup} is used to enter a non-breakable block of
473 text, @code{\markuplines} can be used at top-level to enter lines
474 of text that can spread over multiple pages:
475
476 @verbatim
477 \markuplines {
478   \justified-lines {
479     A very long text of justified lines.
480     ...
481   }
482   \justified-lines {
483     An other very long paragraph.
484     ...
485   }
486   ...
487 }
488 @end verbatim
489
490 @code{\markuplines} accepts a list of markup, that is either the
491 result of a markup list command, or a list of markups or of markup
492 lists.  The built-in markup list commands are described in
493 @ref{Text markup list commands}.
494
495 @seealso
496
497 This manual: @ref{Text markup list commands}, @ref{New
498 markup list command definition}.
499
500 Snippets: @lsrdir{Text,Text}
501
502 @predefined
503
504 @funindex \markuplines
505 @code{\markuplines}
506
507 @node Font selection
508 @subsubsection Font selection
509
510 @cindex font selection
511 @cindex font magnification
512 @funindex font-interface
513
514 By setting the object properties described below, you can select a
515 font from the preconfigured font families.  LilyPond has default
516 support for the feta music fonts.  Text fonts are selected through
517 Pango/FontConfig.  The serif font defaults to New Century
518 Schoolbook, the sans and typewriter to whatever the Pango
519 installation defaults to.
520
521
522 @itemize
523 @item @code{font-encoding}
524 is a symbol that sets layout of the glyphs.  This should only be
525 set to select different types of non-text fonts, e.g.
526
527 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
528 standard music font, including ancient glyphs, @code{fetaDynamic}
529 for dynamic signs and @code{fetaNumber} for the number font.
530
531 @item @code{font-family}
532 is a symbol indicating the general class of the typeface.
533 Supported are @code{roman} (Computer Modern), @code{sans}, and
534 @code{typewriter}.
535
536 @item @code{font-shape}
537 is a symbol indicating the shape of the font.  There are typically
538 several font shapes available for each font family.  Choices are
539 @code{italic}, @code{caps}, and @code{upright}.
540
541 @item @code{font-series}
542 is a symbol indicating the series of the font.  There are
543 typically several font series for each font family and shape.
544 Choices are @code{medium} and @code{bold}.
545
546 @end itemize
547
548 Fonts selected in the way sketched above come from a predefined
549 style sheet.  If you want to use a font from outside the style
550 sheet, then set the @code{font-name} property,
551
552 @lilypond[fragment,verbatim]
553 {
554   \override Staff.TimeSignature #'font-name = #"Charter"
555   \override Staff.TimeSignature #'font-size = #2
556   \time 3/4
557   c'1_\markup {
558     \override #'(font-name . "Vera Bold")
559       { This text is in Vera Bold }
560   }
561 }
562 @end lilypond
563
564 @noindent
565 Any font can be used, as long as it is available to
566 Pango/FontConfig.  To get a full list of all available fonts, run
567 the command
568
569 @example
570 lilypond -dshow-available-fonts blabla
571 @end example
572
573 (the last argument of the command can be anything, but has to be
574 present).
575
576
577 The size of the font may be set with the @code{font-size}
578 property.  The resulting size is taken relative to the
579 @code{text-font-size} as defined in the @code{\paper} block.
580
581 @cindex font size
582 @cindex font magnification
583
584
585 It is also possible to change the default font family for the
586 entire document.  This is done by calling the
587 @code{make-pango-font-tree} from within the @code{\paper} block.
588 The function takes names for the font families to use for roman,
589 sans serif and monospaced text.  For example,
590
591 @cindex font families, setting
592 @cindex Pango
593
594
595 @lilypond[verbatim]
596 \paper  {
597   myStaffSize = #20
598
599   #(define fonts
600     (make-pango-font-tree "Times New Roman"
601                           "Nimbus Sans"
602                           "Luxi Mono"
603                            (/ myStaffSize 20)))
604 }
605
606 {
607   c'^\markup { roman: foo \sans bla \typewriter bar }
608 }
609 @end lilypond
610
611 @c we don't do Helvetica / Courier, since GS incorrectly loads
612 @c Apple TTF fonts
613
614
615
616 @seealso
617
618 Snippets: @lsrdir{Text,Text}
619
620