1 ;;;; figured bass support ...
3 ;;;; todo: make interfaces as 1st level objects in LilyPond.
6 (define (fontify-text font-metric text)
7 "Set TEXT with font FONT-METRIC, returning a molecule."
8 (let* ((b (ly-text-dimension font-metric text)))
10 (ly-fontify-atom font-metric `(text ,text)) (car b) (cdr b))
13 (define (brew-one-figure grob fig-music)
14 "Brew a single column for a music figure"
16 (mf (ly-get-font grob '( (font-family . music) )))
17 (nf (ly-get-font grob '( (font-family . number) )))
18 (mol (ly-make-molecule '() '(0 . 0) '(0 . 1.0)))
19 (fig (ly-get-mus-property fig-music 'figure))
20 (acc (ly-get-mus-property fig-music 'alteration))
25 (set! mol (fontify-text nf (number->string fig)))
26 (ly-align-to! mol Y CENTER)
31 (ly-combine-molecule-at-edge
32 mol 0 1 (ly-find-glyph-by-name mf (string-append "accidentals-" (number->string acc)))
36 (ly-align-to! mol X CENTER)
41 (define (stack-molecules axis dir padding mols)
42 "Stack molecules MOLS in direction AXIS,DIR, using PADDING."
46 (ly-combine-molecule-at-edge (car mols) axis dir
47 (stack-molecules axis dir padding (cdr mols))
53 (define (brew-bass-figure grob)
54 "Make a molecule for a Figured Bass grob"
56 (figs (ly-get-grob-property grob 'causes ))
57 (fig-mols (map (lambda (x) (brew-one-figure grob x)) figs))
58 (fig-mol (stack-molecules 1 -1 0.2 fig-mols))
61 (ly-align-to! fig-mol Y DOWN)