1 ;;;; define-markup-commands.scm -- markup commands
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2000--2006 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
10 ;;; * each markup function should have a doc string with
11 ;; syntax, description and example.
13 (use-modules (ice-9 regex))
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 (define-public empty-stencil (ly:make-stencil '() '(1 . -1) '(1 . -1)))
20 (define-public point-stencil (ly:make-stencil "" '(0 . 0) '(0 . 0)))
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
27 (define-markup-command (draw-circle layout props radius thickness fill)
28 (number? number? boolean?)
29 "A circle of radius @var{radius}, thickness @var{thickness} and
31 (make-circle-stencil radius thickness fill))
33 (define-markup-command (triangle layout props filled) (boolean?)
34 "A triangle, filled or not"
36 ((th (chain-assoc-get 'thickness props 0.1))
37 (size (chain-assoc-get 'font-size props 0))
40 (chain-assoc-get 'baseline-skip props 2))))
54 (define-markup-command (circle layout props arg) (markup?)
55 "Draw a circle around @var{arg}. Use @code{thickness},
56 @code{circle-padding} and @code{font-size} properties to determine line
57 thickness and padding around the markup."
58 (let* ((th (chain-assoc-get 'thickness props 0.1))
59 (size (chain-assoc-get 'font-size props 0))
62 (chain-assoc-get 'circle-padding props 0.2)))
63 (m (interpret-markup layout props arg)))
64 (circle-stencil m th pad)))
66 (define-markup-command (with-url layout props url arg) (string? markup?)
67 "Add a link to URL @var{url} around @var{arg}. This only works in
69 (let* ((stil (interpret-markup layout props arg))
70 (xextent (ly:stencil-extent stil X))
71 (yextent (ly:stencil-extent stil Y))
72 (old-expr (ly:stencil-expr stil))
73 (url-expr (list 'url-link url `(quote ,xextent) `(quote ,yextent))))
74 (ly:stencil-add (ly:make-stencil url-expr xextent yextent) stil)))
77 (define-markup-command (beam layout props width slope thickness)
78 (number? number? number?)
79 "Create a beam with the specified parameters."
80 (let* ((y (* slope width))
81 (yext (cons (min 0 y) (max 0 y)))
82 (half (/ thickness 2)))
87 width (+ (* width slope) (/ thickness -2))
88 width (+ (* width slope) (/ thickness 2))
90 ,(ly:output-def-lookup layout 'blot-diameter)
93 (cons (+ (- half) (car yext))
94 (+ half (cdr yext))))))
96 (define-markup-command (box layout props arg) (markup?)
97 "Draw a box round @var{arg}. Looks at @code{thickness},
98 @code{box-padding} and @code{font-size} properties to determine line
99 thickness and padding around the markup."
101 (let* ((th (chain-assoc-get 'thickness props 0.1))
102 (size (chain-assoc-get 'font-size props 0))
103 (pad (* (magstep size)
104 (chain-assoc-get 'box-padding props 0.2)))
105 (m (interpret-markup layout props arg)))
106 (box-stencil m th pad)))
108 (define-markup-command (filled-box layout props xext yext blot)
109 (number-pair? number-pair? number?)
110 "Draw a box with rounded corners of dimensions @var{xext} and
111 @var{yext}. For example,
113 \\filled-box #'(-.3 . 1.8) #'(-.3 . 1.8) #0
115 create a box extending horizontally from -0.3 to 1.8 and
116 vertically from -0.3 up to 1.8, with corners formed from a
117 circle of diameter 0 (ie sharp corners)."
121 (define-markup-command (rotate layout props ang arg) (number? markup?)
122 "Rotate object with @var{ang} degrees around its center."
123 (let* ((stil (interpret-markup layout props arg)))
124 (ly:stencil-rotate stil ang 0 0)))
127 (define-markup-command (whiteout layout props arg) (markup?)
128 "Provide a white underground for @var{arg}"
129 (let* ((stil (interpret-markup layout props arg))
131 (interpret-markup layout props
132 (make-with-color-markup
134 (make-filled-box-markup
135 (ly:stencil-extent stil X)
136 (ly:stencil-extent stil Y)
139 (ly:stencil-add white stil)))
141 (define-markup-command (pad-markup layout props padding arg) (number? markup?)
142 "Add space around a markup object."
145 ((stil (interpret-markup layout props arg))
146 (xext (ly:stencil-extent stil X))
147 (yext (ly:stencil-extent stil Y)))
150 (ly:stencil-expr stil)
151 (interval-widen xext padding)
152 (interval-widen yext padding))))
154 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
156 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
158 ;;FIXME: is this working?
159 (define-markup-command (strut layout props) ()
160 "Create a box of the same height as the space in the current font."
161 (let ((m (ly:text-interface::interpret-markup layout props " ")))
162 (ly:make-stencil (ly:stencil-expr m)
164 (ly:stencil-extent m X)
168 ;; todo: fix negative space
169 (define-markup-command (hspace layout props amount) (number?)
170 "This produces a invisible object taking horizontal space.
172 \\markup @{ A \\hspace #2.0 B @}
174 will put extra space between A and B, on top of the space that is
175 normally inserted before elements on a line.
178 (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
179 (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
182 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
183 ;; importing graphics.
184 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
186 (define-markup-command (stencil layout props stil) (ly:stencil?)
191 (make-regexp "%%BoundingBox:[ \t]+([0-9-]+)[ \t]+([0-9-]+)[ \t]+([0-9-]+)[ \t]+([0-9-]+)"))
193 (define (get-postscript-bbox string)
194 "Extract the bbox from STRING, or return #f if not present."
196 ((match (regexp-exec bbox-regexp string)))
200 (string->number (match:substring match x)))
205 (define-markup-command (epsfile layout props axis size file-name) (number? number? string?)
206 "Inline an EPS image. The image is scaled along @var{axis} to
209 (if (ly:get-option 'safe)
210 (interpret-markup layout props "not allowed in safe")
211 (eps-file->stencil axis size file-name)
214 (define-markup-command (postscript layout props str) (string?)
215 "This inserts @var{str} directly into the output as a PostScript
216 command string. Due to technicalities of the output backends,
217 different scales should be used for the @TeX{} and PostScript backend,
218 selected with @code{-f}.
221 For the TeX backend, the following string prints a rotated text
226 0 0 moveto /ecrm10 findfont
227 1.75 scalefont setfont 90 rotate (hello) show
231 The magical constant 1.75 scales from LilyPond units (staff spaces) to
234 For the postscript backend, use the following
237 gsave /ecrm10 findfont
238 10.0 output-scale div
239 scalefont setfont 90 rotate (hello) show grestore
244 (list 'embedded-ps str)
248 (define-markup-command (score layout props score) (ly:score?)
249 "Inline an image of music."
250 (let* ((output (ly:score-embedded-format score layout)))
252 (if (ly:music-output? output)
253 (paper-system-stencil
254 (vector-ref (ly:paper-score-paper-systems output) 0))
256 (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?"))
259 (define-markup-command (null layout props) ()
260 "An empty markup with extents of a single point"
264 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
268 (define-markup-command (simple layout props str) (string?)
269 "A simple text string; @code{\\markup @{ foo @}} is equivalent with
270 @code{\\markup @{ \\simple #\"foo\" @}}."
271 (interpret-markup layout props str))
274 ;; TODO: use font recoding.
276 ;; (map make-word-markup (string-tokenize str)))))
278 (define-public empty-markup
279 (make-simple-markup ""))
281 ;; helper for justifying lines.
282 (define (get-fill-space word-count line-width text-widths)
283 "Calculate the necessary paddings between each two adjacent texts.
284 The lengths of all texts are stored in @var{text-widths}.
285 The normal formula for the padding between texts a and b is:
286 padding = line-width/(word-count - 1) - (length(a) + length(b))/2
287 The first and last padding have to be calculated specially using the
288 whole length of the first or last text.
289 Return a list of paddings.
292 ((null? text-widths) '())
294 ;; special case first padding
295 ((= (length text-widths) word-count)
297 (- (- (/ line-width (1- word-count)) (car text-widths))
298 (/ (car (cdr text-widths)) 2))
299 (get-fill-space word-count line-width (cdr text-widths))))
300 ;; special case last padding
301 ((= (length text-widths) 2)
302 (list (- (/ line-width (1- word-count))
303 (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0))
306 (- (/ line-width (1- word-count))
307 (/ (+ (car text-widths) (car (cdr text-widths))) 2))
308 (get-fill-space word-count line-width (cdr text-widths))))))
310 (define-markup-command (fill-line layout props markups)
312 "Put @var{markups} in a horizontal line of width @var{line-width}.
313 The markups are spaced/flushed to fill the entire line.
314 If there are no arguments, return an empty stencil."
316 (let* ((orig-stencils
317 (map (lambda (x) (interpret-markup layout props x))
321 (if (ly:stencil-empty? stc)
323 stc)) orig-stencils))
326 (if (ly:stencil-empty? stc)
328 (interval-length (ly:stencil-extent stc X))))
330 (text-width (apply + text-widths))
331 (text-dir (chain-assoc-get 'text-direction props RIGHT))
332 (word-count (length stencils))
333 (word-space (chain-assoc-get 'word-space props 1))
334 (prop-line-width (chain-assoc-get 'line-width props #f))
335 (line-width (if prop-line-width prop-line-width
336 (ly:output-def-lookup layout 'line-width)))
341 (/ (- line-width text-width) 2)
342 (/ (- line-width text-width) 2)))
345 (- line-width text-width)))
347 (get-fill-space word-count line-width text-widths))))
355 (line-stencils (if (= word-count 1)
362 (if (= text-dir LEFT)
363 (set! line-stencils (reverse line-stencils)))
365 (if (null? (remove ly:stencil-empty? orig-stencils))
367 (stack-stencils-padding-list X
368 RIGHT fill-space-normal line-stencils))))
370 (define-markup-command (line layout props args) (markup-list?)
371 "Put @var{args} in a horizontal line. The property @code{word-space}
372 determines the space between each markup in @var{args}."
374 ((stencils (map (lambda (m) (interpret-markup layout props m)) args))
375 (space (chain-assoc-get 'word-space props))
376 (text-dir (chain-assoc-get 'text-direction props RIGHT))
379 (if (= text-dir LEFT)
380 (set! stencils (reverse stencils)))
385 (remove ly:stencil-empty? stencils))))
388 (define (wordwrap-stencils stencils
389 justify base-space line-width text-dir)
391 "Perform simple wordwrap, return stencil of each line."
393 (define space (if justify
395 ;; justify only stretches lines.
399 (define (take-list width space stencils
400 accumulator accumulated-width)
401 "Return (head-list . tail) pair, with head-list fitting into width"
403 (cons accumulator stencils)
405 ((first (car stencils))
406 (first-wid (cdr (ly:stencil-extent (car stencils) X)))
407 (newwid (+ space first-wid accumulated-width))
411 (or (null? accumulator)
414 (take-list width space
416 (cons first accumulator)
418 (cons accumulator stencils))
426 ((line-break (take-list line-width space todo
428 (line-stencils (car line-break))
429 (space-left (- line-width (apply + (map (lambda (x) (cdr (ly:stencil-extent x X)))
432 (line-word-space (cond
433 ((not justify) space)
435 ;; don't stretch last line of paragraph.
436 ;; hmmm . bug - will overstretch the last line in some case.
437 ((null? (cdr line-break))
439 ((null? line-stencils) 0.0)
440 ((null? (cdr line-stencils)) 0.0)
441 (else (/ space-left (1- (length line-stencils))))))
443 (line (stack-stencil-line
445 (if (= text-dir RIGHT)
446 (reverse line-stencils)
449 (if (pair? (cdr line-break))
450 (loop (cons line lines)
454 (if (= text-dir LEFT)
456 (ly:stencil-translate-axis line
457 (- line-width (interval-end (ly:stencil-extent line X)))
459 (reverse (cons line lines))
466 (define (wordwrap-markups layout props args justify)
468 ((baseline-skip (chain-assoc-get 'baseline-skip props))
469 (prop-line-width (chain-assoc-get 'line-width props #f))
470 (line-width (if prop-line-width prop-line-width
471 (ly:output-def-lookup layout 'line-width)))
472 (word-space (chain-assoc-get 'word-space props))
473 (text-dir (chain-assoc-get 'text-direction props RIGHT))
474 (lines (wordwrap-stencils
475 (remove ly:stencil-empty?
476 (map (lambda (m) (interpret-markup layout props m)) args))
477 justify word-space line-width
481 (stack-lines DOWN 0.0 baseline-skip lines)))
483 (define-markup-command (justify layout props args) (markup-list?)
484 "Like wordwrap, but with lines stretched to justify the margins.
485 Use @code{\\override #'(line-width . X)} to set line-width, where X
486 is the number of staff spaces."
488 (wordwrap-markups layout props args #t))
490 (define-markup-command (wordwrap layout props args) (markup-list?)
491 "Simple wordwrap. Use @code{\\override #'(line-width . X)} to set
492 line-width, where X is the number of staff spaces."
494 (wordwrap-markups layout props args #f))
496 (define (wordwrap-string layout props justify arg)
498 ((baseline-skip (chain-assoc-get 'baseline-skip props))
499 (line-width (chain-assoc-get 'line-width props))
500 (word-space (chain-assoc-get 'word-space props))
502 (para-strings (regexp-split
503 (string-regexp-substitute "\r" "\n"
504 (string-regexp-substitute "\r\n" "\n" arg))
505 "\n[ \t\n]*\n[ \t\n]*"))
507 (text-dir (chain-assoc-get 'text-direction props RIGHT))
508 (list-para-words (map (lambda (str)
509 (regexp-split str "[ \t\n]+"))
511 (para-lines (map (lambda (words)
515 ly:stencil-empty? (map
517 (interpret-markup layout props x))
519 (lines (wordwrap-stencils stencils
528 (stack-lines DOWN 0.0 baseline-skip (apply append para-lines))))
531 (define-markup-command (wordwrap-string layout props arg) (string?)
532 "Wordwrap a string. Paragraphs may be separated with double newlines"
533 (wordwrap-string layout props #f arg))
535 (define-markup-command (justify-string layout props arg) (string?)
536 "Justify a string. Paragraphs may be separated with double newlines"
537 (wordwrap-string layout props #t arg))
540 (define-markup-command (wordwrap-field layout props symbol) (symbol?)
541 (let* ((m (chain-assoc-get symbol props)))
543 (interpret-markup layout props
544 (list wordwrap-string-markup m))
545 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
547 (define-markup-command (justify-field layout props symbol) (symbol?)
548 - (let* ((m (chain-assoc-get symbol props)))
550 (interpret-markup layout props
551 (list justify-string-markup m))
552 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
556 (define-markup-command (combine layout props m1 m2) (markup? markup?)
557 "Print two markups on top of each other."
558 (let* ((s1 (interpret-markup layout props m1))
559 (s2 (interpret-markup layout props m2)))
560 (ly:stencil-add s1 s2)))
563 ;; TODO: should extract baseline-skip from each argument somehow..
565 (define-markup-command (column layout props args) (markup-list?)
566 "Stack the markups in @var{args} vertically. The property
567 @code{baseline-skip} determines the space between each markup in @var{args}."
570 ((arg-stencils (map (lambda (m) (interpret-markup layout props m)) args))
571 (skip (chain-assoc-get 'baseline-skip props)))
576 (remove ly:stencil-empty? arg-stencils))))
579 (define-markup-command (dir-column layout props args) (markup-list?)
580 "Make a column of args, going up or down, depending on the setting
581 of the @code{#'direction} layout property."
582 (let* ((dir (chain-assoc-get 'direction props)))
584 (if (number? dir) dir -1)
586 (chain-assoc-get 'baseline-skip props)
587 (map (lambda (x) (interpret-markup layout props x)) args))))
589 (define-markup-command (center-align layout props args) (markup-list?)
590 "Put @code{args} in a centered column. "
591 (let* ((mols (map (lambda (x) (interpret-markup layout props x)) args))
592 (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols)))
594 (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) cmols)))
596 (define-markup-command (vcenter layout props arg) (markup?)
597 "Align @code{arg} to its Y center. "
598 (let* ((mol (interpret-markup layout props arg)))
599 (ly:stencil-aligned-to mol Y CENTER)))
601 (define-markup-command (hcenter layout props arg) (markup?)
602 "Align @code{arg} to its X center. "
603 (let* ((mol (interpret-markup layout props arg)))
604 (ly:stencil-aligned-to mol X CENTER)))
606 (define-markup-command (right-align layout props arg) (markup?)
607 "Align @var{arg} on its right edge. "
608 (let* ((m (interpret-markup layout props arg)))
609 (ly:stencil-aligned-to m X RIGHT)))
611 (define-markup-command (left-align layout props arg) (markup?)
612 "Align @var{arg} on its left edge. "
613 (let* ((m (interpret-markup layout props arg)))
614 (ly:stencil-aligned-to m X LEFT)))
616 (define-markup-command (general-align layout props axis dir arg) (integer? number? markup?)
617 "Align @var{arg} in @var{axis} direction to the @var{dir} side."
618 (let* ((m (interpret-markup layout props arg)))
619 (ly:stencil-aligned-to m axis dir)))
621 (define-markup-command (halign layout props dir arg) (number? markup?)
622 "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
623 left-aligned, while @code{+1} is right. Values in between interpolate
624 alignment accordingly."
625 (let* ((m (interpret-markup layout props arg)))
626 (ly:stencil-aligned-to m X dir)))
630 (define-markup-command (with-dimensions layout props x y arg) (number-pair? number-pair? markup?)
631 "Set the dimensions of @var{arg} to @var{x} and @var{y}."
633 (let* ((m (interpret-markup layout props arg)))
634 (ly:make-stencil (ly:stencil-expr m) x y)))
637 (define-markup-command (pad-around layout props amount arg) (number? markup?)
639 "Add padding @var{amount} all around @var{arg}. "
642 ((m (interpret-markup layout props arg))
643 (x (ly:stencil-extent m X))
644 (y (ly:stencil-extent m Y)))
647 (ly:make-stencil (ly:stencil-expr m)
648 (interval-widen x amount)
649 (interval-widen y amount))
653 (define-markup-command (pad-x layout props amount arg) (number? markup?)
655 "Add padding @var{amount} around @var{arg} in the X-direction. "
657 ((m (interpret-markup layout props arg))
658 (x (ly:stencil-extent m X))
659 (y (ly:stencil-extent m Y)))
662 (ly:make-stencil (ly:stencil-expr m)
663 (interval-widen x amount)
668 (define-markup-command (put-adjacent layout props arg1 axis dir arg2) (markup? integer? ly:dir? markup?)
670 "Put @var{arg2} next to @var{arg1}, without moving @var{arg1}. "
672 (let* ((m1 (interpret-markup layout props arg1))
673 (m2 (interpret-markup layout props arg2)))
675 (ly:stencil-combine-at-edge m1 axis dir m2 0.0 0.0)
678 (define-markup-command (transparent layout props arg) (markup?)
679 "Make the argument transparent"
681 ((m (interpret-markup layout props arg))
682 (x (ly:stencil-extent m X))
683 (y (ly:stencil-extent m Y)))
691 (define-markup-command (pad-to-box layout props x-ext y-ext arg)
692 (number-pair? number-pair? markup?)
693 "Make @var{arg} take at least @var{x-ext}, @var{y-ext} space"
696 ((m (interpret-markup layout props arg))
697 (x (ly:stencil-extent m X))
698 (y (ly:stencil-extent m Y)))
700 (ly:make-stencil (ly:stencil-expr m)
701 (interval-union x-ext x)
702 (interval-union y-ext y))))
705 (define-markup-command (hcenter-in layout props length arg)
707 "Center @var{arg} horizontally within a box of extending
708 @var{length}/2 to the left and right."
710 (interpret-markup layout props
711 (make-pad-to-box-markup
712 (cons (/ length -2) (/ length 2))
714 (make-hcenter-markup arg))))
717 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
719 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
721 (define-markup-command (fromproperty layout props symbol) (symbol?)
722 "Read the @var{symbol} from property settings, and produce a stencil
723 from the markup contained within. If @var{symbol} is not defined, it
724 returns an empty markup"
725 (let* ((m (chain-assoc-get symbol props)))
727 (interpret-markup layout props m)
728 (ly:make-stencil '() '(1 . -1) '(1 . -1)))))
731 (define-markup-command (on-the-fly layout props procedure arg) (symbol? markup?)
732 "Apply the @var{procedure} markup command to
733 @var{arg}. @var{procedure} should take a single argument."
734 (let* ((anonymous-with-signature (lambda (layout props arg) (procedure layout props arg))))
735 (set-object-property! anonymous-with-signature
738 (interpret-markup layout props (list anonymous-with-signature arg))))
742 (define-markup-command (override layout props new-prop arg) (pair? markup?)
743 "Add the first argument in to the property list. Properties may be
744 any sort of property supported by @internalsref{font-interface} and
745 @internalsref{text-interface}, for example
748 \\override #'(font-family . married) \"bla\"
752 (interpret-markup layout (cons (list new-prop) props) arg))
754 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
756 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
758 (define-markup-command (verbatim-file layout props name) (string?)
759 "Read the contents of a file, and include verbatimly"
763 (if (ly:get-option 'safe)
764 "verbatim-file disabled in safe mode"
766 ((str (ly:gulp-file name))
767 (lines (string-split str #\nl)))
769 (make-typewriter-markup
770 (make-column-markup lines)))
773 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
775 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
778 (define-markup-command (bigger layout props arg) (markup?)
779 "Increase the font size relative to current setting"
780 (interpret-markup layout props
781 `(,fontsize-markup 1 ,arg)))
783 (define-markup-command (smaller layout props arg) (markup?)
784 "Decrease the font size relative to current setting"
785 (interpret-markup layout props
786 `(,fontsize-markup -1 ,arg)))
788 (define-markup-command larger (markup?) bigger-markup)
790 (define-markup-command (finger layout props arg) (markup?)
791 "Set the argument as small numbers."
792 (interpret-markup layout
793 (cons '((font-size . -5) (font-encoding . fetaNumber)) props)
797 (define-markup-command (fontsize layout props increment arg) (number? markup?)
798 "Add @var{increment} to the font-size. Adjust baseline skip accordingly."
800 (let* ((fs (chain-assoc-get 'font-size props 0))
801 (bs (chain-assoc-get 'baseline-skip props 2))
803 (cons 'baseline-skip (* bs (magstep increment)))
804 (cons 'font-size (+ fs increment )))))
806 (interpret-markup layout (cons entries props) arg)))
810 ;; FIXME -> should convert to font-size.
811 (define-markup-command (magnify layout props sz arg) (number? markup?)
812 "Set the font magnification for the its argument. In the following
813 example, the middle A will be 10% larger:
815 A \\magnify #1.1 @{ A @} A
818 Note: magnification only works if a font-name is explicitly selected.
819 Use @code{\\fontsize} otherwise."
822 (prepend-alist-chain 'font-magnification sz props)
825 (define-markup-command (bold layout props arg) (markup?)
826 "Switch to bold font-series"
827 (interpret-markup layout (prepend-alist-chain 'font-series 'bold props) arg))
829 (define-markup-command (sans layout props arg) (markup?)
830 "Switch to the sans serif family"
831 (interpret-markup layout (prepend-alist-chain 'font-family 'sans props) arg))
833 (define-markup-command (number layout props arg) (markup?)
834 "Set font family to @code{number}, which yields the font used for
835 time signatures and fingerings. This font only contains numbers and
836 some punctuation. It doesn't have any letters. "
837 (interpret-markup layout (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
839 (define-markup-command (roman layout props arg) (markup?)
840 "Set font family to @code{roman}."
841 (interpret-markup layout (prepend-alist-chain 'font-family 'roman props) arg))
843 (define-markup-command (huge layout props arg) (markup?)
844 "Set font size to +2."
845 (interpret-markup layout (prepend-alist-chain 'font-size 2 props) arg))
847 (define-markup-command (large layout props arg) (markup?)
848 "Set font size to +1."
849 (interpret-markup layout (prepend-alist-chain 'font-size 1 props) arg))
851 (define-markup-command (normalsize layout props arg) (markup?)
852 "Set font size to default."
853 (interpret-markup layout (prepend-alist-chain 'font-size 0 props) arg))
855 (define-markup-command (small layout props arg) (markup?)
856 "Set font size to -1."
857 (interpret-markup layout (prepend-alist-chain 'font-size -1 props) arg))
859 (define-markup-command (tiny layout props arg) (markup?)
860 "Set font size to -2."
861 (interpret-markup layout (prepend-alist-chain 'font-size -2 props) arg))
863 (define-markup-command (teeny layout props arg) (markup?)
864 "Set font size to -3."
865 (interpret-markup layout (prepend-alist-chain 'font-size -3 props) arg))
867 (define-markup-command (caps layout props arg) (markup?)
868 "Set @code{font-shape} to @code{caps}."
869 (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg))
872 (define-markup-command (smallCaps layout props text) (markup?)
873 "Turn @code{text}, which should be a string, to small caps.
875 \\markup \\smallCaps \"Text between double quotes\"
878 (define (make-small-caps-markup chars)
881 ((char-whitespace? (car chars))
882 (markup #:fontsize -2 #:simple (string-upcase (list->string (cdr chars)))))
885 #:fontsize -2 #:simple (string-upcase (list->string chars))))))
886 (define (make-not-small-caps-markup chars)
889 ((char-whitespace? (car chars))
890 (markup #:simple (list->string (cdr chars))))
893 #:simple (list->string chars)))))
894 (define (small-caps-aux done-markups current-chars rest-chars small? after-space?)
895 (cond ((null? rest-chars)
896 ;; the end of the string: build the markup
897 (make-line-markup (reverse! (cons ((if small?
898 make-small-caps-markup
899 make-not-small-caps-markup)
900 (reverse! current-chars))
902 ((char-whitespace? (car rest-chars))
904 (small-caps-aux done-markups current-chars (cdr rest-chars) small? #t))
905 ((or (and small? (char-lower-case? (car rest-chars)))
906 (and (not small?) (not (char-lower-case? (car rest-chars)))))
908 ;; add the char to the current char list
909 (small-caps-aux done-markups
910 (cons (car rest-chars)
912 (cons #\space current-chars)
919 ;; make a markup with current chars, and start a new list with new char
920 (small-caps-aux (cons ((if small?
921 make-small-caps-markup
922 make-not-small-caps-markup)
923 (reverse! current-chars))
926 (list (car rest-chars) #\space)
927 (list (car rest-chars)))
931 (interpret-markup layout props (small-caps-aux (list)
933 (cons #\space (string->list text))
937 (define-markup-command (dynamic layout props arg) (markup?)
938 "Use the dynamic font. This font only contains @b{s}, @b{f}, @b{m},
939 @b{z}, @b{p}, and @b{r}. When producing phrases, like ``pi@`{u} @b{f}'', the
940 normal words (like ``pi@`{u}'') should be done in a different font. The
941 recommend font for this is bold and italic"
943 layout (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
945 (define-markup-command (text layout props arg) (markup?)
946 "Use a text font instead of music symbol or music alphabet font."
949 (interpret-markup layout (prepend-alist-chain 'font-encoding 'latin1 props)
953 (define-markup-command (italic layout props arg) (markup?)
954 "Use italic @code{font-shape} for @var{arg}. "
955 (interpret-markup layout (prepend-alist-chain 'font-shape 'italic props) arg))
957 (define-markup-command (typewriter layout props arg) (markup?)
958 "Use @code{font-family} typewriter for @var{arg}."
960 layout (prepend-alist-chain 'font-family 'typewriter props) arg))
962 (define-markup-command (upright layout props arg) (markup?)
963 "Set font shape to @code{upright}. This is the opposite of @code{italic}."
965 layout (prepend-alist-chain 'font-shape 'upright props) arg))
967 (define-markup-command (medium layout props arg) (markup?)
968 "Switch to medium font-series (in contrast to bold)."
969 (interpret-markup layout (prepend-alist-chain 'font-series 'medium props)
972 (define-markup-command (normal-text layout props arg) (markup?)
973 "Set all font related properties (except the size) to get the default normal text font, no matter what font was used earlier."
975 (interpret-markup layout
976 (cons '((font-family . roman) (font-shape . upright)
977 (font-series . medium) (font-encoding . latin1))
981 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
983 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
985 (define-markup-command (doublesharp layout props) ()
986 "Draw a double sharp symbol."
988 (interpret-markup layout props (markup #:musicglyph "accidentals.4")))
990 (define-markup-command (sesquisharp layout props) ()
991 "Draw a 3/2 sharp symbol."
992 (interpret-markup layout props (markup #:musicglyph "accidentals.3")))
994 (define-markup-command (sharp layout props) ()
995 "Draw a sharp symbol."
996 (interpret-markup layout props (markup #:musicglyph "accidentals.2")))
998 (define-markup-command (semisharp layout props) ()
999 "Draw a semi sharp symbol."
1000 (interpret-markup layout props (markup #:musicglyph "accidentals.1")))
1002 (define-markup-command (natural layout props) ()
1003 "Draw a natural symbol."
1004 (interpret-markup layout props (markup #:musicglyph "accidentals.0")))
1006 (define-markup-command (semiflat layout props) ()
1008 (interpret-markup layout props (markup #:musicglyph "accidentals.M1")))
1010 (define-markup-command (flat layout props) ()
1011 "Draw a flat symbol."
1012 (interpret-markup layout props (markup #:musicglyph "accidentals.M2")))
1014 (define-markup-command (sesquiflat layout props) ()
1015 "Draw a 3/2 flat symbol."
1016 (interpret-markup layout props (markup #:musicglyph "accidentals.M3")))
1018 (define-markup-command (doubleflat layout props) ()
1019 "Draw a double flat symbol."
1020 (interpret-markup layout props (markup #:musicglyph "accidentals.M4")))
1022 (define-markup-command (with-color layout props color arg) (color? markup?)
1023 "Draw @var{arg} in color specified by @var{color}"
1025 (let* ((stil (interpret-markup layout props arg)))
1027 (ly:make-stencil (list 'color color (ly:stencil-expr stil))
1028 (ly:stencil-extent stil X)
1029 (ly:stencil-extent stil Y))))
1032 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1034 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1037 (define-markup-command (arrow-head layout props axis direction filled)
1038 (integer? ly:dir? boolean?)
1039 "produce an arrow head in specified direction and axis. Use the filled head if @var{filled} is specified."
1041 ((name (format "arrowheads.~a.~a~a"
1048 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
1052 (define-markup-command (musicglyph layout props glyph-name) (string?)
1053 "This is converted to a musical symbol, e.g. @code{\\musicglyph
1054 #\"accidentals.0\"} will select the natural sign from the music font.
1055 See @usermanref{The Feta font} for a complete listing of the possible glyphs."
1057 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
1061 (define-markup-command (lookup layout props glyph-name) (string?)
1062 "Lookup a glyph by name."
1063 (ly:font-get-glyph (ly:paper-get-font layout props)
1066 (define-markup-command (char layout props num) (integer?)
1067 "Produce a single character, e.g. @code{\\char #65} produces the
1069 (ly:get-glyph (ly:paper-get-font layout props) num))
1072 (define number->mark-letter-vector (make-vector 25 #\A))
1077 (if (= i (- (char->integer #\I) (char->integer #\A)))
1079 (vector-set! number->mark-letter-vector j
1080 (integer->char (+ i (char->integer #\A)))))
1082 (define number->mark-alphabet-vector (list->vector
1083 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
1085 (define (number->markletter-string vec n)
1086 "Double letters for big marks."
1087 (let* ((lst (vector-length vec)))
1090 (string-append (number->markletter-string vec (1- (quotient n lst)))
1091 (number->markletter-string vec (remainder n lst)))
1092 (make-string 1 (vector-ref vec n)))))
1094 (define-markup-command (markletter layout props num) (integer?)
1095 "Make a markup letter for @var{num}. The letters start with A to Z
1096 (skipping I), and continues with double letters."
1097 (ly:text-interface::interpret-markup layout props
1098 (number->markletter-string number->mark-letter-vector num)))
1100 (define-markup-command (markalphabet layout props num) (integer?)
1101 "Make a markup letter for @var{num}. The letters start with A to Z
1102 and continues with double letters."
1103 (ly:text-interface::interpret-markup layout props
1104 (number->markletter-string number->mark-alphabet-vector num)))
1108 (define-markup-command (slashed-digit layout props num) (integer?)
1109 "A feta number, with slash. This is for use in the context of
1110 figured bass notation"
1112 ((mag (magstep (chain-assoc-get 'font-size props 0)))
1115 (chain-assoc-get 'thickness props 0.16)))
1117 (number-stencil (interpret-markup layout
1118 (prepend-alist-chain 'font-encoding 'fetaNumber props)
1119 (number->string num)))
1120 (num-x (interval-widen (ly:stencil-extent number-stencil X)
1122 (num-y (ly:stencil-extent number-stencil Y))
1127 ,(car num-x) ,(- (interval-center num-y) dy)
1128 ,(cdr num-x) ,(+ (interval-center num-y) dy))
1132 (ly:stencil-add number-stencil
1134 ((= num 5) (ly:stencil-translate slash-stencil
1135 ;;(cons (* mag -0.05) (* mag 0.42))
1136 (cons (* mag -0.00) (* mag -0.07))
1139 ((= num 7) (ly:stencil-translate slash-stencil
1140 ;;(cons (* mag -0.05) (* mag 0.42))
1141 (cons (* mag -0.00) (* mag -0.15))
1145 (else slash-stencil)))
1148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1149 ;; the note command.
1150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1153 ;; TODO: better syntax.
1155 (define-markup-command (note-by-number layout props log dot-count dir) (number? number? number?)
1156 "Construct a note symbol, with stem. By using fractional values for
1157 @var{dir}, you can obtain longer or shorter stems."
1158 (define (get-glyph-name-candidates dir log style)
1159 (map (lambda (dir-name)
1160 (format "noteheads.~a~a~a" dir-name (min log 2)
1161 (if (and (symbol? style)
1162 (not (equal? 'default style)))
1163 (symbol->string style)
1165 (list (if (= dir UP) "u" "d")
1168 (define (get-glyph-name font cands)
1171 (if (ly:stencil-empty? (ly:font-get-glyph font (car cands)))
1172 (get-glyph-name font (cdr cands))
1175 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
1176 (size-factor (magstep (chain-assoc-get 'font-size props 0)))
1177 (style (chain-assoc-get 'style props '()))
1178 (stem-length (* size-factor (max 3 (- log 1))))
1179 (head-glyph-name (get-glyph-name font (get-glyph-name-candidates dir log style)))
1180 (head-glyph (ly:font-get-glyph font head-glyph-name))
1181 (attach-indices (ly:note-head::stem-attachment font head-glyph-name))
1182 (stem-thickness (* size-factor 0.13))
1183 (stemy (* dir stem-length))
1184 (attach-off (cons (interval-index
1185 (ly:stencil-extent head-glyph X)
1186 (* dir (car attach-indices)))
1187 (* dir ; fixme, this is inconsistent between X & Y.
1189 (ly:stencil-extent head-glyph Y)
1190 (cdr attach-indices)))))
1191 (stem-glyph (and (> log 0)
1192 (ly:round-filled-box
1193 (ordered-cons (car attach-off)
1194 (+ (car attach-off) (* (- dir) stem-thickness)))
1195 (cons (min stemy (cdr attach-off))
1196 (max stemy (cdr attach-off)))
1197 (/ stem-thickness 3))))
1199 (dot (ly:font-get-glyph font "dots.dot"))
1200 (dotwid (interval-length (ly:stencil-extent dot X)))
1201 (dots (and (> dot-count 0)
1202 (apply ly:stencil-add
1204 (ly:stencil-translate-axis
1205 dot (* (+ 1 (* 2 x)) dotwid) X))
1206 (iota dot-count 1)))))
1207 (flaggl (and (> log 2)
1208 (ly:stencil-translate
1209 (ly:font-get-glyph font
1210 (string-append "flags."
1211 (if (> dir 0) "u" "d")
1212 (number->string log)))
1213 (cons (+ (car attach-off) (/ stem-thickness 2)) stemy)))))
1215 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
1216 (if (ly:stencil? stem-glyph)
1217 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
1218 (set! stem-glyph head-glyph))
1219 (if (ly:stencil? dots)
1222 (ly:stencil-translate-axis
1224 (+ (if (and (> dir 0) (> log 2))
1227 ;; huh ? why not necessary?
1228 ;;(cdr (ly:stencil-extent head-glyph X))
1235 (let ((divisor (log 2)))
1236 (lambda (z) (inexact->exact (/ (log z) divisor)))))
1238 (define (parse-simple-duration duration-string)
1239 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
1240 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
1241 (if (and match (string=? duration-string (match:substring match 0)))
1242 (let ((len (match:substring match 1))
1243 (dots (match:substring match 2)))
1244 (list (cond ((string=? len "breve") -1)
1245 ((string=? len "longa") -2)
1246 ((string=? len "maxima") -3)
1247 (else (log2 (string->number len))))
1248 (if dots (string-length dots) 0)))
1249 (ly:error (_ "not a valid duration string: ~a") duration-string))))
1251 (define-markup-command (note layout props duration dir) (string? number?)
1252 "This produces a note with a stem pointing in @var{dir} direction, with
1253 the @var{duration} for the note head type and augmentation dots. For
1254 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
1255 a shortened down stem."
1256 (let ((parsed (parse-simple-duration duration)))
1257 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
1260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1262 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1264 (define-markup-command (lower layout props amount arg) (number? markup?)
1266 Lower @var{arg}, by the distance @var{amount}.
1267 A negative @var{amount} indicates raising, see also @code{\\raise}.
1269 (ly:stencil-translate-axis (interpret-markup layout props arg)
1273 (define-markup-command (translate-scaled layout props offset arg) (number-pair? markup?)
1274 "Translate @var{arg} by @var{offset}, scaling the offset by the @code{font-size}."
1277 ((factor (magstep (chain-assoc-get 'font-size props 0)))
1278 (scaled (cons (* factor (car offset))
1279 (* factor (cdr offset)))))
1281 (ly:stencil-translate (interpret-markup layout props arg)
1284 (define-markup-command (raise layout props amount arg) (number? markup?)
1286 Raise @var{arg}, by the distance @var{amount}.
1287 A negative @var{amount} indicates lowering, see also @code{\\lower}.
1289 @lilypond[verbatim,fragment,relative=1]
1290 c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
1292 The argument to @code{\\raise} is the vertical displacement amount,
1293 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
1294 raise objects in relation to their surrounding markups.
1296 If the text object itself is positioned above or below the staff, then
1297 @code{\\raise} cannot be used to move it, since the mechanism that
1298 positions it next to the staff cancels any shift made with
1299 @code{\\raise}. For vertical positioning, use the @code{padding}
1300 and/or @code{extra-offset} properties. "
1301 (ly:stencil-translate-axis (interpret-markup layout props arg) amount Y))
1303 (define-markup-command (fraction layout props arg1 arg2) (markup? markup?)
1304 "Make a fraction of two markups."
1305 (let* ((m1 (interpret-markup layout props arg1))
1306 (m2 (interpret-markup layout props arg2)))
1307 (set! m1 (ly:stencil-aligned-to m1 X CENTER))
1308 (set! m2 (ly:stencil-aligned-to m2 X CENTER))
1309 (let* ((x1 (ly:stencil-extent m1 X))
1310 (x2 (ly:stencil-extent m2 X))
1311 (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
1312 ;; should stack mols separately, to maintain LINE on baseline
1313 (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
1315 (ly:stencil-aligned-to stack Y CENTER))
1317 (ly:stencil-aligned-to stack X LEFT))
1318 ;; should have EX dimension
1320 (ly:stencil-translate-axis stack 0.75 Y))))
1326 (define-markup-command (normal-size-super layout props arg) (markup?)
1327 "Set @var{arg} in superscript with a normal font size."
1328 (ly:stencil-translate-axis
1329 (interpret-markup layout props arg)
1330 (* 0.5 (chain-assoc-get 'baseline-skip props)) Y))
1332 (define-markup-command (super layout props arg) (markup?)
1334 @cindex raising text
1335 @cindex lowering text
1337 @cindex translating text
1339 @cindex @code{\\super}
1342 Raising and lowering texts can be done with @code{\\super} and
1345 @lilypond[verbatim,fragment,relative=1]
1346 c1^\\markup { E \"=\" mc \\super \"2\" }
1350 (ly:stencil-translate-axis
1353 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
1355 (* 0.5 (chain-assoc-get 'baseline-skip props))
1358 (define-markup-command (translate layout props offset arg) (number-pair? markup?)
1359 "This translates an object. Its first argument is a cons of numbers
1361 A \\translate #(cons 2 -3) @{ B C @} D
1363 This moves `B C' 2 spaces to the right, and 3 down, relative to its
1364 surroundings. This command cannot be used to move isolated scripts
1365 vertically, for the same reason that @code{\\raise} cannot be used for
1369 (ly:stencil-translate (interpret-markup layout props arg)
1372 (define-markup-command (sub layout props arg) (markup?)
1373 "Set @var{arg} in subscript."
1374 (ly:stencil-translate-axis
1377 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
1379 (* -0.5 (chain-assoc-get 'baseline-skip props))
1382 (define-markup-command (normal-size-sub layout props arg) (markup?)
1383 "Set @var{arg} in subscript, in a normal font size."
1384 (ly:stencil-translate-axis
1385 (interpret-markup layout props arg)
1386 (* -0.5 (chain-assoc-get 'baseline-skip props))
1389 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1391 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1393 (define-markup-command (hbracket layout props arg) (markup?)
1394 "Draw horizontal brackets around @var{arg}."
1395 (let ((th 0.1) ;; todo: take from GROB.
1396 (m (interpret-markup layout props arg)))
1397 (bracketify-stencil m X th (* 2.5 th) th)))
1399 (define-markup-command (bracket layout props arg) (markup?)
1400 "Draw vertical brackets around @var{arg}."
1401 (let ((th 0.1) ;; todo: take from GROB.
1402 (m (interpret-markup layout props arg)))
1403 (bracketify-stencil m Y th (* 2.5 th) th)))
1405 (define-markup-command (bracketed-y-column layout props indices args)
1406 (list? markup-list?)
1407 "Make a column of the markups in @var{args}, putting brackets around
1408 the elements marked in @var{indices}, which is a list of numbers.
1412 ;; DROPME? This command is a relic from the old figured bass implementation.
1415 (define (sublist lst start stop)
1416 (take (drop lst start) (- (1+ stop) start)))
1418 (define (stencil-list-extent ss axis)
1420 (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
1421 (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
1424 (define (stack-stencils-vertically stencils bskip last-stencil)
1426 ((null? stencils) '())
1427 ((not (ly:stencil? last-stencil))
1428 (cons (car stencils)
1429 (stack-stencils-vertically (cdr stencils) bskip (car stencils))))
1431 (let* ((orig (car stencils))
1432 (dir (chain-assoc-get 'direction props DOWN))
1433 (new (ly:stencil-moved-to-edge last-stencil Y dir
1437 (cons new (stack-stencils-vertically (cdr stencils) bskip new))))))
1439 (define (make-brackets stencils indices acc)
1442 (pair? (cdr indices)))
1443 (let* ((encl (sublist stencils (car indices) (cadr indices)))
1444 (x-ext (stencil-list-extent encl X))
1445 (y-ext (stencil-list-extent encl Y))
1448 (protusion (* 2.5 thick))
1450 (ly:stencil-translate-axis
1451 (ly:bracket Y y-ext thick protusion)
1452 (- (car x-ext) pad) X))
1453 (rb (ly:stencil-translate-axis
1454 (ly:bracket Y y-ext thick (- protusion))
1455 (+ (cdr x-ext) pad) X)))
1458 stencils (cddr indices)
1471 (chain-assoc-get 'baseline-skip props))
1472 (stacked (stack-stencils-vertically
1473 (remove ly:stencil-empty? stencils) 1.25 #f))
1474 (brackets (make-brackets stacked indices '())))
1476 (apply ly:stencil-add
1477 (append stacked brackets))))
1480 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1481 ;; size indications arrow
1482 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;