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