3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2003--2005 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."
10 ((null? stils) empty-stencil)
11 ((null? (cdr stils)) (car stils))
12 (else (ly:stencil-combine-at-edge
13 (car stils) axis dir (stack-stencils axis dir padding (cdr stils))
16 (define-public (stack-stencils-padding-list axis dir padding stils)
17 "Stack stencils STILS in direction AXIS, DIR, using a list of PADDING."
19 ((null? stils) empty-stencil)
20 ((null? (cdr stils)) (car stils))
21 (else (ly:stencil-combine-at-edge
22 (car stils) axis dir (stack-stencils-padding-list axis dir (cdr padding) (cdr stils))
25 (define-public (stack-lines dir padding baseline stils)
26 "Stack vertically with a baseline-skip."
29 (if (null? (cdr stils))
31 (ly:stencil-combine-at-edge
33 (stack-lines dir padding baseline (cdr stils))
36 (define-public (bracketify-stencil stil axis thick protusion padding)
37 "Add brackets around STIL, producing a new stencil."
39 (let* ((ext (ly:stencil-extent stil axis))
40 (lb (ly:bracket axis ext thick (- protusion)))
41 (rb (ly:bracket axis ext thick protusion)))
43 (ly:stencil-combine-at-edge stil (other-axis axis) 1 lb padding))
45 (ly:stencil-combine-at-edge stil (other-axis axis) -1 rb padding))
48 (define-public (make-filled-box-stencil xext yext)
52 (list 'filledbox (- (car xext)) (cdr xext)
53 (- (car yext)) (cdr yext))
56 (define-public (box-grob-stencil grob)
57 "Make a box of exactly the extents of the grob. The box precisely
58 encloses the contents.
60 (let* ((xext (ly:grob-extent grob grob 0))
61 (yext (ly:grob-extent grob grob 1))
65 (make-filled-box-stencil xext (cons (- (car yext) thick) (car yext)))
66 (make-filled-box-stencil xext (cons (cdr yext) (+ (cdr yext) thick)))
67 (make-filled-box-stencil (cons (cdr xext) (+ (cdr xext) thick)) yext)
68 (make-filled-box-stencil (cons (- (car xext) thick) (car xext)) yext))))
70 ;; TODO merge this and prev function.
71 (define-public (box-stencil stil thick padding)
72 "Add a box around STIL, producing a new stencil."
73 (let* ((x-ext (interval-widen (ly:stencil-extent stil 0) padding))
74 (y-ext (interval-widen (ly:stencil-extent stil 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! stil (ly:stencil-combine-at-edge stil X 1 y-rule padding))
80 (set! stil (ly:stencil-combine-at-edge stil X -1 y-rule padding))
81 (set! stil (ly:stencil-combine-at-edge stil Y 1 x-rule 0.0))
82 (set! stil (ly:stencil-combine-at-edge stil Y -1 x-rule 0.0))
86 (define-public (fontify-text font-metric text)
87 "Set TEXT with font FONT-METRIC, returning a stencil."
88 (let* ((b (ly:text-dimension font-metric text)))
90 `(text ,font-metric ,text) (car b) (cdr b))))
92 (define-public (fontify-text-white scale font-metric text)
93 "Set TEXT with scale factor s"
94 (let* ((b (ly:text-dimension font-metric text))
95 ;;urg -- workaround for using ps font
96 (c `(white-text ,(* 2 scale) ,text)))
97 ;;urg -- extent is not from ps font, but we hope it's close
98 (ly:make-stencil c (car b) (cdr b))))