]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/framework-svg.scm
Svg with woff fonts: include dynamic css font list.
[lilypond.git] / scm / framework-svg.scm
index 9bc11ae2a3f8f5a2a533756b0a876567365173ab..ebd4eb6b42fa33b2f0cfc9dfcd069e1e5c384517 100644 (file)
 (define (svg-end)
   (ec 'svg))
 
-(define (woff-header)
+(define (svg-define-font font font-name scaling)
+  (string-append
+   "@font-face {
+font-family: '"
+   font-name
+"';
+font-weight: normal;
+font-style: normal;
+src: url('"
+   (string-downcase font-name)
+   ".woff');
+}
+"))
+
+(define (woff-header paper)
   "TODO:
-      * dynamically add fonts based on usage
       * add (ly:version) to font name
       * copy woff font with version alongside svg output
 "
   (string-append
    (eo 'defs)
    (eo 'style '(text . "style/css"))
-   "      <![CDATA[
-        @font-face {
-          font-family: 'emmentaler-20';
-          font-weight: normal;
-          font-style: normal;
-          src: url('emmentaler-20.woff');
-        }
-      ]]>
-   "
+   "<![CDATA[
+"
+   (define-fonts paper svg-define-font)
+   "]]>
+"
    (ec 'style)
    (ec 'defs)))
-  
+
 (define (dump-page paper filename page page-number page-count)
   (let* ((outputter (ly:make-paper-outputter (open-file filename "wb") 'svg))
         (dump (lambda (str) (display str (ly:outputter-port outputter))))
     (dump (svg-begin page-width page-height
                     0 0 device-width device-height))
     (if (ly:get-option 'svg-woff)
-       (dump (woff-header)))
+       (dump (woff-header paper)))
     (dump (comment (format "Page: ~S/~S" page-number page-count)))
     (ly:outputter-output-scheme outputter
                                `(begin (set! lily-unit-length ,unit-length)
     (dump (svg-begin svg-width svg-height
                     left-x (- top-y) device-width device-height))
     (if (ly:get-option svg-woff)
-       (dump (woff-header)))
+       (dump (woff-header paper)))
     (ly:outputter-output-scheme outputter
                                `(begin (set! lily-unit-length ,unit-length)
                                        ""))