]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/output-svg.scm:
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 18 Dec 2004 15:44:25 +0000 (15:44 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 18 Dec 2004 15:44:25 +0000 (15:44 +0000)
* scm/framework-svg.scm: Add pageSet.  Update.

* mf/GNUmakefile:
* buildscripts/gen-bigcheese-scripts.py: Also generate SVG font.

ChangeLog
GNUmakefile.in
buildscripts/gen-bigcheese-scripts.py
mf/GNUmakefile
mf/aybabtu.pe.in
scm/framework-svg.scm
scm/output-svg.scm

index c8f75bcaa5ebbf2fc08b71f89f00ac327ee1041a..2d52dbfcafaf5db2f3b9f9e945890ca781da1542 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-12-18  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * scm/output-svg.scm:
+       * scm/framework-svg.scm: Add pageSet.  Update.
+
+       * mf/GNUmakefile: 
+       * buildscripts/gen-bigcheese-scripts.py: Also generate SVG font.
+
 2004-12-18  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * tex/lilyponddefs.tex: comment out new ifpdf code.
index 1f1dbcc82dfc2fd944e085313febd0530dae8d04..e3198a352f09030460b5f280038089cbddc5eca7 100644 (file)
@@ -112,6 +112,7 @@ $(builddir)/share/lilypond-force:
                ln -s $(abs-srcdir)/ly ly && \
                ln -s ../../mf/$(outconfbase) dvips && \
                ln -s ../../mf/$(outconfbase) otf && \
+               ln -s ../../mf/$(outconfbase) svg && \
                ln -s ../../mf/$(outconfbase) tfm && \
                ln -s $(abs-srcdir)/mf && \
                ln -s $(abs-srcdir)/ps && \
@@ -125,6 +126,7 @@ $(builddir)/share/lilypond-force:
                ln -s $(abs-srcdir)/mf source && \
                ln -s ../../../mf/$(outconfbase) otf && \
                ln -s ../../../mf/$(outconfbase) tfm && \
+               ln -s ../../../mf/$(outconfbase) svg && \
                ln -s ../../../mf/$(outconfbase) type1
        cd $(builddir)/share/$(package)/elisp && \
                ln -sf ../../../elisp/$(outconfbase)/lilypond-words.el . && \
index f5e47d42e46417576636bc3f070d19f97269fccb..d4091e82f14171a8b513916e780adac6e5546bbd 100644 (file)
@@ -65,7 +65,9 @@ LoadTableFromFile("LILC", "feta%(design_size)d.otf-table")
 LoadTableFromFile("LILY", "feta%(design_size)d.otf-gtable")
 
 Generate("%(name)s%(design_size)d.otf");
-Generate("%(name)s%(design_size)d.cff");''' % vars()
+Generate("%(name)s%(design_size)d.cff");
+Generate("%(name)s%(design_size)d.svg");
+''' % vars()
 
        path = os.path.join (outdir, name + '%d' % design_size +  '.pe')
        open (path, 'w').write (script)
index 014d7b1d710e824aae18baf487606a7b69e8acce..b01bb1cff04338486b525ca4f00aa528fe7fd280 100644 (file)
@@ -24,6 +24,7 @@ PE_SCRIPTS = $(addsuffix .pe, $(addprefix $(outdir)/bigcheese, $(STAFF_SIZES)))
 OTF_TABLES = $(addsuffix .otf-table, $(addprefix $(outdir)/feta, $(STAFF_SIZES))) \
  $(BRACES:%=$(outdir)/feta-braces-%.otf-table)
 FETA_FONTS = $(FETA_MF_FILES:.mf=)
+SVG_FILES = $(OTF_FILES:%.otf=%.svg)
 
 $(outdir)/aybabtu.otf-table: $(BRACES:%=$(outdir)/feta-braces-%.otf-table)
        cat $^ > $@
@@ -54,7 +55,7 @@ foe:
        echo $(TEXMF)
        kpsewhich exbase.mf
 
-$(outdir)/%.otf: $(outdir)/%.pe
+$(outdir)/%.otf $(outdir)/%.svg: $(outdir)/%.pe
        (cd $(outdir) && fontforge -script $(notdir $<)) 
 
 $(outdir)/%.otf-table: $(outdir)/%.lisp
@@ -106,6 +107,9 @@ INSTALLATION_OUT_FILES6=$(outdir)/lilypond.map
 INSTALLATION_OUT_DIR7=$(local_lilypond_datadir)/ps/
 INSTALLATION_OUT_FILES7=$(ENC_FILES)
 
+INSTALLATION_OUT_DIR8=$(local_lilypond_datadir)/svg
+INSTALLATION_OUT_FILES8=$(OTF_FILES)
+
 
 export MFINPUTS:=.:$(MFINPUTS)
 
index fbe376285c19f0c0c062a39c5e05987ef52a1039..983b31b3e9a2da75da4caf25fd005f4bfd617fa6 100644 (file)
@@ -42,3 +42,4 @@ LoadTableFromFile("LILY", "aybabtu.otf-gtable")
 
 Generate("aybabtu.otf");
 Generate("aybabtu.cff");
+Generate("aybabtu.svg");
index 7415536ec6b0de75a35e2e5610216c08cf7c5d18..83af347a709c61df3f09e373080434e547b06ad6 100644 (file)
@@ -6,7 +6,7 @@
 
 (define-module (scm framework-svg))
 
-(use-modules (guile) (lily))
+(use-modules (guile) (lily) (scm output-svg))
 (use-modules (srfi srfi-2) (ice-9 regex))
 
 ;; FIXME: 0.62 to get paper size right
         (hsize (ly:output-def-lookup paper 'hsize))
         (vsize (ly:output-def-lookup paper 'vsize))
         (page-width (inexact->exact (ceiling (* output-scale hsize))))
-        (page-height (inexact->exact (ceiling (* output-scale vsize)))))
-
-    (ly:outputter-dump-string outputter xml-header)
-    (ly:outputter-dump-string
-     outputter
-     (comment "Created with GNU LilyPond (http://lilypond.org)"))
-    (ly:outputter-dump-string
-     outputter (format #f "<svg id='svg1' width='~smm' height='~smm'>\n"
-                      page-width page-height))
-    (ly:outputter-dump-string
-     outputter "<g transform='translate (10, 10) scale (1)'>\n")
-      
-;   (for-each
-;    (lambda (x)
-;      (ly:outputter-dump-string outputter x))
-;    (cons
-;     (page-header paper page-count)
-;     (preamble paper)))
-  
+        (page-height (inexact->exact (ceiling (* output-scale vsize))))
+        (page-set? (> page-count 1)))
+    
+   (ly:outputter-dump-string
+    outputter
+    (string-append
+     (eo 'svg
+        '(xmlns . "http://www.w3.org/2000/svg")
+        '(version . "1.2")
+        `(width . ,(format #f "~smm" page-width))
+        `(height . ,(format #f "~smm" page-height)))
+     ;; FIXME: only use pages if there are more than one, pageSet is
+     ;; not supported by all SVG applications yet.
+     (if page-set? (eo 'pageSet) "")
+     (eo 'g)))
+       
   (for-each
    (lambda (page)
      (set! page-number (1+ page-number))
-     (dump-page outputter page page-number page-count landscape?))
+     (dump-page outputter page page-number page-count landscape? page-set?))
    pages)
-  (ly:outputter-dump-string outputter "\n</g>\n</svg>\n")))
-
-(define (comment s)
-  (string-append "<!-- " s " !-->\n"))
-
-;; FIXME: gulp from file
-(define xml-header
-  "<?xml version='1.0' encoding='UTF-8' standalone='no'?>
-<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
-'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
-")
-
-(define (dump-page outputter page page-number page-count landscape?) 
+  
+  (if page-set? (eo 'pageSet) "")
   (ly:outputter-dump-string
    outputter
    (string-append
-    (comment (format #f "Page: ~S/~S" page-number page-count))
-    ;;(format #f "<g transform='translate (0, ~f)'>\n" (* output-scale y))))
-    "<g>\n"))
+    (ec 'g)
+    (if page-set? (ec 'pageSet) "")
+    (ec 'svg)))))
 
+(define (dump-page outputter page page-number page-count landscape? page-set?)
   ;; FIXME:landscape
-  (ly:outputter-dump-stencil outputter page)
-
   (ly:outputter-dump-string
-   outputter
-   (string-append
-    (comment (format #f "End Page ~S/~S" page-number page-count))
-    "</g>\n")))
+   outputter (comment (format #f "Page: ~S/~S" page-number page-count)))
+  (if page-set? (ly:outputter-dump-string outputter (eo 'page)))
+  (ly:outputter-dump-string outputter (string-append (eo 'g)))
+  (ly:outputter-dump-stencil outputter page)
+  (ly:outputter-dump-string outputter (string-append (ec 'g)))
+  (if page-set? (ly:outputter-dump-string outputter (ec 'page))))
index 068b69d28a11e9b8e0f1bc82ccb2e312e06ba31a..b19006a342888139a9aabd9e75433fb6c820a349 100644 (file)
            ""))))))
   
 ;; Helper functions
-(define (tagify tag string . attribute-alist)
-  (string-append
-   "<"
-   tag
-   (apply string-append
-         (map (lambda (x)
-                (string-append " " (symbol->string (car x)) "='" (cdr x) "'"))
-              attribute-alist))
-   ">"
-   string "</" tag ">\n"))
+(define-public (attributes attributes-alist)
+  (apply string-append
+        (map (lambda (x) (format #f " ~s=\"~a\"" (car x) (cdr x)))
+             attributes-alist)))
+
+(define-public (eo entity . attributes-alist)
+  (format #f "<~S~a>\n" entity (attributes attributes-alist)))
+
+(define-public (eoc entity . attributes-alist)
+  (format #f "<~S~a/>\n" entity (attributes attributes-alist)))
+
+(define-public (ec entity)
+  (format #f "</~S>\n" entity))
+
+(define-public (entity entity string . attributes-alist)
+  (if (equal? string "")
+      (apply eoc entity attributes-alist)
+      (string-append
+       (apply eo (cons entity attributes-alist)) string (ec entity))))
 
 (define (control->list c)
   (list (car c) (cdr c)))
           (font-size font) anchor)))
 
 (define (fontify font expr)
-   (tagify "text" expr (cons 'style (svg-font font))))
+   (entity 'text expr (cons 'style (svg-font font))))
 
 ;; FIXME
 (define-public (otf-name-mangling font family)
   (let* ((x width)
         (y (* slope width))
         (z (sqrt (+ (sqr x) (sqr y)))))
-    (tagify "rect" ""
+    (entity 'rect ""
            `(style . ,(format "stroke-linejoin:round;stroke-linecap:round;stroke-width:~f;" blot))
            `(x . "0")
            `(y . ,(number->string (* output-scale (- 0 (/ thick 2)))))
   (let* ((first (list-tail lst 4))
         (first-c0 (car (list-tail first 3)))
         (second (list-head lst 4)))
-    (tagify "path" ""
+    (entity 'path ""
            `(style . ,(format "stroke-linejoin:round;stroke-linecap:round;stroke-width:~f;" thick))
            `(transform . ,(format #f "scale (~f, ~f)"
                                   output-scale output-scale))
 
 (define (char font i)
   (dispatch
-   `(fontify ,font ,(tagify "tspan" (char->entity (integer->char i))))))
+   `(fontify ,font ,(entity 'tspan (char->entity (integer->char i))))))
 
-(define (comment s)
+(define-public (comment s)
   (string-append "<!-- " s " !-->\n"))
 
 (define (filledbox breapth width depth height)
 
 (define (named-glyph font name)
   (dispatch
-   `(fontify ,font ,(tagify "tspan"
+   `(fontify ,font ,(entity 'tspan
                            (integer->entity
                             (ly:font-glyph-name-to-charcode font name))))))
 
 (define (placebox x y expr)
-  (tagify "g"
+  (entity 'g
          ;; FIXME -- JCN
          ;;(dispatch expr)
          expr
                                 (- 0 (* output-scale y))))))
 
 (define (round-filled-box breapth width depth height blot-diameter)
-  (tagify "rect" ""
+  (entity 'rect ""
          `(style . ,(format "stroke-linejoin:round;stroke-linecap:round;stroke-width:~f;" blot-diameter))
          `(x . ,(number->string (* output-scale (- 0 breapth))))
          `(y . ,(number->string (* output-scale (- 0 height))))
          `(ry . ,(number->string (/ blot-diameter 2)))))
 
 (define (text font string)
-  (dispatch `(fontify ,font ,(tagify "tspan" (string->entities string)))))
+  (dispatch `(fontify ,font ,(entity 'tspan (string->entities string)))))
 
 ;; WTF is this in every backend?
 (define (horizontal-line x1 x2 th)