]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add warnings for invalid 'path styles.
authorPatrick McCarty <pnorcks@gmail.com>
Mon, 21 Jun 2010 22:03:26 +0000 (15:03 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Fri, 13 Aug 2010 22:03:08 +0000 (15:03 -0700)
Since there are only six styles, it is trivial to do error checking
here.

scm/output-ps.scm
scm/output-svg.scm

index 54ba874d00d5e7efc24b827a557ffc07ff29d404..16f62012d9846a3ca7e5690c76b0004e7056c037 100644 (file)
                (convert-path-exps (drop rest arity))))
        '()))
 
-  (let ((cap-numeric (case cap ((butt) 0) ((round) 1) ((square) 2)))
-       (join-numeric (case join ((miter) 0) ((round) 1) ((bevel) 2))))
+  (let ((cap-numeric (case cap ((butt) 0) ((round) 1) ((square) 2)
+                      (else (begin
+                              (ly:warning (_ "unknown line-cap-style: ~S")
+                                          (symbol->string cap))
+                              1))))
+       (join-numeric (case join ((miter) 0) ((round) 1) ((bevel) 2)
+                       (else (begin
+                               (ly:warning (_ "unknown line-join-style: ~S")
+                                           (symbol->string join))
+                               1)))))
     (ly:format
      "gsave currentpoint translate
 ~a setlinecap ~a setlinejoin ~a setlinewidth
index 40aafb420f18d0348eada77f15a0a2b8e10781b0..8d4248fb4333fed586fd12d3153502895b3f1ccb 100644 (file)
                (convert-path-exps (drop rest arity))))
        '()))
 
-  (entity 'path ""
-         `(stroke-width . ,thick)
-         `(stroke-linejoin . ,(symbol->string join))
-         `(stroke-linecap . ,(symbol->string cap))
-         '(stroke . "currentColor")
-         `(fill . ,(if fill? "currentColor" "none"))
-         `(d . ,(apply string-append (convert-path-exps commands)))))
+  (let* ((line-cap-styles '(butt round square))
+        (line-join-styles '(miter round bevel))
+        (cap-style (if (not (memv cap line-cap-styles))
+                       (begin
+                         (ly:warning (_ "unknown line-cap-style: ~S")
+                                     (symbol->string cap))
+                         'round)
+                       cap))
+        (join-style (if (not (memv join line-join-styles))
+                        (begin
+                          (ly:warning (_ "unknown line-join-style: ~S")
+                                      (symbol->string join))
+                          'round)
+                        join)))
+    (entity 'path ""
+           `(stroke-width . ,thick)
+           `(stroke-linejoin . ,(symbol->string join-style))
+           `(stroke-linecap . ,(symbol->string cap-style))
+           '(stroke . "currentColor")
+           `(fill . ,(if fill? "currentColor" "none"))
+           `(d . ,(apply string-append (convert-path-exps commands))))))
 
 (define (placebox x y expr)
   (if (string-null? expr)