OLD | NEW |
1 ;;;; This file is part of LilyPond, the GNU music typesetter. | 1 ;;;; This file is part of LilyPond, the GNU music typesetter. |
2 ;;;; | 2 ;;;; |
3 ;;;; Copyright (C) 2004--2020 Jan Nieuwenhuizen <janneke@gnu.org> | 3 ;;;; Copyright (C) 2004--2020 Jan Nieuwenhuizen <janneke@gnu.org> |
4 ;;;; Patrick McCarty <pnorcks@gmail.com> | 4 ;;;; Patrick McCarty <pnorcks@gmail.com> |
5 ;;;; | 5 ;;;; |
6 ;;;; LilyPond is free software: you can redistribute it and/or modify | 6 ;;;; LilyPond is free software: you can redistribute it and/or modify |
7 ;;;; it under the terms of the GNU General Public License as published by | 7 ;;;; it under the terms of the GNU General Public License as published by |
8 ;;;; the Free Software Foundation, either version 3 of the License, or | 8 ;;;; the Free Software Foundation, either version 3 of the License, or |
9 ;;;; (at your option) any later version. | 9 ;;;; (at your option) any later version. |
10 ;;;; | 10 ;;;; |
(...skipping 29 matching lines...) Expand all Loading... |
40 (scm clip-region) | 40 (scm clip-region) |
41 (srfi srfi-1) | 41 (srfi srfi-1) |
42 (srfi srfi-2) | 42 (srfi srfi-2) |
43 (srfi srfi-13) | 43 (srfi srfi-13) |
44 (ice-9 regex)) | 44 (ice-9 regex)) |
45 | 45 |
46 (define format ergonomic-simple-format) | 46 (define format ergonomic-simple-format) |
47 | 47 |
48 (define (svg-begin . rest) | 48 (define (svg-begin . rest) |
49 (string-append | 49 (string-append |
50 (eo 'svg #t | 50 (eo 'svg #t |
51 '(xmlns . "http://www.w3.org/2000/svg") | 51 '(xmlns . "http://www.w3.org/2000/svg") |
52 '(xmlns:xlink . "http://www.w3.org/1999/xlink") | 52 '(xmlns:xlink . "http://www.w3.org/1999/xlink") |
53 '(version . "1.2") | 53 '(version . "1.2") |
54 `(width . ,(ly:format "~2fmm" (first rest))) | 54 `(width . ,(ly:format "~2fmm" (first rest))) |
55 `(height . ,(ly:format "~2fmm" (second rest))) | 55 `(height . ,(ly:format "~2fmm" (second rest))) |
56 `(viewBox . ,(ly:format "~4f ~4f ~4f ~4f" | 56 `(viewBox . ,(ly:format "~4f ~4f ~4f ~4f" |
57 (third rest) (fourth rest) | 57 (third rest) (fourth rest) |
58 (fifth rest) (sixth rest)))) | 58 (fifth rest) (sixth rest)))) |
59 (eo 'style #t '(text . "style/css")) | 59 (eo 'style #t '(text . "style/css")) |
60 "<![CDATA[ | 60 "<![CDATA[ |
61 tspan { white-space: pre; } | 61 tspan { white-space: pre; } |
62 ")) | 62 ")) |
63 | 63 |
64 (define (svg-end) | 64 (define (svg-end) |
65 (ec 'svg)) | 65 (ec 'svg)) |
66 | 66 |
67 (define (mkdirs dir-name mode) | 67 (define (mkdirs dir-name mode) |
68 (let loop ((dir-name (string-split dir-name #\/)) (root "")) | 68 (let loop ((dir-name (string-split dir-name #\/)) (root "")) |
69 (if (pair? dir-name) | 69 (if (pair? dir-name) |
70 (let ((dir (string-append root (car dir-name)))) | 70 (let ((dir (string-append root (car dir-name)))) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 (define (dump-preview-bbox paper stencil filename bbox) | 186 (define (dump-preview-bbox paper stencil filename bbox) |
187 (let* ((outputter (ly:make-paper-outputter (open-file filename "wb") 'svg)) | 187 (let* ((outputter (ly:make-paper-outputter (open-file filename "wb") 'svg)) |
188 (dump (lambda (str) (display str (ly:outputter-port outputter)))) | 188 (dump (lambda (str) (display str (ly:outputter-port outputter)))) |
189 (lookup (lambda (x) (ly:output-def-lookup paper x))) | 189 (lookup (lambda (x) (ly:output-def-lookup paper x))) |
190 (unit-length (lookup 'output-scale)) | 190 (unit-length (lookup 'output-scale)) |
191 (output-scale (* lily-unit->mm-factor unit-length)) | 191 (output-scale (* lily-unit->mm-factor unit-length)) |
192 (left-x (list-ref bbox 0)) | 192 (left-x (list-ref bbox 0)) |
193 (top-y (list-ref bbox 1)) | 193 (top-y (list-ref bbox 1)) |
194 (device-width (list-ref bbox 2)) | 194 (device-width (list-ref bbox 2)) |
195 (device-height (list-ref bbox 3)) | 195 (device-height (list-ref bbox 3)) |
196 ;BUG: Height calculation is off - optional & disabled | 196 ;; BUG: Height calculation is off - optional & disabled |
197 ;(svg-width (* output-scale device-width)) | 197 ;; (svg-width (* output-scale device-width)) |
198 ;(svg-height (* output-scale device-height)) | 198 ;; (svg-height (* output-scale device-height)) |
199 ) | 199 ) |
200 | 200 |
201 (if (ly:get-option 'svg-woff) | 201 (if (ly:get-option 'svg-woff) |
202 (module-define! (ly:outputter-module outputter) 'paper paper)) | 202 (module-define! (ly:outputter-module outputter) 'paper paper)) |
203 (dump (svg-begin "" "" | 203 (dump (svg-begin "" "" |
204 left-x (- top-y) device-width device-height)) | 204 left-x (- top-y) device-width device-height)) |
205 (if (ly:get-option 'svg-woff) | 205 (if (ly:get-option 'svg-woff) |
206 (module-remove! (ly:outputter-module outputter) 'paper)) | 206 (module-remove! (ly:outputter-module outputter) 'paper)) |
207 (if (ly:get-option 'svg-woff) | 207 (if (ly:get-option 'svg-woff) |
208 (dump (woff-header paper (dirname filename)))) | 208 (dump (woff-header paper (dirname filename)))) |
209 (ly:outputter-output-scheme outputter | 209 (ly:outputter-output-scheme outputter |
(...skipping 20 matching lines...) Expand all Loading... |
230 (paper-system (cdr ext-system-pair)) | 230 (paper-system (cdr ext-system-pair)) |
231 (yext (paper-system-extent paper-system Y)) | 231 (yext (paper-system-extent paper-system Y)) |
232 (bbox (list (car xext) (car yext) | 232 (bbox (list (car xext) (car yext) |
233 (cdr xext) (cdr yext))) | 233 (cdr xext) (cdr yext))) |
234 (paper-system (cdr ext-system-pair)) | 234 (paper-system (cdr ext-system-pair)) |
235 (filename (if (< 0 count) | 235 (filename (if (< 0 count) |
236 (format #f "~a-~a.svg" basename count) | 236 (format #f "~a-~a.svg" basename count) |
237 (string-append basename ".svg")))) | 237 (string-append basename ".svg")))) |
238 (set! count (1+ count)) | 238 (set! count (1+ count)) |
239 (dump-preview-bbox paper | 239 (dump-preview-bbox paper |
240 (paper-system-stencil paper-system) | 240 (paper-system-stencil paper-system) |
241 filename bbox))) | 241 filename bbox))) |
242 extents-system-pairs))) | 242 extents-system-pairs))) |
243 | 243 |
244 (define (clip-system-SVG basename paper-book) | 244 (define (clip-system-SVG basename paper-book) |
245 (define (clip-score-systems basename systems) | 245 (define (clip-score-systems basename systems) |
246 (let* ((layout (ly:grob-layout (paper-system-system-grob (car systems)))) | 246 (let* ((layout (ly:grob-layout (paper-system-system-grob (car systems)))) |
247 (regions (ly:output-def-lookup layout 'clip-regions))) | 247 (regions (ly:output-def-lookup layout 'clip-regions))) |
248 (for-each | 248 (for-each |
249 (lambda (region) | 249 (lambda (region) |
250 (clip-systems-to-region | 250 (clip-systems-to-region |
251 (format #f "~a-from-~a-to-~a-clip" | 251 (format #f "~a-from-~a-to-~a-clip" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 (format #f "~a.preview.svg" basename)))) | 328 (format #f "~a.preview.svg" basename)))) |
329 | 329 |
330 (define (output-crop-framework basename book scopes fields) | 330 (define (output-crop-framework basename book scopes fields) |
331 (let* ((paper (ly:paper-book-paper book)) | 331 (let* ((paper (ly:paper-book-paper book)) |
332 (systems (relevant-book-systems book)) | 332 (systems (relevant-book-systems book)) |
333 (page-stencils (stack-stencils Y DOWN 0.0 | 333 (page-stencils (stack-stencils Y DOWN 0.0 |
334 (map paper-system-stencil | 334 (map paper-system-stencil |
335 (reverse (reverse systems)))))) | 335 (reverse (reverse systems)))))) |
336 (if (ly:get-option 'clip-systems) (clip-system-SVG basename book)) | 336 (if (ly:get-option 'clip-systems) (clip-system-SVG basename book)) |
337 (dump-preview paper page-stencils (format #f "~a.cropped.svg" basename)))) | 337 (dump-preview paper page-stencils (format #f "~a.cropped.svg" basename)))) |
OLD | NEW |