3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2003--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 (define-public (stack-stencils axis dir padding stils)
8 "Stack stencils STILS in direction AXIS, DIR, using PADDING."
12 (ly:stencil-combine-at-edge
13 (car stils) axis dir (stack-stencils axis dir padding (cdr stils))
16 (define-public (stack-lines dir padding baseline stils)
17 "Stack vertically with a baseline-skip."
20 (if (null? (cdr stils))
22 (ly:stencil-combine-at-edge
24 (stack-lines dir padding baseline (cdr stils))
27 (define-public (bracketify-stencil stil axis thick protusion padding)
28 "Add brackets around STIL, producing a new stencil."
30 (let* ((ext (ly:stencil-extent stil axis))
31 (lb (ly:bracket axis ext thick (- protusion)))
32 (rb (ly:bracket axis ext thick protusion)))
34 (ly:stencil-combine-at-edge stil (other-axis axis) 1 lb padding))
36 (ly:stencil-combine-at-edge stil (other-axis axis) -1 rb padding))
39 (define-public (make-filled-box-stencil xext yext)
43 (list 'filledbox (- (car xext)) (cdr xext)
44 (- (car yext)) (cdr yext))
48 (define-public (box-grob-stencil grob)
49 "Make a box of exactly the extents of the grob. The box precisely
50 encloses the contents.
52 (let* ((xext (ly:grob-extent grob grob 0))
53 (yext (ly:grob-extent grob grob 1))
57 (make-filled-box-stencil xext (cons (- (car yext) thick) (car yext)))
58 (make-filled-box-stencil xext (cons (cdr yext) (+ (cdr yext) thick)))
59 (make-filled-box-stencil (cons (cdr xext) (+ (cdr xext) thick)) yext)
60 (make-filled-box-stencil (cons (- (car xext) thick) (car xext)) yext))))
62 ;; TODO merge this and prev function.
63 (define-public (box-stencil stil thick padding)
64 "Add a box around STIL, producing a new stencil."
65 (let* ((x-ext (interval-widen (ly:stencil-extent stil 0) padding))
66 (y-ext (interval-widen (ly:stencil-extent stil 1) padding))
67 (y-rule (make-filled-box-stencil (cons 0 thick) y-ext))
68 (x-rule (make-filled-box-stencil (interval-widen x-ext thick)
71 (set! stil (ly:stencil-combine-at-edge stil X 1 y-rule padding))
72 (set! stil (ly:stencil-combine-at-edge stil X -1 y-rule padding))
73 (set! stil (ly:stencil-combine-at-edge stil Y 1 x-rule 0.0))
74 (set! stil (ly:stencil-combine-at-edge stil Y -1 x-rule 0.0))
78 (define-public (fontify-text font-metric text)
79 "Set TEXT with font FONT-METRIC, returning a stencil."
80 (let* ((b (ly:text-dimension font-metric text)))
82 `(text ,font-metric ,text) (car b) (cdr b))))
84 (define-public (fontify-text-white scale font-metric text)
85 "Set TEXT with scale factor s"
86 (let* ((b (ly:text-dimension font-metric text))
87 (c `(white-text ,(* 2 scale) ,text))) ;urg -- workaround for using ps font
88 (ly:make-stencil c (car b) (cdr b)))) ;urg -- extent is not from ps font, but we hope it's close