]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/text.itely
Merge branch 'master' of git://git.sv.gnu.org/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
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 @lsrdir{Text,Text}
102
103 Internals Reference: @internalsref{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 @lsrdir{Text,Text}
165
166 Internals Reference: @internalsref{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 @lsrdir{Text,Text}
228
229 Internals Reference: @internalsref{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 @lsrdir{Text,Text}
306
307 Internals Reference: @internalsref{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 syntax,
334 called @qq{markup mode}.
335 Specific commands can be entered in this mode, using the
336 backslash @code{\} character.
337 @c TODO: move the following sentence (and add an example?) -vv
338 To @emph{print} such characters as
339 @code{\} and @code{#} in the output, use double
340 quotation marks.
341
342 @lilypond[quote,verbatim,fragment,relative=1]
343 c1^\markup { hello }
344 c1_\markup { hi there }
345 c1^\markup { hi \bold there, is \italic {anyone home?} }
346 c1_\markup { "\special {weird} #characters" }
347 @end lilypond
348
349 @noindent
350 An exhaustive list of @code{\markup}-specific commands can be found in
351 @ref{Text markup commands}.
352
353
354 @lilypond[quote,verbatim]
355 \header{ title = \markup{ \bold { foo \italic { bar! } } } }
356 \score{
357   \relative c'' {
358     \override Score.RehearsalMark
359       #'break-visibility = #begin-of-line-invisible
360     \override Score.RehearsalMark #'self-alignment-X = #right
361
362     \set Staff.instrumentName = \markup{ \column{ Alto solo } }
363     c2^\markup{ don't be \flat }
364     \override TextSpanner #'bound-details #'left #'text = \markup{\italic rit }
365     b2\startTextSpan
366     a2\mark \markup{ \large \bold Fine }
367     r2\stopTextSpan
368     \bar "||"
369   }
370   \addlyrics { bar, foo \markup{ \italic bar! } }
371 }
372 @end lilypond
373
374
375
376 @cindex font switching
377
378 Some font switching commands are demonstrated here. Such commands
379 apply only to the first following word; several words may be affected
380 by enclosing them in braces.
381
382 @example
383 \markup @{ \bold @{ hi there @} @}
384 @end example
385
386 @c TODO: remove the following line and example? -vv
387 @noindent
388 For clarity, you can also do this for single arguments, e.g.,
389
390 @example
391 \markup @{ is \italic @{ anyone @} home @}
392 @end example
393
394 The markup mode can be used to compose expressions, similar to
395 mathematical expressions, XML documents, and music expressions.
396 Such expressions can be vertically stacked, horizontally centered, 
397 or aligned in different ways:
398
399 @lilypond[quote,verbatim,fragment,relative=1]
400 c1^\markup { \column { a bbbb \line { c d } } }
401 c1^\markup { \center-align { a bbbb c } }
402 c1^\markup { \line { a b c } }
403 @end lilypond
404
405 Lists with no previous command are not kept distinct.  In
406 the following example, the two @code{\markup} expressions
407 are equivalent:
408
409 @c TODO: merge these two examples in a @lilypond example -vv
410
411 @example
412 \center-align @{ @{ a b @} @{ c d @} @}
413 \center-align @{ a b c d @}
414 @end example
415
416 @noindent
417
418 To keep lists of words distinct, please use quotes @code{"} or
419 the @code{\line} command
420
421 @lilypond[quote,verbatim,fragment,relative=1]
422 \textLengthOn
423 c4^\markup{ \center-align { on three lines } }
424 c4^\markup{ \center-align { "all one line" } }
425 c4^\markup{ \center-align { { on three lines } } }
426 c4^\markup{ \center-align { \line { on one line } } }
427 @end lilypond
428
429 Markups can be stored in variables and these variables may be
430 attached to notes, like
431
432 @example
433 allegro = \markup @{ \bold \large @{ Allegro @} @}
434  @{ a^\allegro b c d @}
435 @end example
436
437 Some objects have alignment procedures of their own, which cancel
438 out any effects of alignments applied to their markup arguments as
439 a whole.  For example, the @internalsref{RehearsalMark} is
440 horizontally centered, so using @code{\mark \markup @{ \left-align
441 .. @}} has no effect.
442
443 In addition, vertical placement is performed after creating the
444 text markup object.  If you wish to move an entire piece of
445 markup, you need to use the #'padding property or create an
446 @q{anchor} point inside the markup (generally with @code{\hspace
447 #0}).
448
449 @lilypond[quote,verbatim,fragment,relative=1]
450 \textLengthOn
451 c'4^\markup{ \raise #5 "not raised" }
452 \once \override TextScript #'padding = #3
453 c'4^\markup{ raised }
454 c'4^\markup{ \hspace #0 \raise #1.5 raised }
455 @end lilypond
456
457 Some situations (such as dynamic marks) have preset font-related
458 properties.  If you are creating text in such situations, it is
459 advisable to cancel those properties with @code{normal-text}.  See
460 @ref{Text markup commands}, for more details.
461
462 @ignore
463 TODO: here are some commands that could be described here.
464 I'm putting them in bulk, prior to working on this section. -vv
465
466 \simple
467
468 \char
469 \fraction
470
471 \combine
472 \concat
473 \put-adjacent
474
475
476 \page-ref (see also "Table of contents")
477 \fromproperty
478 \verbatim-file
479 \with-url
480
481 \on-the-fly 
482 \override
483
484
485 \null
486 \hspace
487
488 \lower
489 \raise 
490 \translate 
491 \translate-scaled
492 \rotate
493 \transparent
494 \whiteout
495
496 @end ignore
497
498 @seealso
499
500 This manual: @ref{Text markup commands}.
501
502 Snippets:
503 @lsrdir{Text,Text}
504
505 Internals Reference: @internalsref{TextScript}.
506
507 Init files: @file{scm/@/new@/-markup@/.scm}.
508
509
510 @knownissues
511
512 Kerning or generation of ligatures is only done when the @TeX{}
513 backend is used.  In this case, LilyPond does not account for them
514 so texts will be spaced slightly too wide.
515
516 Syntax errors for markup mode are confusing.
517
518 @node Common markup commands
519 @subsubsection Common markup commands
520
521 Some basic formatting can be used blah blah
522
523 \italic 
524 \upright
525 \bold 
526 \medium 
527 \underline
528         
529
530 @c TODO: what's the difference between the following commands? -vv
531 \smallCaps      
532 \caps 
533 \fontCaps
534
535
536 Some alternate font families can easily be selected:
537
538 \sans
539 \typewriter
540 \roman
541 \number (only for numbers, such as fingerings and time signatures)
542 @c TODO: add \slashed-digit here? -vv
543
544 The size can be blah blah blah
545
546 \fontsize
547
548 Some predefined font sizes can be used blah blah
549
550 \teeny
551 \tiny
552 \small  
553 \normalsize
554 \large
555 \huge
556
557 Some shorcuts allow to change the font size relatively to its previous value 
558
559 \smaller
560 \bigger
561 \larger
562
563 \magnify
564
565 Text may be printed as subscript or superscript:
566
567 \sub 
568 \super
569
570 To obtain subscripts or superscripts in a normal text size, use
571 \normal-size-sub
572 \normal-size-super
573
574 All these settings (except the size) can be reverted to the default font:
575
576 \normal-text 
577
578
579 @node Text alignment
580 @subsubsection Text alignment
581
582 Alignment basics:
583 \left-align
584 \center-align
585 \right-align
586
587 Horizontal alignment:
588 \hcenter
589 \general-align
590 \halign 
591
592
593 Vertical alignment: 
594 \vcenter
595 \column 
596 \dir-column 
597
598 Building a "large" markup:
599
600 \line
601
602 \fill-line
603
604 \hcenter-in
605         
606 \pad-around
607 \pad-markup
608 \pad-to-box
609 \pad-x
610         
611 Alignment inside a "large" markup:
612
613 \justify-field 
614 \justify
615 \justify-string
616
617 \wordwrap-field
618 \wordwrap
619 \wordwrap-string
620
621 @node Graphic notation inside markup
622 @subsubsection Graphic notation inside markup
623 Graphics around text:
624 \box
625 \circle
626
627 \bracket
628 \hbracket
629
630 "Standalone" graphics:
631
632 \arrow-head
633 \draw-line
634 \draw-circle
635 \filled-box
636 \triangle
637 \strut
638
639 \with-color
640
641
642 Advanced graphics:
643 \stencil
644
645 \postscript
646 \epsfile
647
648 \with-dimensions
649
650 @node Music notation inside markup
651 @subsubsection Music notation inside markup
652
653 Notes can be printed in markup mode blah blah:
654
655 \note   
656 \note-by-number
657
658 Accidental symbols can be obtained easily:
659
660 \doubleflat
661 \sesquiflat
662 \flat
663 \semiflat
664 \natural
665 \semisharp
666 \sharp
667 \sesquisharp
668 \doublesharp
669
670 Some other notation objects blah blah
671
672 \beam
673 \finger
674 \dynamic
675 \tied-lyric
676 \markalphabet
677 \markletter
678 @c TODO: add \text here? -vv
679
680 Any musical symbol can be printed
681
682 \musicglyph
683 @c TODO: add \lookup here? -vv
684
685
686 The markup mode has support for fret diagrams:
687
688 \fret-diagram 
689 \fret-diagram-terse
690 \fret-diagram-verbose
691
692 An entire @code{\score} block can even be nested in a @code{\markup}
693 block.  In such a case, the @code{\score} must contain a @code{\layout} block.
694
695
696 \score
697
698
699 @lilypond[quote,verbatim,ragged-right]
700 \relative {
701   c4 d^\markup {
702     \score {
703       \relative { c4 d e f }
704       \layout { }
705     }
706   }
707   e f
708 }
709 @end lilypond
710
711 @seealso
712
713 Snippets:
714 @lsrdir{Text,Text}
715
716 @node Multi-page markup
717 @subsubsection Multi-page markup
718
719 Whereas @code{\markup} is used to enter a non-breakable block of
720 text, @code{\markuplines} can be used at top-level to enter lines
721 of text that can spread over multiple pages:
722
723 @verbatim
724 \markuplines {
725   \justified-lines {
726     A very long text of justified lines.
727     ...
728   }
729   \justified-lines {
730     An other very long paragraph.
731     ...
732   }
733   ...
734 }
735 @end verbatim
736
737 @code{\markuplines} accepts a list of markup, that is either the
738 result of a markup list command, or a list of markups or of markup
739 lists.  The built-in markup list commands are described in
740 @ref{Text markup list commands}.
741
742 @seealso
743
744 This manual: @ref{Text markup list commands}, @ref{New
745 markup list command definition}.
746
747 Snippets:
748 @lsrdir{Text,Text}
749
750 @predefined
751
752 @funindex \markuplines
753 @code{\markuplines}
754
755
756
757 @c TODO: move the following subsubsec into NR3 -vv
758 @c maybe.  -gp
759 @node Fonts
760 @subsection Fonts
761
762 @menu
763 * Entire document fonts::       
764 * Single entry fonts::          
765 @end menu
766
767 @node Entire document fonts
768 @subsubsection Entire document fonts
769
770 It is also possible to change the default font family for the
771 entire document.  This is done by calling the
772 @code{make-pango-font-tree} from within the @code{\paper} block.
773 The function takes names for the font families to use for roman,
774 sans serif and monospaced text.  For example,
775
776 @cindex font families, setting
777 @cindex Pango
778
779
780 @lilypond[verbatim]
781 \paper  {
782   myStaffSize = #20
783
784   #(define fonts
785     (make-pango-font-tree "Times New Roman"
786                           "Nimbus Sans"
787                           "Luxi Mono"
788                            (/ myStaffSize 20)))
789 }
790
791 {
792   c'^\markup { roman: foo \sans bla \typewriter bar }
793 }
794 @end lilypond
795
796 @c we don't do Helvetica / Courier, since GS incorrectly loads
797 @c Apple TTF fonts
798
799
800 @node Single entry fonts
801 @subsubsection Single entry fonts
802
803 @cindex font selection
804 @cindex font magnification
805 @funindex font-interface
806
807 By setting the object properties described below, you can select a
808 font from the preconfigured font families.  LilyPond has default
809 support for the feta music fonts.  Text fonts are selected through
810 Pango/FontConfig.  The serif font defaults to New Century
811 Schoolbook, the sans and typewriter to whatever the Pango
812 installation defaults to.
813
814
815 @itemize
816 @item @code{font-encoding}
817 is a symbol that sets layout of the glyphs.  This should only be
818 set to select different types of non-text fonts, e.g.
819
820 @code{fetaBraces} for piano staff braces, @code{fetaMusic} the
821 standard music font, including ancient glyphs, @code{fetaDynamic}
822 for dynamic signs and @code{fetaNumber} for the number font.
823
824 @item @code{font-family}
825 is a symbol indicating the general class of the typeface.
826 Supported are @code{roman} (Computer Modern), @code{sans}, and
827 @code{typewriter}.
828
829 @item @code{font-shape}
830 is a symbol indicating the shape of the font.  There are typically
831 several font shapes available for each font family.  Choices are
832 @code{italic}, @code{caps}, and @code{upright}.
833
834 @item @code{font-series}
835 is a symbol indicating the series of the font.  There are
836 typically several font series for each font family and shape.
837 Choices are @code{medium} and @code{bold}.
838
839 @end itemize
840
841 Fonts selected in the way sketched above come from a predefined
842 style sheet.  If you want to use a font from outside the style
843 sheet, then set the @code{font-name} property,
844
845 @lilypond[fragment,verbatim]
846 {
847   \override Staff.TimeSignature #'font-name = #"Charter"
848   \override Staff.TimeSignature #'font-size = #2
849   \time 3/4
850   c'1_\markup {
851     \override #'(font-name . "Vera Bold")
852       { This text is in Vera Bold }
853   }
854 }
855 @end lilypond
856
857 @noindent
858 Any font can be used, as long as it is available to
859 Pango/FontConfig.  To get a full list of all available fonts, run
860 the command
861
862 @example
863 lilypond -dshow-available-fonts blabla
864 @end example
865
866 (the last argument of the command can be anything, but has to be
867 present).
868
869
870 The size of the font may be set with the @code{font-size}
871 property.  The resulting size is taken relative to the
872 @code{text-font-size} as defined in the @code{\paper} block.
873
874 @cindex font size
875 @cindex font magnification
876
877
878
879
880 @seealso
881
882 Snippets:
883 @lsrdir{Text,Text}
884
885