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