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 Y center. "
336 (let* ((mol (interpret-markup layout props arg)))
337 (ly:stencil-align-to! mol Y CENTER)
340 (def-markup-command (hcenter layout props arg) (markup?)
341 "Align @code{arg} to its X center. "
342 (let* ((mol (interpret-markup layout props arg)))
343 (ly:stencil-align-to! mol X CENTER)
346 (def-markup-command (right-align layout props arg) (markup?)
347 "Align @var{arg} on its right edge. "
348 (let* ((m (interpret-markup layout props arg)))
349 (ly:stencil-align-to! m X RIGHT)
352 (def-markup-command (left-align layout props arg) (markup?)
353 "Align @var{arg} on its left edge. "
354 (let* ((m (interpret-markup layout props arg)))
355 (ly:stencil-align-to! m X LEFT)
358 (def-markup-command (general-align layout props axis dir arg) (integer? number? markup?)
359 "Align @var{arg} in @var{axis} direction to the @var{dir} side."
360 (let* ((m (interpret-markup layout props arg)))
361 (ly:stencil-align-to! m axis dir)
364 (def-markup-command (halign layout props dir arg) (number? markup?)
365 "Set horizontal alignment. If @var{dir} is @code{-1}, then it is
366 left-aligned, while @code{+1} is right. Values in between interpolate
367 alignment accordingly."
368 (let* ((m (interpret-markup layout props arg)))
369 (ly:stencil-align-to! m X dir)
372 (def-markup-command (musicglyph layout props glyph-name) (string?)
373 "This is converted to a musical symbol, e.g. @code{\\musicglyph
374 #\"accidentals.0\"} will select the natural sign from the music font.
375 See @usermanref{The Feta font} for a complete listing of the possible glyphs."
377 (ly:paper-get-font layout (cons '((font-encoding . fetaMusic))
381 (def-markup-command (lookup layout props glyph-name) (string?)
382 "Lookup a glyph by name."
383 (ly:font-get-glyph (ly:paper-get-font layout props)
386 (def-markup-command (char layout props num) (integer?)
387 "Produce a single character, e.g. @code{\\char #65} produces the
389 (ly:get-glyph (ly:paper-get-font layout props) num))
391 (def-markup-command (raise layout props amount arg) (number? markup?)
393 This raises @var{arg}, by the distance @var{amount}.
394 A negative @var{amount} indicates lowering:
396 @lilypond[verbatim,fragment,relative=1]
397 c1^\\markup { C \\small \\raise #1.0 \\bold { \"9/7+\" }}
399 The argument to @code{\\raise} is the vertical displacement amount,
400 measured in (global) staff spaces. @code{\\raise} and @code{\\super}
401 raise objects in relation to their surrounding markups.
403 If the text object itself is positioned above or below the staff, then
404 @code{\\raise} cannot be used to move it, since the mechanism that
405 positions it next to the staff cancels any shift made with
406 @code{\\raise}. For vertical positioning, use the @code{padding}
407 and/or @code{extra-offset} properties. "
408 (ly:stencil-translate-axis (interpret-markup layout props arg)
411 (def-markup-command (fraction layout props arg1 arg2) (markup? markup?)
412 "Make a fraction of two markups."
413 (let* ((m1 (interpret-markup layout props arg1))
414 (m2 (interpret-markup layout props arg2)))
415 (ly:stencil-align-to! m1 X CENTER)
416 (ly:stencil-align-to! m2 X CENTER)
417 (let* ((x1 (ly:stencil-extent m1 X))
418 (x2 (ly:stencil-extent m2 X))
419 (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
420 ;; should stack mols separately, to maintain LINE on baseline
421 (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
422 (ly:stencil-align-to! stack Y CENTER)
423 (ly:stencil-align-to! stack X LEFT)
424 ;; should have EX dimension
426 (ly:stencil-translate-axis stack 0.75 Y))))
429 ;; TODO: better syntax.
431 (def-markup-command (note-by-number layout props log dot-count dir) (number? number? number?)
432 "Construct a note symbol, with stem. By using fractional values for
433 @var{dir}, you can obtain longer or shorter stems."
434 (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)))
435 (size (chain-assoc-get 'font-size props 0))
436 (stem-length (* (magstep size) (max 3 (- log 1))))
437 (head-glyph (ly:font-get-glyph
439 (string-append "noteheads.s" (number->string (min log 2)))))
440 (stem-thickness 0.13)
441 (stemy (* dir stem-length))
442 (attachx (if (> dir 0)
443 (- (cdr (ly:stencil-extent head-glyph X)) stem-thickness)
445 (attachy (* dir 0.28))
446 (stem-glyph (and (> log 0)
448 (cons attachx (+ attachx stem-thickness))
449 (cons (min stemy attachy)
451 (/ stem-thickness 3))))
452 (dot (ly:font-get-glyph font "dots-dot"))
453 (dotwid (interval-length (ly:stencil-extent dot X)))
454 (dots (and (> dot-count 0)
455 (apply ly:stencil-add
457 (ly:stencil-translate-axis
458 dot (* (+ 1 (* 2 x)) dotwid) X))
459 (iota dot-count 1)))))
460 (flaggl (and (> log 2)
461 (ly:stencil-translate
462 (ly:font-get-glyph font
463 (string-append "flags."
464 (if (> dir 0) "u" "d")
465 (number->string log)))
466 (cons (+ attachx (/ stem-thickness 2)) stemy)))))
468 (set! stem-glyph (ly:stencil-add flaggl stem-glyph)))
469 (if (ly:stencil? stem-glyph)
470 (set! stem-glyph (ly:stencil-add stem-glyph head-glyph))
471 (set! stem-glyph head-glyph))
472 (if (ly:stencil? dots)
475 (ly:stencil-translate-axis dots
476 (+ (if (and (> dir 0) (> log 2))
479 ;; huh ? why not necessary?
480 ;;(cdr (ly:stencil-extent head-glyph X))
486 (use-modules (ice-9 regex))
489 (let ((divisor (log 2)))
490 (lambda (z) (inexact->exact (/ (log z) divisor)))))
492 (define (parse-simple-duration duration-string)
493 "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
494 (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
495 (if (and match (string=? duration-string (match:substring match 0)))
496 (let ((len (match:substring match 1))
497 (dots (match:substring match 2)))
498 (list (cond ((string=? len "breve") -1)
499 ((string=? len "longa") -2)
500 ((string=? len "maxima") -3)
501 (else (log2 (string->number len))))
502 (if dots (string-length dots) 0)))
503 (error "This is not a valid duration string:" duration-string))))
505 (def-markup-command (note layout props duration dir) (string? number?)
506 "This produces a note with a stem pointing in @var{dir} direction, with
507 the @var{duration} for the note head type and augmentation dots. For
508 example, @code{\\note #\"4.\" #-0.75} creates a dotted quarter note, with
509 a shortened down stem."
510 (let ((parsed (parse-simple-duration duration)))
511 (note-by-number-markup layout props (car parsed) (cadr parsed) dir)))
513 (def-markup-command (normal-size-super layout props arg) (markup?)
514 "Set @var{arg} in superscript with a normal font size."
515 (ly:stencil-translate-axis (interpret-markup
518 (* 0.5 (chain-assoc-get 'baseline-skip props))
521 (def-markup-command (super layout props arg) (markup?)
524 @cindex lowering text
526 @cindex translating text
528 @cindex @code{\\super}
531 Raising and lowering texts can be done with @code{\\super} and
534 @lilypond[verbatim,fragment,relative=1]
535 c1^\\markup { E \"=\" mc \\super \"2\" }
539 (ly:stencil-translate-axis
542 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
544 (* 0.5 (chain-assoc-get 'baseline-skip props))
547 (def-markup-command (translate layout props offset arg) (number-pair? markup?)
548 "This translates an object. Its first argument is a cons of numbers
550 A \\translate #(cons 2 -3) @{ B C @} D
552 This moves `B C' 2 spaces to the right, and 3 down, relative to its
553 surroundings. This command cannot be used to move isolated scripts
554 vertically, for the same reason that @code{\\raise} cannot be used for
558 (ly:stencil-translate (interpret-markup layout props arg)
561 (def-markup-command (sub layout props arg) (markup?)
562 "Set @var{arg} in subscript."
563 (ly:stencil-translate-axis
566 (cons `((font-size . ,(- (chain-assoc-get 'font-size props 0) 3))) props)
568 (* -0.5 (chain-assoc-get 'baseline-skip props))
571 (def-markup-command (beam layout props width slope thickness) (number? number? number?)
572 "Create a beam with the specified parameters."
576 (yext (cons (min 0 y) (max 0 y)))
577 (half (/ thickness 2)))
583 (ly:output-def-lookup layout 'blotdiameter))
585 (cons (+ (- half) (car yext))
586 (+ half (cdr yext))))
591 (def-markup-command (normal-size-sub layout props arg) (markup?)
592 "Set @var{arg} in subscript, in a normal font size."
593 (ly:stencil-translate-axis
594 (interpret-markup layout props arg)
595 (* -0.5 (chain-assoc-get 'baseline-skip props))
598 (def-markup-command (hbracket layout props arg) (markup?)
599 "Draw horizontal brackets around @var{arg}."
600 (let ((th 0.1) ;; todo: take from GROB.
601 (m (interpret-markup layout props arg)))
602 (bracketify-stencil m X th (* 2.5 th) th)))
604 (def-markup-command (bracket layout props arg) (markup?)
605 "Draw vertical brackets around @var{arg}."
606 (let ((th 0.1) ;; todo: take from GROB.
607 (m (interpret-markup layout props arg)))
608 (bracketify-stencil m Y th (* 2.5 th) th)))
610 ;; todo: fix negative space
611 (def-markup-command (hspace layout props amount) (number?)
612 "This produces a invisible object taking horizontal space.
614 \\markup @{ A \\hspace #2.0 B @}
616 will put extra space between A and B, on top of the space that is
617 normally inserted before elements on a line.
620 (ly:make-stencil "" (cons 0 amount) '(-1 . 1))
621 (ly:make-stencil "" (cons amount amount) '(-1 . 1))))
623 (def-markup-command (override layout props new-prop arg) (pair? markup?)
624 "Add the first argument in to the property list. Properties may be
625 any sort of property supported by @internalsref{font-interface} and
626 @internalsref{text-interface}, for example
629 \\override #'(font-family . married) \"bla\"
633 (interpret-markup layout (cons (list new-prop) props) arg))
635 (def-markup-command (smaller layout props arg) (markup?)
636 "Decrease the font size relative to current setting"
637 (let* ((fs (chain-assoc-get 'font-size props 0))
638 (entry (cons 'font-size (- fs 1))))
639 (interpret-markup layout (cons (list entry) props) arg)))
641 (def-markup-command (bigger layout props arg) (markup?)
642 "Increase the font size relative to current setting"
643 (let* ((fs (chain-assoc-get 'font-size props 0))
644 (entry (cons 'font-size (+ fs 1))))
645 (interpret-markup layout (cons (list entry) props) arg)))
647 (def-markup-command larger (markup?) bigger-markup)
649 (def-markup-command (box layout props arg) (markup?)
650 "Draw a box round @var{arg}. Looks at @code{thickness} and
651 @code{box-padding} properties to determine line thickness and padding
653 (let ((th (chain-assoc-get 'thickness props 0.1))
654 (pad (chain-assoc-get 'box-padding props 0.2))
655 (m (interpret-markup layout props arg)))
656 (box-stencil m th pad)))
658 ;;FIXME: is this working?
659 (def-markup-command (strut layout props) ()
660 "Create a box of the same height as the space in the current font."
661 (let ((m (Text_interface::interpret_markup layout props " ")))
662 (ly:stencil-set-extent! m X '(1000 . -1000))
665 (define number->mark-letter-vector (make-vector 25 #\A))
670 (if (= i (- (char->integer #\I) (char->integer #\A)))
672 (vector-set! number->mark-letter-vector j
673 (integer->char (+ i (char->integer #\A)))))
675 (define number->mark-alphabet-vector (list->vector
676 (map (lambda (i) (integer->char (+ i (char->integer #\A)))) (iota 26))))
678 (define (number->markletter-string vec n)
679 "Double letters for big marks."
680 (let* ((lst (vector-length vec)))
683 (string-append (number->markletter-string vec (1- (quotient n lst)))
684 (number->markletter-string vec (remainder n lst)))
685 (make-string 1 (vector-ref vec n)))))
687 (def-markup-command (markletter layout props num) (integer?)
688 "Make a markup letter for @var{num}. The letters start with A to Z
689 (skipping I), and continues with double letters."
690 (Text_interface::interpret_markup layout props
691 (number->markletter-string number->mark-letter-vector num)))
693 (def-markup-command (markalphabet layout props num) (integer?)
694 "Make a markup letter for @var{num}. The letters start with A to Z
695 and continues with double letters."
696 (Text_interface::interpret_markup layout props
697 (number->markletter-string number->mark-alphabet-vector num)))
699 (def-markup-command (bracketed-y-column layout props indices args)
701 "Make a column of the markups in @var{args}, putting brackets around
702 the elements marked in @var{indices}, which is a list of numbers."
703 (define (sublist lst start stop)
704 (take (drop lst start) (- (1+ stop) start)))
706 (define (stencil-list-extent ss axis)
708 (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss))
709 (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss))))
711 (define (stack-stencils stencils bskip last-stencil)
713 ((null? stencils) '())
714 ((not (ly:stencil? last-stencil))
716 (stack-stencils (cdr stencils) bskip (car stencils))))
718 (let* ((orig (car stencils))
719 (dir (chain-assoc-get 'direction props DOWN))
720 (new (ly:stencil-moved-to-edge last-stencil Y dir
724 (cons new (stack-stencils (cdr stencils) bskip new))))))
726 (define (make-brackets stencils indices acc)
729 (pair? (cdr indices)))
730 (let* ((encl (sublist stencils (car indices) (cadr indices)))
731 (x-ext (stencil-list-extent encl X))
732 (y-ext (stencil-list-extent encl Y))
735 (protusion (* 2.5 thick))
737 (ly:stencil-translate-axis
738 (ly:bracket Y y-ext thick protusion)
739 (- (car x-ext) pad) X))
740 (rb (ly:stencil-translate-axis
741 (ly:bracket Y y-ext thick (- protusion))
742 (+ (cdr x-ext) pad) X)))
745 stencils (cddr indices)
758 (chain-assoc-get 'baseline-skip props))
759 (stacked (stack-stencils
760 (remove ly:stencil-empty? stencils) 1.25 #f))
761 (brackets (make-brackets stacked indices '())))
763 (apply ly:stencil-add
764 (append stacked brackets))))