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