1 ;;;; output-lib.scm -- implement Scheme output helper functions
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2009 Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12 (define-public (grob::has-interface grob iface)
13 (memq iface (ly:grob-interfaces grob)))
15 (define-public (grob::is-live? grob)
16 (pair? (ly:grob-basic-properties grob)))
18 (define-public (make-stencil-boxer thickness padding callback)
20 "Return function that adds a box around the grob passed as argument."
22 (box-stencil (callback grob) thickness padding)))
24 (define-public (make-stencil-circler thickness padding callback)
25 "Return function that adds a circle around the grob passed as argument."
27 (lambda (grob) (circle-stencil (callback grob) thickness padding)))
29 (define-public (print-circled-text-callback grob)
30 (grob-interpret-markup grob (make-circle-markup
31 (ly:grob-property grob 'text))))
33 (define-public (event-cause grob)
34 (let ((cause (ly:grob-property grob 'cause)))
37 ((ly:stream-event? cause) cause)
38 ((ly:grob? cause) (event-cause cause))
41 (define-public (grob-interpret-markup grob text)
42 (let* ((layout (ly:grob-layout grob))
43 (defs (ly:output-def-lookup layout 'text-font-defaults))
44 (props (ly:grob-alist-chain grob defs)))
46 (ly:text-interface::interpret-markup layout props text)))
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52 (define-public (stem::calc-duration-log grob)
54 (ly:event-property (event-cause grob) 'duration)))
56 (define-public (note-head::calc-duration-log grob)
59 (ly:event-property (event-cause grob) 'duration))))
61 (define-public (dots::calc-dot-count grob)
62 (ly:duration-dot-count
63 (ly:event-property (event-cause grob) 'duration)))
65 (define-public (dots::calc-staff-position grob)
66 (let* ((head (ly:grob-parent grob Y))
67 (log (ly:grob-property head 'duration-log)))
70 ((or (not (grob::has-interface head 'rest-interface))
71 (not (integer? log))) 0)
80 (define-public (note-head::calc-glyph-name grob)
81 (let ((style (ly:grob-property grob 'style))
82 (log (min 2 (ly:grob-property grob 'duration-log))))
85 ;; "default" style is directly handled in note-head.cc as a
86 ;; special case (HW says, mainly for performance reasons).
87 ;; Therefore, style "default" does not appear in this case
89 ((xcircle) "2xcircle")
90 ((harmonic) "0harmonic")
91 ((harmonic-black) "2harmonic")
92 ((harmonic-mixed) (if (<= log 1) "0harmonic"
95 ;; Oops, I actually would not call this "baroque", but, for
96 ;; backwards compatibility to 1.4, this is supposed to take
97 ;; brevis, longa and maxima from the neo-mensural font and all
98 ;; other note heads from the default font. -- jr
100 (string-append (number->string log) "neomensural")
101 (number->string log)))
103 (string-append (number->string log) (symbol->string style)))
106 (string-append (number->string log) "mensural")
107 (string-append (number->string log) (symbol->string style))))
109 (string-append (number->string log) (symbol->string style)))
111 (if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
112 (symbol->string style)
113 (string-append (number->string (max 0 log))
114 (symbol->string style)))))))
116 (define-public (note-head::brew-ez-stencil grob)
117 (let* ((log (ly:grob-property grob 'duration-log))
118 (pitch (ly:event-property (event-cause grob) 'pitch))
119 (pitch-index (ly:pitch-notename pitch))
120 (note-names (ly:grob-property grob 'note-names))
121 (pitch-string (if (vector? note-names)
122 (vector-ref note-names pitch-index)
125 (+ (modulo (+ pitch-index 2) 7)
126 (char->integer #\A))))))
127 (staff-space (ly:staff-symbol-staff-space grob))
128 (line-thickness (ly:staff-symbol-line-thickness grob))
129 (stem (ly:grob-object grob 'stem))
130 (stem-thickness (* (if (ly:grob? stem)
131 (ly:grob-property stem 'thickness)
134 (radius (/ (+ staff-space line-thickness) 2))
135 (letter (markup #:center-align #:vcenter pitch-string))
136 (filled-circle (markup #:draw-circle radius 0 #t)))
138 (grob-interpret-markup
143 (make-with-color-markup white letter))
147 (make-with-color-markup white (make-draw-circle-markup
148 (- radius stem-thickness) 0 #t)))
151 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
154 (define-public all-visible #(#t #t #t))
155 (define-public begin-of-line-invisible #(#t #t #f))
156 (define-public center-invisible #(#t #f #t))
157 (define-public end-of-line-invisible #(#f #t #t))
158 (define-public begin-of-line-visible #(#f #f #t))
159 (define-public center-visible #(#f #t #f))
160 (define-public end-of-line-visible #(#t #f #f))
161 (define-public all-invisible #(#f #f #f))
163 (define-public spanbar-begin-of-line-invisible #(#t #f #f))
166 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
170 ;; How should a bar line behave at a break?
171 (define bar-glyph-alist
172 '((":|:" . (":|" . "|:"))
173 (":|.|:" . (":|" . "|:"))
174 (":|.:" . (":|" . "|:"))
175 ("||:" . ("||" . "|:"))
176 ("dashed" . ("dashed" . '()))
178 ("||:" . ("||" . "|:"))
180 ("|:" . ("|" . "|:"))
183 ;; hmm... should we end with a bar line here?
184 (".|" . ("|" . ".|"))
187 (".|." . (".|." . ()))
188 ("|.|" . ("|.|" . ()))
193 ("empty" . (() . ()))
194 ("brace" . (() . "brace"))
195 ("bracket" . (() . "bracket"))))
197 (define-public (bar-line::calc-glyph-name grob)
198 (let* ((glyph (ly:grob-property grob 'glyph))
199 (dir (ly:item-break-dir grob))
200 (result (assoc glyph bar-glyph-alist))
201 (glyph-name (if (= dir CENTER)
204 (string? (index-cell (cdr result) dir)))
205 (index-cell (cdr result) dir)
209 (define-public (bar-line::calc-break-visibility grob)
210 (let* ((glyph (ly:grob-property grob 'glyph))
211 (result (assoc glyph bar-glyph-alist)))
214 (vector (string? (cadr result)) #t (string? (cddr result)))
217 (define-public (shift-right-at-line-begin g)
218 "Shift an item to the right, but only at the start of the line."
219 (if (and (ly:item? g)
220 (equal? (ly:item-break-dir g) RIGHT))
221 (ly:grob-translate-axis! g 3.5 X)))
224 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
227 (define-public (tuplet-number::calc-denominator-text grob)
228 (number->string (ly:event-property (event-cause grob) 'denominator)))
230 (define-public (tuplet-number::calc-fraction-text grob)
231 (let ((ev (event-cause grob)))
234 (ly:event-property ev 'denominator)
235 (ly:event-property ev 'numerator))))
237 ;; a formatter function, which is simply a wrapper around an existing
238 ;; tuplet formatter function. It takes the value returned by the given
239 ;; function and appends a note of given length.
240 (define-public ((tuplet-number::append-note-wrapper function note) grob)
241 (let ((txt (if function (function grob) #f)))
244 (markup txt #:fontsize -5 #:note note UP)
245 (markup #:fontsize -5 #:note note UP))))
247 ;; Print a tuplet denominator with a different number than the one derived from
248 ;; the actual tuplet fraction
249 (define-public ((tuplet-number::non-default-tuplet-denominator-text denominator)
251 (number->string (if denominator
253 (ly:event-property (event-cause grob) 'denominator))))
255 ;; Print a tuplet fraction with different numbers than the ones derived from
256 ;; the actual tuplet fraction
257 (define-public ((tuplet-number::non-default-tuplet-fraction-text
258 denominator numerator) grob)
259 (let* ((ev (event-cause grob))
260 (den (if denominator denominator (ly:event-property ev 'denominator)))
261 (num (if numerator numerator (ly:event-property ev 'numerator))))
263 (format "~a:~a" den num)))
265 ;; Print a tuplet fraction with note durations appended to the numerator and the
267 (define-public ((tuplet-number::fraction-with-notes
268 denominatornote numeratornote) grob)
269 (let* ((ev (event-cause grob))
270 (denominator (ly:event-property ev 'denominator))
271 (numerator (ly:event-property ev 'numerator)))
273 ((tuplet-number::non-default-fraction-with-notes
274 denominator denominatornote numerator numeratornote) grob)))
276 ;; Print a tuplet fraction with note durations appended to the numerator and the
278 (define-public ((tuplet-number::non-default-fraction-with-notes
279 denominator denominatornote numerator numeratornote) grob)
280 (let* ((ev (event-cause grob))
281 (den (if denominator denominator (ly:event-property ev 'denominator)))
282 (num (if numerator numerator (ly:event-property ev 'numerator))))
284 (make-concat-markup (list
285 (make-simple-markup (format "~a" den))
286 (markup #:fontsize -5 #:note denominatornote UP)
287 (make-simple-markup " : ")
288 (make-simple-markup (format "~a" num))
289 (markup #:fontsize -5 #:note numeratornote UP)))))
292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
295 (define-public color? list?)
296 (define-public (rgb-color r g b) (list r g b))
299 (define-public black '(0.0 0.0 0.0))
300 (define-public white '(1.0 1.0 1.0))
301 (define-public red '(1.0 0.0 0.0))
302 (define-public green '(0.0 1.0 0.0))
303 (define-public blue '(0.0 0.0 1.0))
304 (define-public cyan '(0.0 1.0 1.0))
305 (define-public magenta '(1.0 0.0 1.0))
306 (define-public yellow '(1.0 1.0 0.0))
308 (define-public grey '(0.5 0.5 0.5))
309 (define-public darkred '(0.5 0.0 0.0))
310 (define-public darkgreen '(0.0 0.5 0.0))
311 (define-public darkblue '(0.0 0.0 0.5))
312 (define-public darkcyan '(0.0 0.5 0.5))
313 (define-public darkmagenta '(0.5 0.0 0.5))
314 (define-public darkyellow '(0.5 0.5 0.0))
317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
320 (define-public (key-signature-interface::alteration-position step alter
322 ;; TODO: memoize - this is mostly constant.
324 ;; fes, ges, as and bes typeset in lower octave
325 (define FLAT_TOP_PITCH 2)
327 ;; ais and bis typeset in lower octave
328 (define SHARP_TOP_PITCH 4)
331 (+ (cdr step) (* (car step) 7) c0-position)
332 (let* ((from-bottom-pos (modulo (+ 4 49 c0-position) 7))
334 (c0 (- from-bottom-pos 4)))
338 (or (> p FLAT_TOP_PITCH) (> (+ p c0) 4)) (> (+ p c0) 1))
340 (or (> p SHARP_TOP_PITCH) (> (+ p c0) 5)) (> (+ p c0) 2)))
342 ;; Typeset below c_position
345 ;; Provide for the four cases in which there's a glitch
346 ;; it's a hack, but probably not worth
347 ;; the effort of finding a nicer solution.
350 ((and (= c0 2) (= p 3) (> alter 0))
352 ((and (= c0 -3) (= p -1) (> alter 0))
354 ((and (= c0 -4) (= p -1) (< alter 0))
356 ((and (= c0 -2) (= p -3) (< alter 0))
362 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
365 (define-public (accidental-interface::calc-alteration grob)
366 (ly:pitch-alteration (ly:event-property (event-cause grob) 'pitch)))
368 (define-public cancellation-glyph-name-alist
369 '((0 . "accidentals.natural")))
371 (define-public standard-alteration-glyph-name-alist
373 ;; ordered for optimal performance.
374 (0 . "accidentals.natural")
375 (-1/2 . "accidentals.flat")
376 (1/2 . "accidentals.sharp")
378 (1 . "accidentals.doublesharp")
379 (-1 . "accidentals.flatflat")
381 (3/4 . "accidentals.sharp.slashslash.stemstemstem")
382 (1/4 . "accidentals.sharp.slashslash.stem")
383 (-1/4 . "accidentals.mirroredflat")
384 (-3/4 . "accidentals.mirroredflat.flat")))
386 ;; FIXME: standard vs default, alteration-FOO vs FOO-alteration
387 (define-public alteration-default-glyph-name-alist
388 standard-alteration-glyph-name-alist)
390 (define-public makam-alteration-glyph-name-alist
391 '((1 . "accidentals.doublesharp")
392 (8/9 . "accidentals.sharp.slashslashslash.stemstem")
393 (5/9 . "accidentals.sharp.slashslashslash.stem")
394 (4/9 . "accidentals.sharp")
395 (1/9 . "accidentals.sharp.slashslash.stem")
396 (0 . "accidentals.natural")
397 (-1/9 . "accidentals.mirroredflat")
398 (-4/9 . "accidentals.flat.slash")
399 (-5/9 . "accidentals.flat")
400 (-8/9 . "accidentals.flat.slashslash")
401 (-1 . "accidentals.flatflat")))
403 (define-public alteration-hufnagel-glyph-name-alist
404 '((-1/2 . "accidentals.hufnagelM1")
405 (0 . "accidentals.vaticana0")
406 (1/2 . "accidentals.mensural1")))
408 (define-public alteration-medicaea-glyph-name-alist
409 '((-1/2 . "accidentals.medicaeaM1")
410 (0 . "accidentals.vaticana0")
411 (1/2 . "accidentals.mensural1")))
413 (define-public alteration-vaticana-glyph-name-alist
414 '((-1/2 . "accidentals.vaticanaM1")
415 (0 . "accidentals.vaticana0")
416 (1/2 . "accidentals.mensural1")))
418 (define-public alteration-mensural-glyph-name-alist
419 '((-1/2 . "accidentals.mensuralM1")
420 (0 . "accidentals.vaticana0")
421 (1/2 . "accidentals.mensural1")))
424 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
425 ;; * Pitch Trill Heads
428 (define-public (parentheses-item::calc-parenthesis-stencils grob)
429 (let* ((font (ly:grob-default-font grob))
430 (lp (ly:font-get-glyph font "accidentals.leftparen"))
431 (rp (ly:font-get-glyph font "accidentals.rightparen")))
435 (define-public (parentheses-item::calc-angled-bracket-stencils grob)
436 (let* ((font (ly:grob-default-font grob))
437 (lp (ly:stencil-aligned-to (ly:stencil-aligned-to
438 (grob-interpret-markup
440 (ly:wide-char->utf-8 #x2329))
443 (rp (ly:stencil-aligned-to (ly:stencil-aligned-to
444 (grob-interpret-markup
446 (ly:wide-char->utf-8 #x232A))
450 (list (stencil-whiteout lp)
451 (stencil-whiteout rp))))
453 (define (parenthesize-elements grob . rest)
454 (let* ((refp (if (null? rest)
457 (elts (ly:grob-object grob 'elements))
458 (x-ext (ly:relative-group-extent elts refp X))
459 (stencils (ly:grob-property grob 'stencils))
462 (padding (ly:grob-property grob 'padding 0.1)))
465 (ly:stencil-translate-axis lp (- (car x-ext) padding) X)
466 (ly:stencil-translate-axis rp (+ (cdr x-ext) padding) X))))
469 (define (parentheses-item::print me)
470 (let* ((elts (ly:grob-object me 'elements))
471 (y-ref (ly:grob-common-refpoint-of-array me elts Y))
472 (x-ref (ly:grob-common-refpoint-of-array me elts X))
473 (stencil (parenthesize-elements me x-ref))
474 (elt-y-ext (ly:relative-group-extent elts y-ref Y))
475 (y-center (interval-center elt-y-ext)))
477 (ly:stencil-translate
480 (- (ly:grob-relative-coordinate me x-ref X))
481 (- y-center (ly:grob-relative-coordinate me y-ref Y))))))
485 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
488 (define-public (chain-grob-member-functions grob value . funcs)
491 (set! value (func grob value)))
497 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
500 (define-public (bend::print spanner)
502 (< (abs (- a b)) 0.01))
504 (let* ((delta-y (* 0.5 (ly:grob-property spanner 'delta-position)))
505 (left-span (ly:spanner-bound spanner LEFT))
506 (dots (if (and (grob::has-interface left-span 'note-head-interface)
507 (ly:grob? (ly:grob-object left-span 'dot)))
508 (ly:grob-object left-span 'dot) #f))
510 (right-span (ly:spanner-bound spanner RIGHT))
511 (thickness (* (ly:grob-property spanner 'thickness)
512 (ly:output-def-lookup (ly:grob-layout spanner)
514 (padding (ly:grob-property spanner 'padding 0.5))
515 (common (ly:grob-common-refpoint right-span
516 (ly:grob-common-refpoint spanner
519 (common-y (ly:grob-common-refpoint spanner left-span Y))
520 (minimum-length (ly:grob-property spanner 'minimum-length 0.5))
524 (interval-end (ly:grob-robust-relative-extent
529 (ly:grob-relative-coordinate dots common-y Y)
530 (ly:grob-relative-coordinate spanner common-y Y)))
532 (ly:grob-robust-relative-extent dots common X))
533 ;; TODO: use real infinity constant.
535 (right-x (max (- (interval-start
536 (ly:grob-robust-relative-extent right-span common X))
538 (+ left-x minimum-length)))
539 (self-x (ly:grob-relative-coordinate spanner common X))
540 (dx (- right-x left-x))
541 (exp (list 'path thickness
549 ,dx ,(* 0.66 delta-y)
554 (cons (- left-x self-x) (- right-x self-x))
555 (cons (min 0 delta-y)
559 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
562 (define-public (grace-spacing::calc-shortest-duration grob)
563 (let* ((cols (ly:grob-object grob 'columns))
566 (ly:moment-sub (ly:grob-property
567 (ly:grob-array-ref cols (1+ idx)) 'when)
569 (ly:grob-array-ref cols idx) 'when))))
571 (moment-min (lambda (x y)
574 (if (ly:moment<? x y)
580 (fold moment-min #f (map get-difference
581 (iota (1- (ly:grob-array-length cols)))))))
584 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
587 (define-public (fingering::calc-text grob)
588 (let* ((event (event-cause grob))
589 (digit (ly:event-property event 'digit)))
592 (ly:input-message (ly:event-property event 'origin)
593 "Warning: Fingering notation for finger number ~a"
596 (number->string digit 10)))
598 (define-public (string-number::calc-text grob)
599 (let ((digit (ly:event-property (event-cause grob) 'string-number)))
601 (number->string digit 10)))
603 (define-public (stroke-finger::calc-text grob)
604 (let* ((digit (ly:event-property (event-cause grob) 'digit))
605 (text (ly:event-property (event-cause grob) 'text)))
609 (vector-ref (ly:grob-property grob 'digit-names)
610 (1- (max (min 5 digit) 1))))))
613 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
616 (define-public (hairpin::calc-grow-direction grob)
617 (if (eq? (ly:event-property (event-cause grob) 'class) 'decrescendo-event)
622 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
625 (define-public (lyric-text::print grob)
626 "Allow interpretation of tildes as lyric tieing marks."
628 (let ((text (ly:grob-property grob 'text)))
630 (grob-interpret-markup grob (if (string? text)
631 (make-tied-lyric-markup text)
634 (define-public ((grob::calc-property-by-copy prop) grob)
635 (ly:event-property (event-cause grob) prop))
638 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
641 (define-public (fret-board::calc-stencil grob)
642 (grob-interpret-markup
644 (make-fret-diagram-verbose-markup
645 (ly:grob-property grob 'dot-placement-list))))
648 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
651 (define-public (script-interface::calc-x-offset grob)
652 (ly:grob-property grob 'positioning-done)
653 (let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
655 (ly:self-alignment-interface::centered-on-x-parent grob))
656 (note-head-grob (ly:grob-parent grob X))
657 (stem-grob (ly:grob-object note-head-grob 'stem)))
659 (+ note-head-location
660 ;; If the property 'toward-stem-shift is defined and the script
661 ;; has the same direction as the stem, move the script accordingly.
662 ;; Since scripts can also be over skips, we need to check whether
663 ;; the grob has a stem at all.
664 (if (ly:grob? stem-grob)
665 (let ((dir1 (ly:grob-property grob 'direction))
666 (dir2 (ly:grob-property stem-grob 'direction)))
667 (if (equal? dir1 dir2)
668 (let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
670 (ly:grob-relative-coordinate stem-grob common-refp X)))
671 (* shift (- stem-location note-head-location)))
676 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
679 (define-public (system-start-text::print grob)
680 (let* ((left-bound (ly:spanner-bound grob LEFT))
681 (left-mom (ly:grob-property left-bound 'when))
682 (name (if (moment<=? left-mom ZERO-MOMENT)
683 (ly:grob-property grob 'long-text)
684 (ly:grob-property grob 'text))))
686 (if (and (markup? name)
687 (!= (ly:item-break-dir left-bound) CENTER))
689 (grob-interpret-markup grob name)
690 (ly:grob-suicide! grob))))
692 (define-public (system-start-text::calc-x-offset grob)
693 (let* ((left-bound (ly:spanner-bound grob LEFT))
694 (left-mom (ly:grob-property left-bound 'when))
695 (layout (ly:grob-layout grob))
696 (indent (ly:output-def-lookup layout
697 (if (moment<=? left-mom ZERO-MOMENT)
701 (system (ly:grob-system grob))
702 (my-extent (ly:grob-extent grob system X))
703 (elements (ly:grob-object system 'elements))
704 (common (ly:grob-common-refpoint-of-array system elements X))
705 (total-ext empty-interval)
706 (align-x (ly:grob-property grob 'self-alignment-X 0))
707 (padding (min 0 (- (interval-length my-extent) indent)))
708 (right-padding (- padding
709 (/ (* padding (1+ align-x)) 2))))
711 ;; compensate for the variation in delimiter extents by
712 ;; calculating an X-offset correction based on united extents
713 ;; of all delimiters in this system
714 (let unite-delims ((l (ly:grob-array-length elements)))
716 (let ((elt (ly:grob-array-ref elements (1- l))))
718 (if (grob::has-interface elt 'system-start-delimiter-interface)
719 (let ((dims (ly:grob-extent elt common X)))
720 (if (interval-sane? dims)
721 (set! total-ext (interval-union total-ext dims)))))
722 (unite-delims (1- l)))))
725 (ly:side-position-interface::x-aligned-side grob)
727 (- (interval-length total-ext)))))
729 (define-public (system-start-text::calc-y-offset grob)
731 (define (live-elements-list me)
732 (let* ((elements (ly:grob-object me 'elements))
733 (elts-length (ly:grob-array-length elements))
736 (let get-live ((len elts-length))
738 (let ((elt (ly:grob-array-ref elements (1- len))))
740 (if (grob::is-live? elt)
741 (set! live-elements (cons elt live-elements)))
742 (get-live (1- len)))))
745 (let* ((left-bound (ly:spanner-bound grob LEFT))
746 (live-elts (live-elements-list grob))
747 (system (ly:grob-system grob))
748 (extent empty-interval))
750 (if (and (pair? live-elts)
751 (interval-sane? (ly:grob-extent grob system Y)))
752 (let get-extent ((lst live-elts))
754 (let ((axis-group (car lst)))
756 (if (and (ly:spanner? axis-group)
757 (equal? (ly:spanner-bound axis-group LEFT)
759 (set! extent (add-point extent
760 (ly:grob-relative-coordinate
761 axis-group system Y))))
762 (get-extent (cdr lst)))))
763 ;; no live axis group(s) for this instrument name -> remove from system
764 (ly:grob-suicide! grob))
767 (ly:self-alignment-interface::y-aligned-on-self grob)
768 (interval-center extent))))