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