2 (define-public (stack-stencils axis dir padding mols)
3 "Stack stencils MOLS in direction AXIS,DIR, using PADDING."
7 (ly:stencil-combine-at-edge (car mols) axis dir
8 (stack-stencils axis dir padding (cdr mols))
15 (define-public (stack-lines dir padding baseline mols)
16 "Stack vertically with a baseline-skip."
19 (if (null? (cdr mols))
21 (ly:stencil-combine-at-edge (car mols) Y dir
22 (stack-lines dir padding baseline (cdr mols))
27 (define-public (fontify-text font-metric text)
28 "Set TEXT with font FONT-METRIC, returning a stencil."
29 (let* ((b (ly:text-dimension font-metric text)))
31 (ly:fontify-atom font-metric `(text ,text)) (car b) (cdr b))
34 (define-public (bracketify-stencil mol axis thick protusion padding)
35 "Add brackets around MOL, producing a new stencil."
37 (let* ((ext (ly:stencil-get-extent mol axis))
38 (lb (ly:bracket axis ext thick (- protusion)))
39 (rb (ly:bracket axis ext thick protusion)))
40 (set! mol (ly:stencil-combine-at-edge mol (other-axis axis) 1 lb padding))
41 (set! mol (ly:stencil-combine-at-edge mol (other-axis axis) -1 rb padding))
45 (define-public (make-filled-box-stencil xext yext)
49 (list 'filledbox (- (car xext)) (cdr xext)
50 (- (car yext)) (cdr yext))
55 (define-public (box-grob-stencil grob)
56 "Make a box of exactly the extents of the grob. The box precisely
57 encloses the contents.
59 (let* ((xext (ly:get-extent grob grob 0))
60 (yext (ly:get-extent grob grob 1))
63 (ly:stencil-add (make-filled-box-stencil xext (cons (- (car yext) thick) (car yext) ))
64 (make-filled-box-stencil xext (cons (cdr yext) (+ (cdr yext) thick) ))
65 (make-filled-box-stencil (cons (cdr xext) (+ (cdr xext) thick)) yext)
66 (make-filled-box-stencil (cons (- (car xext) thick) (car xext)) yext))))
69 ;; TODO merge this and prev function.
70 (define-public (box-stencil mol thick padding)
71 "Add a box around MOL, producing a new stencil."
73 (x-ext (interval-widen (ly:stencil-get-extent mol 0) padding))
74 (y-ext (interval-widen (ly:stencil-get-extent mol 1) padding))
75 (y-rule (make-filled-box-stencil (cons 0 thick) y-ext))
76 (x-rule (make-filled-box-stencil (interval-widen x-ext thick)
79 (set! mol (ly:stencil-combine-at-edge mol X 1 y-rule padding))
80 (set! mol (ly:stencil-combine-at-edge mol X -1 y-rule padding))
81 (set! mol (ly:stencil-combine-at-edge mol Y 1 x-rule 0.0))
82 (set! mol (ly:stencil-combine-at-edge mol Y -1 x-rule 0.0))