1 ;;;; define-markup-commands.scm -- markup commands
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 ;;; * each markup function should have a doc string with
10 ;; syntax, description and example.
12 (define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
13 (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
15 (def-markup-command (stencil layout props stil) (ly:stencil?)
19 (def-markup-command (score layout props score) (ly:score?)
20 "Inline an image of music."
21 (let* ((systems (ly:score-embedded-format score layout)))
23 (if (= 0 (vector-length systems))
25 (ly:warn "No systems found in \\score markup. Did you forget \\layout?")
28 (let* ((stencil (ly:paper-system-stencil (vector-ref systems 0))))
30 (ly:stencil-align-to! stencil Y CENTER)
33 (def-markup-command (simple layout props str) (string?)
34 "A simple text string; @code{\\markup @{ foo @}} is equivalent with
35 @code{\\markup @{ \\simple #\"foo\" @}}."
36 (interpret-markup layout props str))
38 (def-markup-command (encoded-simple layout props sym str) (symbol? string?)
39 "A text string, encoded with encoding @var{sym}. See
40 @usermanref{Text encoding} for more information."
41 (Text_interface::interpret_string layout
45 ;; TODO: use font recoding.
47 ;; (map make-word-markup (string-tokenize str)))))
49 (define-public empty-markup
50 (make-simple-markup ""))
53 (def-markup-command (postscript layout props str) (string?)
54 "This inserts @var{str} directly into the output as a PostScript
55 command string. Due to technicalities of the output backends,
56 different scales should be used for the @TeX{} and PostScript backend,
57 selected with @code{-f}.
60 For the TeX backend, the following string prints a rotated text
65 0 0 moveto /ecrm10 findfont
66 1.75 scalefont setfont 90 rotate (hello) show
70 The magical constant 1.75 scales from LilyPond units (staff spaces) to
73 For the postscript backend, use the following
76 gsave /ecrm10 findfont
78 scalefont setfont 90 rotate (hello) show grestore
83 (list 'embedded-ps str)
86 ;;(def-markup-command (fill-line layout props line-width markups)
87 ;; (number? markup-list?)
88 ;; no parser tag -- should make number? markuk-list? thingy
89 (def-markup-command (fill-line layout props markups)
91 "Put @var{markups} in a horizontal line of width @var{line-width}.
92 The markups are spaced/flushed to fill the entire line.
93 If there are no arguments, return an empty stencil.
96 (map (lambda (x) (interpret-markup layout props x))
100 (if (ly:stencil-empty? stc)
102 stc)) orig-stencils))
105 (if (ly:stencil-empty? stc)
107 (interval-length (ly:stencil-extent stc X))))
109 (word-count (length stencils))
110 (word-space (chain-assoc-get 'word-space props))
111 (line-width (chain-assoc-get 'linewidth props))
112 (fill-space (if (< line-width text-width)
114 (/ (- line-width text-width)
115 (if (= word-count 1) 2 (- word-count 1)))))
116 (line-stencils (if (= word-count 1)
123 (if (null? (remove ly:stencil-empty? orig-stencils))
125 (stack-stencils X RIGHT fill-space line-stencils))))
127 (define (font-markup qualifier value)
128 (lambda (layout props arg)
129 (interpret-markup layout
130 (prepend-alist-chain qualifier value props)
134 (def-markup-command (line layout props args) (markup-list?)
135 "Put @var{args} in a horizontal line. The property @code{word-space}
136 determines the space between each markup in @var{args}."
138 (chain-assoc-get 'word-space props)
139 (remove ly:stencil-empty?
140 (map (lambda (m) (interpret-markup layout props m)) args))))
142 (def-markup-command (fromproperty layout props symbol) (symbol?)
143 "Read the @var{symbol} from property settings, and produce a stencil
144 from the markup contained within. If @var{symbol} is not defined, it
145 returns an empty markup"
146 (let* ((m (chain-assoc-get symbol props)))
148 (interpret-markup layout props m)
149 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
152 (def-markup-command (on-the-fly layout props procedure arg) (symbol? markup?)
153 "Apply the @var{procedure} markup command to
154 @var{arg}. @var{procedure} should take a single argument."
155 (let* ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
156 (set-object-property! anonymous-with-signature
159 (interpret-markup layout props (list anonymous-with-signature arg))))
162 (def-markup-command (combine layout props m1 m2) (markup? markup?)
163 "Print two markups on top of each other."
164 (let* ((s1 (interpret-markup layout props m1))
165 (s2 (interpret-markup layout props m2)))
166 (ly:stencil-add s1 s2)))
168 (def-markup-command (finger layout props arg) (markup?)
169 "Set the argument as small numbers."
170 (interpret-markup layout
171 (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
174 (def-markup-command (fontsize layout props mag arg) (number? markup?)
175 "This sets the relative font size, e.g.
177 A \\fontsize #2 @{ B C @} D
181 This will enlarge the B and the C by two steps.
185 (prepend-alist-chain 'font-size mag props)
188 (def-markup-command (magnify layout props sz arg) (number? markup?)
189 "This sets the font magnification for the its argument. In the following
190 example, the middle A will be 10% larger:
192 A \\magnify #1.1 @{ A @} A
195 Note: magnification only works if a font-name is explicitly selected.
196 Use @code{\\fontsize} otherwise."
199 (prepend-alist-chain 'font-magnification sz props)
202 (def-markup-command (bold layout props arg) (markup?)
203 "Switch to bold font-series"
204 (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
206 (def-markup-command (sans layout props arg) (markup?)
207 "Switch to the sans serif family"
208 (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
210 (def-markup-command (number layout props arg) (markup?)
211 "Set font family to @code{number}, which yields the font used for
212 time signatures and fingerings. This font only contains numbers and
213 some punctuation. It doesn't have any letters. "
214 (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
216 (def-markup-command (roman layout props arg) (markup?)
217 "Set font family to @code{roman}."
218 (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
220 (def-markup-command (huge layout props arg) (markup?)
221 "Set font size to +2."
222 (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
224 (def-markup-command (large layout props arg) (markup?)
225 "Set font size to +1."
226 (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
228 (def-markup-command (normalsize layout props arg) (markup?)
229 "Set font size to default."
230 (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
232 (def-markup-command (small layout props arg) (markup?)
233 "Set font size to -1."
234 (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
236 (def-markup-command (tiny layout props arg) (markup?)
237 "Set font size to -2."
238 (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
240 (def-markup-command (teeny layout props arg) (markup?)
241 "Set font size to -3."
242 (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
244 (def-markup-command (caps layout props arg) (markup?)
245 "Set @code{font-shape} to @code{caps}."
246 (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
248 ;(def-markup-command (latin-i layout props arg) (markup?)
249 ; "TEST latin1 encoding."
250 ; (interpret-markup layout (prepend-alist-chain 'font-shape 'latin1 props) arg))
252 (def-markup-command (dynamic layout props arg) (markup?)
253 "Use the dynamic font. This font only contains @b{s}, @b{f}, @b{m},
254 @b{z}, @b{p}, and @b{r}. When producing phrases, like ``pi@`{u} @b{f}'', the
255 normal words (like ``pi@`{u}'') should be done in a different font. The
256 recommend font for this is bold and italic"
258 layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
260 (def-markup-command (italic layout props arg) (markup?)
261 "Use italic @code{font-shape} for @var{arg}. "
262 (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
264 (def-markup-command (typewriter layout props arg) (markup?)
265 "Use @code{font-family} typewriter for @var{arg}."
267 layout (prepend-alist-chain 'font-family 'typewriter props) arg))
269 (def-markup-command (upright layout props arg) (markup?)
270 "Set font shape to @code{upright}."
272 layout (prepend-alist-chain 'font-shape 'upright props) arg))
274 (def-markup-command (doublesharp layout props) ()
275 "Draw a double sharp symbol."
277 (interpret-markup layout props (markup #:musicglyph "accidentals.4")))
278 (def-markup-command (sesquisharp layout props) ()
279 "Draw a 3/2 sharp symbol."
280 (interpret-markup layout props (markup #:musicglyph "accidentals.3")))
282 (def-markup-command (sharp layout props) ()
283 "Draw a sharp symbol."
284 (interpret-markup layout props (markup #:musicglyph "accidentals.2")))
286 (def-markup-command (semisharp layout props) ()
287 "Draw a semi sharp symbol."
288 (interpret-markup layout props (markup #:musicglyph "accidentals.1")))
290 (def-markup-command (natural layout props) ()
291 "Draw a natural symbol."
292 (interpret-markup layout props (markup #:musicglyph "accidentals.0")))
294 (def-markup-command (semiflat layout props) ()
296 (interpret-markup layout props (markup #:musicglyph "accidentals.M1")))
298 (def-markup-command (flat layout props) ()
299 "Draw a flat symbol."
300 (interpret-markup layout props (markup #:musicglyph "accidentals.M2")))
302 (def-markup-command (sesquiflat layout props) ()
303 "Draw a 3/2 flat symbol."
304 (interpret-markup layout props (markup #:musicglyph "accidentals.M3")))
306 (def-markup-command (doubleflat layout props) ()
307 "Draw a double flat symbol."
308 (interpret-markup layout props (markup #:musicglyph "accidentals.M4")))
310 (def-markup-command (column layout props args) (markup-list?)
311 "Stack the markups in @var{args} vertically. The property
312 @code{baseline-skip} determines the space between each markup in @var{args}."
314 -1 0.0 (chain-assoc-get 'baseline-skip props)
315 (remove ly:stencil-empty?
316 (map (lambda (m) (interpret-markup layout props m)) args))))
318 (def-markup-command (dir-column layout props args) (markup-list?)
319 "Make a column of args, going up or down, depending on the setting
320 of the @code{#'direction} layout property."
321 (let* ((dir (chain-assoc-get 'direction props)))
323 (if (number? dir) dir -1)
325 (chain-assoc-get 'baseline-skip props)
326 (map (lambda (x) (interpret-markup layout props x)) args))))
328 (def-markup-command (center-align layout props args) (markup-list?)
329 "Put @code{args} in a centered column. "
330 (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
331 (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
332 (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
334 (def-markup-command (vcenter layout props arg) (markup?)
335 "Align @code{arg} to its center. "
336 (let* ((mol (interpret-markup layout props arg)))
337 (ly:stencil-align-to! mol Y CENTER)
340 (def-markup-command (right-align layout props arg) (markup?)
341 "Align @var{arg} on its right edge. "
342 (let* ((m (interpret-markup layout props arg)))
343 (ly:stencil-align-to! m X RIGHT)
346 (def-markup-command (left-align layout props arg) (markup?)
347 "Align @var{arg} on its left edge. "
348 (let* ((m (interpret-markup layout props arg)))
349 (ly:stencil-align-to! m X LEFT)
352 (def-markup-command (general-align layout props axis dir arg) (integer? number? markup?)
353 "Align @var{arg} in @var{axis} direction to the @var{dir} side."
354 (let* ((m (interpret-markup layout props arg)))
355 (ly:stencil-align-to! m axis dir)
358 (def-markup-command (halign layout props dir arg) (number? markup?)
359 "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
360 left-aligned, while @code{+1} is right. Values in between interpolate
361 alignment accordingly."
362 (let* ((m (interpret-markup layout props arg)))
363 (ly:stencil-align-to! m X dir)
366 (def-markup-command (musicglyph layout props glyph-name) (string?)
367 "This is converted to a musical symbol, e.g. @code{\\musicglyph
368 #\"accidentals.0\"} will select the natural sign from the music font.
369 See @usermanref{The Feta font} for a complete listing of the possible glyphs."
371 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
375 (def-markup-command (lookup layout props glyph-name) (string?)
376 "Lookup a glyph by name."
377 (ly:font-get-glyph (ly:paper-get-font layout props)
380 (def-markup-command (char layout props num) (integer?)
381 "Produce a single character, e.g. @code{\\char #65} produces the
383 (ly:get-glyph (ly:paper-get-font layout props) num))
385 (def-markup-command (raise layout props amount arg) (number? markup?)
387 This raises @var{arg}, by the distance @var{amount}.
388 A negative @var{amount} indicates lowering:
390 @lilypond[verbatim,fragment,relative=1]
391 c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
393 The argument to @code{\\raise} is the vertical displacement amount,
394 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
395 raise objects in relation to their surrounding markups.
397 If the text object itself is positioned above or below the staff, then
398 @code{\\raise} cannot be used to move it, since the mechanism that
399 positions it next to the staff cancels any shift made with
400 @code{\\raise}. For vertical positioning, use the @code{padding}
401 and/or @code{extra-offset} properties. "
402 (ly:stencil-translate-axis (interpret-markup layout props arg)
405 (def-markup-command (fraction layout props arg1 arg2) (markup? markup?)
406 "Make a fraction of two markups."
407 (let* ((m1 (interpret-markup layout props arg1))
408 (m2 (interpret-markup layout props arg2)))
409 (ly:stencil-align-to! m1 X CENTER)
410 (ly:stencil-align-to! m2 X CENTER)
411 (let* ((x1 (ly:stencil-extent m1 X))
412 (x2 (ly:stencil-extent m2 X))
413 (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
414 ;; should stack mols separately, to maintain LINE on baseline
415 (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
416 (ly:stencil-align-to! stack Y CENTER)
417 (ly:stencil-align-to! stack X LEFT)
418 ;; should have EX dimension
420 (ly:stencil-translate-axis stack 0.75 Y))))
423 ;; TODO: better syntax.
425 (def-markup-command (note-by-number layout props log dot-count dir) (number? number? number?)
426 "Construct a note symbol, with stem. By using fractional values for
427 @var{dir}, you can obtain longer or shorter stems."
428 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
429 (size (chain-assoc-get 'font-size props 0))
430 (stem-length (* (magstep size) (max 3 (- log 1))))
431 (head-glyph (ly:font-get-glyph
433 (string-append "noteheads.s" (number->string (min log 2)))))
434 (stem-thickness 0.13)
435 (stemy (* dir stem-length))
436 (attachx (if (> dir 0)
437 (- (cdr (ly:stencil-extent head-glyph X)) stem-thickness)
439 (attachy (* dir 0.28))
440 (stem-glyph (and (> log 0)
442 (cons attachx (+ attachx stem-thickness))
443 (cons (min stemy attachy)
445 (/ stem-thickness 3))))
446 (dot (ly:font-get-glyph font "dots-dot"))
447 (dotwid (interval-length (ly:stencil-extent dot X)))
448 (dots (and (> dot-count 0)
449 (apply ly:stencil-add
451 (ly:stencil-translate-axis
452 dot (* (+ 1 (* 2 x)) dotwid) X))
453 (iota dot-count 1)))))
454 (flaggl (and (> log 2)
455 (ly:stencil-translate
456 (ly:font-get-glyph font
457 (string-append "flags."
458 (if (> dir 0) "u" "d")
459 (number->string log)))
460 (cons (+ attachx (/ stem-thickness 2)) stemy)))))
462 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
463 (if (ly:stencil? stem-glyph)
464 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
465 (set! stem-glyph head-glyph))
466 (if (ly:stencil? dots)
469 (ly:stencil-translate-axis dots
470 (+ (if (and (> dir 0) (> log 2))
473 ;; huh ? why not necessary?
474 ;;(cdr (ly:stencil-extent head-glyph X))
480 (use-modules (ice-9 regex))
483 (let ((divisor (log 2)))
484 (lambda (z) (inexact->exact (/ (log z) divisor)))))
486 (define (parse-simple-duration duration-string)
487 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
488 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
489 (if (and match (string=? duration-string (match:substring match 0)))
490 (let ((len (match:substring match 1))
491 (dots (match:substring match 2)))
492 (list (cond ((string=? len "breve") -1)
493 ((string=? len "longa") -2)
494 ((string=? len "maxima") -3)
495 (else (log2 (string->number len))))
496 (if dots (string-length dots) 0)))
497 (error "This is not a valid duration string:" duration-string))))
499 (def-markup-command (note layout props duration dir) (string? number?)
500 "This produces a note with a stem pointing in @var{dir} direction, with
501 the @var{duration} for the note head type and augmentation dots. For
502 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
503 a shortened down stem."
504 (let ((parsed (parse-simple-duration duration)))
505 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
507 (def-markup-command (normal-size-super layout props arg) (markup?)
508 "Set @var{arg} in superscript with a normal font size."
509 (ly:stencil-translate-axis (interpret-markup
512 (* 0.5 (chain-assoc-get 'baseline-skip props))
515 (def-markup-command (super layout props arg) (markup?)
518 @cindex lowering text
520 @cindex translating text
522 @cindex @code{\\super}
525 Raising and lowering texts can be done with @code{\\super} and
528 @lilypond[verbatim,fragment,relative=1]
529 c1^\\markup { E \"=\" mc \\super \"2\" }
533 (ly:stencil-translate-axis
536 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
538 (* 0.5 (chain-assoc-get 'baseline-skip props))
541 (def-markup-command (translate layout props offset arg) (number-pair? markup?)
542 "This translates an object. Its first argument is a cons of numbers
544 A \\translate #(cons 2 -3) @{ B C @} D
546 This moves `B C' 2 spaces to the right, and 3 down, relative to its
547 surroundings. This command cannot be used to move isolated scripts
548 vertically, for the same reason that @code{\\raise} cannot be used for
552 (ly:stencil-translate (interpret-markup layout props arg)
555 (def-markup-command (sub layout props arg) (markup?)
556 "Set @var{arg} in subscript."
557 (ly:stencil-translate-axis
560 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
562 (* -0.5 (chain-assoc-get 'baseline-skip props))
565 (def-markup-command (normal-size-sub layout props arg) (markup?)
566 "Set @var{arg} in subscript, in a normal font size."
567 (ly:stencil-translate-axis
568 (interpret-markup layout props arg)
569 (* -0.5 (chain-assoc-get 'baseline-skip props))
572 (def-markup-command (hbracket layout props arg) (markup?)
573 "Draw horizontal brackets around @var{arg}."
574 (let ((th 0.1) ;; todo: take from GROB.
575 (m (interpret-markup layout props arg)))
576 (bracketify-stencil m X th (* 2.5 th) th)))
578 (def-markup-command (bracket layout props arg) (markup?)
579 "Draw vertical brackets around @var{arg}."
580 (let ((th 0.1) ;; todo: take from GROB.
581 (m (interpret-markup layout props arg)))
582 (bracketify-stencil m Y th (* 2.5 th) th)))
584 ;; todo: fix negative space
585 (def-markup-command (hspace layout props amount) (number?)
586 "This produces a invisible object taking horizontal space.
588 \\markup @{ A \\hspace #2.0 B @}
590 will put extra space between A and B, on top of the space that is
591 normally inserted before elements on a line.
594 (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
595 (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
597 (def-markup-command (override layout props new-prop arg) (pair? markup?)
598 "Add the first argument in to the property list. Properties may be
599 any sort of property supported by @internalsref{font-interface} and
600 @internalsref{text-interface}, for example
603 \\override #'(font-family . married) \"bla\"
607 (interpret-markup layout (cons (list new-prop) props) arg))
609 (def-markup-command (smaller layout props arg) (markup?)
610 "Decrease the font size relative to current setting"
611 (let* ((fs (chain-assoc-get 'font-size props 0))
612 (entry (cons 'font-size (- fs 1))))
613 (interpret-markup layout (cons (list entry) props) arg)))
615 (def-markup-command (bigger layout props arg) (markup?)
616 "Increase the font size relative to current setting"
617 (let* ((fs (chain-assoc-get 'font-size props 0))
618 (entry (cons 'font-size (+ fs 1))))
619 (interpret-markup layout (cons (list entry) props) arg)))
621 (def-markup-command larger (markup?) bigger-markup)
623 (def-markup-command (box layout props arg) (markup?)
624 "Draw a box round @var{arg}. Looks at @code{thickness} and
625 @code{box-padding} properties to determine line thickness and padding
627 (let ((th (chain-assoc-get 'thickness props 0.1))
628 (pad (chain-assoc-get 'box-padding props 0.2))
629 (m (interpret-markup layout props arg)))
630 (box-stencil m th pad)))
632 ;;FIXME: is this working?
633 (def-markup-command (strut layout props) ()
634 "Create a box of the same height as the space in the current font."
635 (let ((m (Text_interface::interpret_markup layout props " ")))
636 (ly:stencil-set-extent! m X '(1000 . -1000))
639 (define number->mark-letter-vector (make-vector 25 #\A))
644 (if (= i (- (char->integer #\I) (char->integer #\A)))
646 (vector-set! number->mark-letter-vector j
647 (integer->char (+ i (char->integer #\A)))))
649 (define number->mark-alphabet-vector (list->vector
650 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
652 (define (number->markletter-string vec n)
653 "Double letters for big marks."
654 (let* ((lst (vector-length vec)))
657 (string-append (number->markletter-string vec (1- (quotient n lst)))
658 (number->markletter-string vec (remainder n lst)))
659 (make-string 1 (vector-ref vec n)))))
661 (def-markup-command (markletter layout props num) (integer?)
662 "Make a markup letter for @var{num}. The letters start with A to Z
663 (skipping I), and continues with double letters."
664 (Text_interface::interpret_markup layout props
665 (number->markletter-string number->mark-letter-vector num)))
667 (def-markup-command (markalphabet layout props num) (integer?)
668 "Make a markup letter for @var{num}. The letters start with A to Z
669 and continues with double letters."
670 (Text_interface::interpret_markup layout props
671 (number->markletter-string number->mark-alphabet-vector num)))
673 (def-markup-command (bracketed-y-column layout props indices args)
675 "Make a column of the markups in @var{args}, putting brackets around
676 the elements marked in @var{indices}, which is a list of numbers."
677 (define (sublist lst start stop)
678 (take (drop lst start) (- (1+ stop) start)))
680 (define (stencil-list-extent ss axis)
682 (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
683 (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
685 (define (stack-stencils stencils bskip last-stencil)
687 ((null? stencils) '())
690 (stack-stencils (cdr stencils) bskip (car stencils))))
692 (let* ((orig (car stencils))
693 (dir (chain-assoc-get 'direction props DOWN))
694 (new (ly:stencil-moved-to-edge last-stencil Y dir
698 (cons new (stack-stencils (cdr stencils) bskip new))))))
700 (define (make-brackets stencils indices acc)
703 (pair? (cdr indices)))
704 (let* ((encl (sublist stencils (car indices) (cadr indices)))
705 (x-ext (stencil-list-extent encl X))
706 (y-ext (stencil-list-extent encl Y))
709 (protusion (* 2.5 thick))
711 (ly:stencil-translate-axis
712 (ly:bracket Y y-ext thick protusion)
713 (- (car x-ext) pad) X))
714 (rb (ly:stencil-translate-axis
715 (ly:bracket Y y-ext thick (- protusion))
716 (+ (cdr x-ext) pad) X)))
719 stencils (cddr indices)
732 (chain-assoc-get 'baseline-skip props))
733 (stacked (stack-stencils stencils 1.25 #f))
734 (brackets (make-brackets stacked indices '())))
736 (apply ly:stencil-add
737 (append stacked brackets))))