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