-;;;; stencil.scm --
+;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
-;;;; source file of the GNU LilyPond music typesetter
-;;;;
-;;;; (c) 2003--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; Copyright (C) 2003--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;;
+;;;; LilyPond is free software: you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation, either version 3 of the License, or
+;;;; (at your option) any later version.
+;;;;
+;;;; LilyPond is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;;; GNU General Public License for more details.
+;;;;
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
(define-public (stack-stencils axis dir padding stils)
"Stack stencils STILS in direction AXIS, DIR, using PADDING."
(set! result (car p)))))
result)
-
-(define-public (bracketify-stencil stil axis thick protusion padding)
+
+(define-public (bracketify-stencil stil axis thick protrusion padding)
"Add brackets around STIL, producing a new stencil."
(let* ((ext (ly:stencil-extent stil axis))
- (lb (ly:bracket axis ext thick (- protusion)))
- (rb (ly:bracket axis ext thick protusion)))
+ (lb (ly:bracket axis ext thick protrusion))
+ (rb (ly:bracket axis ext thick (- protrusion))))
(set! stil
- (ly:stencil-combine-at-edge stil (other-axis axis) 1 lb padding))
+ (ly:stencil-combine-at-edge stil (other-axis axis) 1 rb padding))
(set! stil
- (ly:stencil-combine-at-edge stil (other-axis axis) -1 rb padding))
+ (ly:stencil-combine-at-edge lb (other-axis axis) 1 stil padding))
stil))
(define-public (make-line-stencil width startx starty endx endy)
0))
(scaled-bbox
(map (lambda (x) (* factor x)) bbox))
+ ; We need to shift the whole eps to (0,0), otherwise it will appear
+ ; displaced in lilypond (displacement will depend on the scaling!)
+ (translate-string (ly:format "~a ~a translate" (- (list-ref bbox 0)) (- (list-ref bbox 1))))
(clip-rect-string (ly:format
"~a ~a ~a ~a rectclip"
(list-ref bbox 0)
BeginEPSF
~a dup scale
~a
+~a
%%BeginDocument: ~a
-" factor clip-rect-string
+" factor translate-string clip-rect-string
file-name
)
EndEPSF
grestore
"))
-
- (cons (list-ref scaled-bbox 0) (list-ref scaled-bbox 2))
- (cons (list-ref scaled-bbox 1) (list-ref scaled-bbox 3)))
+ ; Stencil starts at (0,0), since we have shifted the eps, and its
+ ; size is exactly the size of the scaled bounding box
+ (cons 0 (- (list-ref scaled-bbox 2) (list-ref scaled-bbox 0)))
+ (cons 0 (- (list-ref scaled-bbox 3) (list-ref scaled-bbox 1))))
(ly:make-stencil "" '(0 . 0) '(0 . 0)))
))