]> git.donarmstrong.com Git - lilypond.git/blob - scm/define-markup-commands.scm
*** empty log message ***
[lilypond.git] / scm / define-markup-commands.scm
1 ;;;; define-markup-commands.scm -- markup commands
2 ;;;;
3 ;;;;  source file of the GNU LilyPond music typesetter
4 ;;;; 
5 ;;;; (c)  2000--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
7
8 ;;; markup commands
9 ;;;  * each markup function should have a doc string with
10 ;;     syntax, description and example. 
11
12 (define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
13 (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
14
15 (def-markup-command (stencil layout props stil) (ly:stencil?)
16   "Stencil as markup"
17   stil)
18
19 (def-markup-command (score layout props score) (ly:score?)
20   "Inline an image of music."
21   (let* ((systems (ly:score-embedded-format score layout)))
22
23     (if (= 0 (vector-length systems))
24         (begin
25           (ly:warn "No systems found in \\score markup. Did you forget \\layout?")
26           empty-markup)
27         (begin
28           (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0)))) 
29
30             (ly:stencil-align-to! stencil Y CENTER)
31             stencil)))))
32
33 (def-markup-command (simple layout props str) (string?)
34   "A simple text string; @code{\\markup @{ foo @}} is equivalent with
35 @code{\\markup @{ \\simple #\"foo\" @}}."
36   (interpret-markup layout props str))
37
38 (def-markup-command (encoded-simple layout props sym str) (symbol? string?)
39   "A text string, encoded with encoding @var{sym}. See
40 @usermanref{Text encoding} for more information."
41   (Text_interface::interpret_string layout
42                                     props sym str))
43
44
45 ;; TODO: use font recoding.
46 ;;                    (make-line-markup
47 ;;                     (map make-word-markup (string-tokenize str)))))
48
49 (define-public empty-markup
50   (make-simple-markup ""))
51
52
53 (def-markup-command (postscript layout props str) (string?)
54   "This inserts @var{str} directly into the output as a PostScript
55 command string.  Due to technicalities of the output backends,
56 different scales should be used for the @TeX{} and PostScript backend,
57 selected with @code{-f}. 
58
59
60 For the TeX backend, the following string prints a rotated text
61
62 @cindex rotated text
63
64 @verbatim
65 0 0 moveto /ecrm10 findfont 
66 1.75 scalefont setfont 90 rotate (hello) show
67 @end verbatim
68
69 @noindent
70 The magical constant 1.75 scales from LilyPond units (staff spaces) to
71 TeX dimensions.
72
73 For the postscript backend, use the following
74
75 @verbatim
76 gsave /ecrm10 findfont 
77  10.0 output-scale div 
78  scalefont setfont 90 rotate (hello) show grestore 
79 @end verbatim
80 "
81   ;; FIXME
82   (ly:make-stencil
83    (list 'embedded-ps str)
84    '(0 . 0) '(0 . 0)))
85
86 ;;(def-markup-command (fill-line layout props line-width markups)
87 ;;  (number? markup-list?)
88 ;; no parser tag -- should make number? markuk-list? thingy
89 (def-markup-command (fill-line layout props markups)
90   (markup-list?)
91   "Put @var{markups} in a horizontal line of width @var{line-width}.
92    The markups are spaced/flushed to fill the entire line.
93    If there are no arguments, return an empty stencil.
94 "
95   (let* ((orig-stencils
96           (map (lambda (x) (interpret-markup layout props x))
97                markups))
98          (stencils
99           (map (lambda (stc)
100                  (if (ly:stencil-empty? stc)
101                      point-stencil
102                      stc)) orig-stencils))
103          (text-width (apply +
104                             (map (lambda (stc)
105                                    (if (ly:stencil-empty? stc)
106                                        0.0
107                                        (interval-length (ly:stencil-extent stc X))))
108                                  stencils)))
109          (word-count (length stencils))
110          (word-space (chain-assoc-get 'word-space props))
111          (line-width (chain-assoc-get 'linewidth props))
112          (fill-space (if (< line-width text-width)
113                          word-space
114                          (/ (- line-width text-width)
115                             (if (= word-count 1) 2 (- word-count 1)))))
116          (line-stencils (if (= word-count 1)
117                             (list
118                              point-stencil
119                              (car stencils)
120                              point-stencil)
121                             stencils)))
122
123     (if (null? (remove ly:stencil-empty? orig-stencils))
124         empty-stencil
125         (stack-stencils X RIGHT fill-space line-stencils))))
126
127 (define (font-markup qualifier value)
128   (lambda (layout props arg)
129     (interpret-markup layout
130                       (prepend-alist-chain qualifier value props)
131                       arg)))
132
133
134 (def-markup-command (line layout props args) (markup-list?)
135   "Put @var{args} in a horizontal line.  The property @code{word-space}
136 determines the space between each markup in @var{args}."
137   (stack-stencil-line
138    (chain-assoc-get 'word-space props)
139    (map (lambda (m) (interpret-markup layout props m)) args)))
140
141 (def-markup-command (fromproperty layout props symbol) (symbol?)
142   "Read the @var{symbol} from property settings, and produce a stencil
143   from the markup contained within. If @var{symbol} is not defined, it
144   returns an empty markup"
145   (let* ((m (chain-assoc-get symbol props)))
146     (if (markup? m)
147         (interpret-markup layout props m)
148         (ly:make-stencil '()  '(1 . -1) '(1 . -1)))))
149
150
151 (def-markup-command (on-the-fly layout props procedure arg) (symbol? markup?)
152   "Apply the @var{procedure} markup command to
153 @var{arg}. @var{procedure} should take a single argument."
154   (let* ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
155     (set-object-property! anonymous-with-signature
156                           'markup-signature
157                           (list markup?))
158     (interpret-markup layout props (list anonymous-with-signature arg))))
159
160
161 (def-markup-command (combine layout props m1 m2) (markup? markup?)
162   "Print two markups on top of each other."
163   (let* ((s1 (interpret-markup layout props m1))
164          (s2 (interpret-markup layout props m2)))
165     (ly:stencil-add s1 s2)))
166
167 (def-markup-command (finger layout props arg) (markup?)
168   "Set the argument as small numbers."
169   (interpret-markup layout
170                     (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
171                     arg))
172
173 (def-markup-command (fontsize layout props mag arg) (number? markup?)
174   "This sets the relative font size, e.g.
175 @example
176 A \\fontsize #2 @{ B C @} D
177 @end example
178
179
180 This will enlarge the B and the C by two steps.
181 "
182   (interpret-markup
183    layout 
184    (prepend-alist-chain 'font-size mag props)
185    arg))
186
187 (def-markup-command (magnify layout props sz arg) (number? markup?)
188   "This sets the font magnification for the its argument. In the following
189 example, the middle A will be 10% larger:
190 @example
191 A \\magnify #1.1 @{ A @} A
192 @end example
193
194 Note: magnification only works if a font-name is explicitly selected.
195 Use @code{\\fontsize} otherwise."
196   (interpret-markup
197    layout 
198    (prepend-alist-chain 'font-magnification sz props)
199    arg))
200
201 (def-markup-command (bold layout props arg) (markup?)
202   "Switch to bold font-series"
203   (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
204
205 (def-markup-command (sans layout props arg) (markup?)
206   "Switch to the sans serif family"
207   (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
208
209 (def-markup-command (number layout props arg) (markup?)
210   "Set font family to @code{number}, which yields the font used for
211 time signatures and fingerings.  This font only contains numbers and
212 some punctuation. It doesn't have any letters.  "
213   (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
214
215 (def-markup-command (roman layout props arg) (markup?)
216   "Set font family to @code{roman}."
217   (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
218
219 (def-markup-command (huge layout props arg) (markup?)
220   "Set font size to +2."
221   (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
222
223 (def-markup-command (large layout props arg) (markup?)
224   "Set font size to +1."
225   (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
226
227 (def-markup-command (normalsize layout props arg) (markup?)
228   "Set font size to default."
229   (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
230
231 (def-markup-command (small layout props arg) (markup?)
232   "Set font size to -1."
233   (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
234
235 (def-markup-command (tiny layout props arg) (markup?)
236   "Set font size to -2."
237   (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
238
239 (def-markup-command (teeny layout props arg) (markup?)
240   "Set font size to -3."
241   (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
242
243 (def-markup-command (caps layout props arg) (markup?)
244   "Set @code{font-shape} to @code{caps}."
245   (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
246
247 ;(def-markup-command (latin-i layout props arg) (markup?)
248 ;  "TEST latin1 encoding."
249 ;  (interpret-markup layout (prepend-alist-chain 'font-shape 'latin1 props) arg))
250
251 (def-markup-command (dynamic layout props arg) (markup?)
252   "Use the dynamic font.  This font only contains @b{s}, @b{f}, @b{m},
253 @b{z}, @b{p}, and @b{r}.  When producing phrases, like ``pi@`{u} @b{f}'', the
254 normal words (like ``pi@`{u}'') should be done in a different font.  The
255 recommend font for this is bold and italic"
256   (interpret-markup
257    layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
258
259 (def-markup-command (italic layout props arg) (markup?)
260   "Use italic @code{font-shape} for @var{arg}. "
261   (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
262
263 (def-markup-command (typewriter layout props arg) (markup?)
264   "Use @code{font-family} typewriter for @var{arg}."
265   (interpret-markup
266    layout (prepend-alist-chain 'font-family 'typewriter props) arg))
267
268 (def-markup-command (upright layout props arg) (markup?)
269   "Set font shape to @code{upright}."
270   (interpret-markup
271    layout (prepend-alist-chain 'font-shape 'upright props) arg))
272
273 (def-markup-command (doublesharp layout props) ()
274   "Draw a double sharp symbol."
275
276   (interpret-markup layout props (markup #:musicglyph "accidentals.4")))
277 (def-markup-command (sesquisharp layout props) ()
278   "Draw a 3/2 sharp symbol."
279   (interpret-markup layout props (markup #:musicglyph "accidentals.3")))
280
281 (def-markup-command (sharp layout props) ()
282   "Draw a sharp symbol."
283   (interpret-markup layout props (markup #:musicglyph "accidentals.2")))
284
285 (def-markup-command (semisharp layout props) ()
286   "Draw a semi sharp symbol."
287   (interpret-markup layout props (markup #:musicglyph "accidentals.1")))
288
289 (def-markup-command (natural layout props) ()
290   "Draw a natural symbol."
291   (interpret-markup layout props (markup #:musicglyph "accidentals.0")))
292
293 (def-markup-command (semiflat layout props) ()
294   "Draw a semiflat."
295   (interpret-markup layout props (markup #:musicglyph "accidentals.M1")))
296
297 (def-markup-command (flat layout props) ()
298   "Draw a flat symbol."
299   (interpret-markup layout props (markup #:musicglyph "accidentals.M2")))
300
301 (def-markup-command (sesquiflat layout props) ()
302   "Draw a 3/2 flat symbol."
303   (interpret-markup layout props (markup #:musicglyph "accidentals.M3")))
304
305 (def-markup-command (doubleflat layout props) ()
306   "Draw a double flat symbol."
307   (interpret-markup layout props (markup #:musicglyph "accidentals.M4")))
308
309 (def-markup-command (column layout props args) (markup-list?)
310   "Stack the markups in @var{args} vertically.  The property
311 @code{baseline-skip} determines the space between each markup in @var{args}."
312   (stack-lines
313    -1 0.0 (chain-assoc-get 'baseline-skip props)
314    (remove ly:stencil-empty?
315            (map (lambda (m) (interpret-markup layout props m)) args))))
316
317 (def-markup-command (dir-column layout props args) (markup-list?)
318   "Make a column of args, going up or down, depending on the setting
319 of the @code{#'direction} layout property."
320   (let* ((dir (chain-assoc-get 'direction props)))
321     (stack-lines
322      (if (number? dir) dir -1)
323      0.0
324      (chain-assoc-get 'baseline-skip props)
325      (map (lambda (x) (interpret-markup layout props x)) args))))
326
327 (def-markup-command (center-align layout props args) (markup-list?)
328   "Put @code{args} in a centered column. "
329   (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
330          (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
331     (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
332
333 (def-markup-command (vcenter layout props arg) (markup?)
334   "Align @code{arg} to its center. "
335   (let* ((mol (interpret-markup layout props arg)))
336     (ly:stencil-align-to! mol Y CENTER)
337     mol))
338
339 (def-markup-command (right-align layout props arg) (markup?)
340   "Align @var{arg} on its right edge. "
341   (let* ((m (interpret-markup layout props arg)))
342     (ly:stencil-align-to! m X RIGHT)
343     m))
344
345 (def-markup-command (left-align layout props arg) (markup?)
346   "Align @var{arg} on its left edge. "
347   (let* ((m (interpret-markup layout props arg)))
348     (ly:stencil-align-to! m X LEFT)
349     m))
350
351 (def-markup-command (general-align layout props axis dir arg)  (integer? number? markup?)
352   "Align @var{arg} in @var{axis} direction to the @var{dir} side."
353   (let* ((m (interpret-markup layout props arg)))
354     (ly:stencil-align-to! m axis dir)
355     m))
356
357 (def-markup-command (halign layout props dir arg) (number? markup?)
358   "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
359 left-aligned, while @code{+1} is right. Values in between interpolate
360 alignment accordingly."
361   (let* ((m (interpret-markup layout props arg)))
362     (ly:stencil-align-to! m X dir)
363     m))
364
365 (def-markup-command (musicglyph layout props glyph-name) (string?)
366   "This is converted to a musical symbol, e.g. @code{\\musicglyph
367 #\"accidentals-0\"} will select the natural sign from the music font.
368 See @usermanref{The Feta font} for  a complete listing of the possible glyphs."
369   (ly:font-get-glyph
370    (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
371                                    props))
372    glyph-name))
373
374 (def-markup-command (lookup layout props glyph-name) (string?)
375   "Lookup a glyph by name."
376   (ly:font-get-glyph (ly:paper-get-font layout props)
377                      glyph-name))
378
379 (def-markup-command (char layout props num) (integer?)
380   "Produce a single character, e.g. @code{\\char #65} produces the 
381 letter 'A'."
382   (ly:get-glyph (ly:paper-get-font layout props) num))
383
384 (def-markup-command (raise layout props amount arg) (number? markup?)
385   "
386 This  raises  @var{arg}, by the distance @var{amount}.
387 A negative @var{amount} indicates lowering:
388 @c
389 @lilypond[verbatim,fragment,relative=1]
390  c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
391 @end lilypond
392 The argument to @code{\\raise} is the vertical displacement amount,
393 measured in (global) staff spaces.  @code{\\raise} and @code{\\super}
394 raise objects in relation to their surrounding markups.
395
396 If the text object itself is positioned above or below the staff, then
397 @code{\\raise} cannot be used to move it, since the mechanism that
398 positions it next to the staff cancels any shift made with
399 @code{\\raise}. For vertical positioning, use the @code{padding}
400 and/or @code{extra-offset} properties. "
401   (ly:stencil-translate-axis (interpret-markup layout props arg)
402                              amount Y))
403
404 (def-markup-command (fraction layout props arg1 arg2) (markup? markup?)
405   "Make a fraction of two markups."
406   (let* ((m1 (interpret-markup layout props arg1))
407          (m2 (interpret-markup layout props arg2)))
408     (ly:stencil-align-to! m1 X CENTER)
409     (ly:stencil-align-to! m2 X CENTER)    
410     (let* ((x1 (ly:stencil-extent m1 X))
411            (x2 (ly:stencil-extent m2 X))
412            (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
413            ;; should stack mols separately, to maintain LINE on baseline
414            (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
415       (ly:stencil-align-to! stack Y CENTER)
416       (ly:stencil-align-to! stack X LEFT)
417       ;; should have EX dimension
418       ;; empirical anyway
419       (ly:stencil-translate-axis stack 0.75 Y))))
420
421
422 ;; TODO: better syntax.
423
424 (def-markup-command (note-by-number layout props log dot-count dir) (number? number? number?)
425   "Construct a note symbol, with stem.  By using fractional values for
426 @var{dir}, you can obtain longer or shorter stems."
427   (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
428          (size (chain-assoc-get 'font-size props 0))
429          (stem-length (* (magstep size) (max 3 (- log 1))))
430          (head-glyph (ly:font-get-glyph
431                       font
432                       (string-append "noteheads.s" (number->string (min log 2)))))
433          (stem-thickness 0.13)
434          (stemy (* dir stem-length))
435          (attachx (if (> dir 0)
436                       (- (cdr (ly:stencil-extent head-glyph X)) stem-thickness)
437                       0))
438          (attachy (* dir 0.28))
439          (stem-glyph (and (> log 0)
440                           (ly:round-filled-box
441                            (cons attachx (+ attachx  stem-thickness))
442                            (cons (min stemy attachy)
443                                  (max stemy attachy))
444                            (/ stem-thickness 3))))
445          (dot (ly:font-get-glyph font "dots-dot"))
446          (dotwid (interval-length (ly:stencil-extent dot X)))
447          (dots (and (> dot-count 0)
448                     (apply ly:stencil-add
449                            (map (lambda (x)
450                                   (ly:stencil-translate-axis
451                                    dot  (* (+ 1 (* 2 x)) dotwid) X))
452                                 (iota dot-count 1)))))
453          (flaggl (and (> log 2)
454                       (ly:stencil-translate
455                        (ly:font-get-glyph font
456                                           (string-append "flags."
457                                                          (if (> dir 0) "u" "d")
458                                                          (number->string log)))
459                        (cons (+ attachx (/ stem-thickness 2)) stemy)))))
460     (if flaggl
461         (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
462     (if (ly:stencil? stem-glyph)
463         (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
464         (set! stem-glyph head-glyph))
465     (if (ly:stencil? dots)
466         (set! stem-glyph
467               (ly:stencil-add
468                (ly:stencil-translate-axis dots
469                                           (+ (if (and (> dir 0) (> log 2))
470                                                  (* 1.5 dotwid)
471                                                  0)
472                                              ;; huh ? why not necessary?
473                                              ;;(cdr (ly:stencil-extent head-glyph X))
474                                              dotwid)
475                                           X)
476                stem-glyph)))
477     stem-glyph))
478
479 (use-modules (ice-9 regex))
480
481 (define-public log2 
482   (let ((divisor (log 2)))
483     (lambda (z) (inexact->exact (/ (log z) divisor)))))
484
485 (define (parse-simple-duration duration-string)
486   "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
487   (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
488     (if (and match (string=? duration-string (match:substring match 0)))
489         (let ((len  (match:substring match 1))
490               (dots (match:substring match 2)))
491           (list (cond ((string=? len "breve")  -1)
492                       ((string=? len "longa")  -2)
493                       ((string=? len "maxima") -3)
494                       (else (log2 (string->number len))))
495                 (if dots (string-length dots) 0)))
496         (error "This is not a valid duration string:" duration-string))))
497
498 (def-markup-command (note layout props duration dir) (string? number?)
499   "This produces a note with a stem pointing in @var{dir} direction, with
500 the @var{duration} for the note head type and augmentation dots. For
501 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
502 a shortened down stem."
503   (let ((parsed (parse-simple-duration duration)))
504     (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
505
506 (def-markup-command (normal-size-super layout props arg) (markup?)
507   "Set @var{arg} in superscript with a normal font size."
508   (ly:stencil-translate-axis (interpret-markup
509                               layout
510                               props arg)
511                              (* 0.5  (chain-assoc-get 'baseline-skip props))
512                              Y))
513
514 (def-markup-command (super layout props arg) (markup?)
515   "
516 @cindex raising text
517 @cindex lowering text
518 @cindex moving text
519 @cindex translating text
520
521 @cindex @code{\\super}
522
523
524 Raising and lowering texts can be done with @code{\\super} and
525 @code{\\sub}:
526
527 @lilypond[verbatim,fragment,relative=1]
528  c1^\\markup { E \"=\" mc \\super \"2\" }
529 @end lilypond
530
531 "
532   (ly:stencil-translate-axis
533    (interpret-markup
534     layout
535     (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
536     arg)
537    (* 0.5 (chain-assoc-get 'baseline-skip props))
538    Y))
539
540 (def-markup-command (translate layout props offset arg) (number-pair? markup?)
541   "This translates an object. Its first argument is a cons of numbers
542 @example
543 A \\translate #(cons 2 -3) @{ B C @} D
544 @end example
545 This moves `B C' 2 spaces to the right, and 3 down, relative to its
546 surroundings. This command cannot be used to move isolated scripts
547 vertically, for the same reason that @code{\\raise} cannot be used for
548 that.
549
550 "
551   (ly:stencil-translate (interpret-markup  layout props arg)
552                         offset))
553
554 (def-markup-command (sub layout props arg) (markup?)
555   "Set @var{arg} in subscript."
556   (ly:stencil-translate-axis
557    (interpret-markup
558     layout
559     (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
560     arg)
561    (* -0.5 (chain-assoc-get 'baseline-skip props))
562    Y))
563
564 (def-markup-command (normal-size-sub layout props arg) (markup?)
565   "Set @var{arg} in subscript, in a normal font size."
566   (ly:stencil-translate-axis
567    (interpret-markup layout props arg)
568    (* -0.5 (chain-assoc-get 'baseline-skip props))
569    Y))
570
571 (def-markup-command (hbracket layout props arg) (markup?)
572   "Draw horizontal brackets around @var{arg}."  
573   (let ((th 0.1) ;; todo: take from GROB.
574         (m (interpret-markup layout props arg)))
575     (bracketify-stencil m X th (* 2.5 th) th)))
576
577 (def-markup-command (bracket layout props arg) (markup?)
578   "Draw vertical brackets around @var{arg}."  
579   (let ((th 0.1) ;; todo: take from GROB.
580         (m (interpret-markup layout props arg)))
581     (bracketify-stencil m Y th (* 2.5 th) th)))
582
583 ;; todo: fix negative space
584 (def-markup-command (hspace layout props amount) (number?)
585   "This produces a invisible object taking horizontal space.
586 @example 
587 \\markup @{ A \\hspace #2.0 B @} 
588 @end example
589 will put extra space between A and B, on top of the space that is
590 normally inserted before elements on a line.
591 "
592   (if (> amount 0)
593       (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
594       (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
595
596 (def-markup-command (override layout props new-prop arg) (pair? markup?)
597   "Add the first argument in to the property list.  Properties may be
598 any sort of property supported by @internalsref{font-interface} and
599 @internalsref{text-interface}, for example
600
601 @verbatim
602 \\override #'(font-family . married) \"bla\"
603 @end verbatim
604
605 "
606   (interpret-markup layout (cons (list new-prop) props) arg))
607
608 (def-markup-command (smaller layout props arg) (markup?)
609   "Decrease the font size relative to current setting"
610   (let* ((fs (chain-assoc-get 'font-size props 0))
611          (entry (cons 'font-size (- fs 1))))
612     (interpret-markup layout (cons (list entry) props) arg)))
613
614 (def-markup-command (bigger layout props arg) (markup?)
615   "Increase the font size relative to current setting"
616   (let* ((fs (chain-assoc-get 'font-size props 0))
617          (entry (cons 'font-size (+ fs 1))))
618     (interpret-markup layout (cons (list entry) props) arg)))
619
620 (def-markup-command larger (markup?)
621   "Increase the font size relative to current setting"
622   bigger-markup)
623
624 (def-markup-command (box layout props arg) (markup?)
625   "Draw a box round @var{arg}.  Looks at @code{thickness} and
626 @code{box-padding} properties to determine line thickness and padding
627 around the markup."
628   (let ((th (chain-assoc-get 'thickness props  0.1))
629         (pad (chain-assoc-get 'box-padding props 0.2))
630         (m (interpret-markup layout props arg)))
631     (box-stencil m th pad)))
632
633 ;;FIXME: is this working? 
634 (def-markup-command (strut layout props) ()
635   "Create a box of the same height as the space in the current font."
636   (let ((m (Text_interface::interpret_markup layout props " ")))
637     (ly:stencil-set-extent! m X '(1000 . -1000))
638     m))
639
640 (define number->mark-letter-vector (make-vector 25 #\A))
641
642 (do ((i 0 (1+ i))
643      (j 0 (1+ j)))
644     ((>= i 26))
645   (if (= i (- (char->integer #\I) (char->integer #\A)))
646       (set! i (1+ i)))
647   (vector-set! number->mark-letter-vector j
648                (integer->char (+ i (char->integer #\A)))))
649
650 (define number->mark-alphabet-vector (list->vector
651   (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
652
653 (define (number->markletter-string vec n)
654   "Double letters for big marks."
655   (let* ((lst (vector-length vec)))
656     
657     (if (>= n lst)
658         (string-append (number->markletter-string vec (1- (quotient n lst)))
659                        (number->markletter-string vec (remainder n lst)))
660         (make-string 1 (vector-ref vec n)))))
661
662 (def-markup-command (markletter layout props num) (integer?)
663   "Make a markup letter for @var{num}.  The letters start with A to Z
664  (skipping I), and continues with double letters."
665   (Text_interface::interpret_markup layout props
666     (number->markletter-string number->mark-letter-vector num)))
667
668 (def-markup-command (markalphabet layout props num) (integer?)
669    "Make a markup letter for @var{num}.  The letters start with A to Z
670  and continues with double letters."
671    (Text_interface::interpret_markup layout props
672      (number->markletter-string number->mark-alphabet-vector num)))
673
674 (def-markup-command (bracketed-y-column layout props indices args)
675   (list? markup-list?)
676   "Make a column of the markups in @var{args}, putting brackets around
677 the elements marked in @var{indices}, which is a list of numbers."
678   (define (sublist lst start stop)
679     (take (drop lst start) (- (1+ stop) start)))
680
681   (define (stencil-list-extent ss axis)
682     (cons
683      (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
684      (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
685   
686   (define (stack-stencils stencils bskip last-stencil)
687     (cond
688      ((null? stencils) '())
689      ((not last-stencil)
690       (cons (car stencils)
691             (stack-stencils (cdr stencils) bskip (car stencils))))
692      (else
693       (let* ((orig (car stencils))
694              (dir (chain-assoc-get 'direction  props DOWN))
695              (new (ly:stencil-moved-to-edge last-stencil Y dir
696                                             orig
697                                             0.1 bskip)))
698
699         (cons new (stack-stencils (cdr stencils) bskip new))))))
700
701   (define (make-brackets stencils indices acc)
702     (if (and stencils
703              (pair? indices)
704              (pair? (cdr indices)))
705         (let* ((encl (sublist stencils (car indices) (cadr indices)))
706                (x-ext (stencil-list-extent encl X))
707                (y-ext (stencil-list-extent encl Y))
708                (thick 0.10)
709                (pad 0.35)
710                (protusion (* 2.5 thick))
711                (lb
712                 (ly:stencil-translate-axis 
713                  (ly:bracket Y y-ext thick protusion)
714                  (- (car x-ext) pad) X))
715                (rb (ly:stencil-translate-axis
716                     (ly:bracket Y y-ext thick (- protusion))
717                     (+ (cdr x-ext) pad) X)))
718
719           (make-brackets
720            stencils (cddr indices)
721            (append
722             (list lb rb)
723             acc)))
724         acc))
725
726   (let* ((stencils
727           (map (lambda (x)
728                  (interpret-markup
729                   layout
730                   props
731                   x)) args))
732          (leading
733           (chain-assoc-get 'baseline-skip props))
734          (stacked (stack-stencils stencils 1.25 #f))
735          (brackets (make-brackets stacked indices '())))
736
737     (apply ly:stencil-add
738            (append stacked brackets))))