* scm/framework-svg.scm: Add pageSet. Update.
* mf/GNUmakefile:
* buildscripts/gen-bigcheese-scripts.py: Also generate SVG font.
+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.
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 && \
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 . && \
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)
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 $^ > $@
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
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)
Generate("aybabtu.otf");
Generate("aybabtu.cff");
+Generate("aybabtu.svg");
(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))))
""))))))
;; 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)