From bc26fcff31419e15794e69b3ee156d244c17c954 Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Mon, 21 Jun 2010 15:03:26 -0700 Subject: [PATCH] Add warnings for invalid 'path styles. Since there are only six styles, it is trivial to do error checking here. --- scm/output-ps.scm | 12 ++++++++++-- scm/output-svg.scm | 28 +++++++++++++++++++++------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 54ba874d00..16f62012d9 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -308,8 +308,16 @@ (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 diff --git a/scm/output-svg.scm b/scm/output-svg.scm index 40aafb420f..8d4248fb43 100644 --- a/scm/output-svg.scm +++ b/scm/output-svg.scm @@ -575,13 +575,27 @@ (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) -- 2.39.2