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