1 ;;;; sodipodi.scm -- implement Scheme output routines for PostScript
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2002 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;;; NOTE that Sodipodi
9 ;;;; * dumps core on displaying feta characters
10 ;;;; * needs PFBs (ie, not PFAs like sketch)
11 ;;;; * must have (LilyPond/feta) fonts registered through GNOME's
12 ;;;; gnome-font-install (ie, not through X11, like sketch and xfontsel),
13 ;;;; which in turn is very picky about afm files
14 ;;;; * has it's own svg-like language: possibly this file should be
18 (debug-enable 'backtrace)
21 (define-module (scm sodipodi))
22 (define this-module (current-module))
31 ;;; Lily output interface --- cleanup and docme
33 ;;; Bare minimum interface for \score { \notes c } }
36 ;;; xx-output-expression
41 ;;; and should intercept:
57 ;;(define-public (sodipodi-output-expression expr port)
58 ;; (display (eval expr this-module) port))
60 (define-public (sodipodi-output-expression expr port)
61 (display (dispatch expr) port))
64 (define (dispatch expr)
65 (let ((keyword (car expr)))
67 ((eq? keyword 'some-func) "")
68 ;;((eq? keyword 'placebox) (dispatch (cadddr expr)))
69 ;;((eq? keyword 'fontify) (dispatch (caddr expr)))
71 (if (module-defined? this-module keyword)
72 (apply (eval keyword this-module) (cdr expr))
75 (string-append "undefined: " (symbol->string keyword) "\n"))
81 (define output-scale 1)
85 ((equal? (ly:unit) "mm") (/ 72.0 25.4))
86 ((equal? (ly:unit) "pt") (/ 72.0 72.27))
87 (else (error "unknown unit" (ly:unit)))))
89 ;; alist containing fontname -> fontcommand assoc (both strings)
90 ;;(define font-name-alist '())
95 (define (tagify tag string . attribute-alist)
98 (apply string-append (map (lambda (x) (string-append
100 (symbol->string (car x))
106 string "\n</" tag ">\n"))
109 ;; Interface functions
118 ;;(tagify "tspan" (format #f "&#x~2,'0x;" i))
119 (tagify "tspan" (format #f "à~2,'0x;" i))
120 ;; how to access remaining characters??
121 ;;;(tagify "tspan" (format #f "&#x~2,'0x;" #x20)
123 (format #t "can't display char: ~x\n" i)
130 (define (filledbox breapth width depth height)
133 '(style . "fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;")
134 `(x . ,(number->string (* output-scale (- 0 breapth))))
135 `(y . ,(number->string (* output-scale (- 0 height))))
136 `(width . ,(number->string (* output-scale (+ breapth width))))
137 `(height . ,(number->string (* output-scale (+ depth height))))))
140 (define font-alist '(("feta13" . ("LilyPond-Feta13" . "13"))
141 ("feta20" . "fill:black;stroke:none;font-family:lilypond;font-style:feta;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;")
142 ("parmesan20" . "fill:black;stroke:none;font-family:lilypond;font-style:parmesan;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;")
144 (define (get-font name-mag-pair)
145 ;; name-mag-pair: (quote ("feta20" . 0.569055118110236))"feta20"(quote ("feta20" . 0.569055118110236))
146 (let ((f (assoc (caadr name-mag-pair) font-alist)))
150 (format #t "font not found: ~s\n" (caadr name-mag-pair))
151 (cdr (assoc "feta20" font-alist))))))
153 (define (fontify name-mag-pair expr)
155 (tagify "text" (dispatch expr) (cons 'style (get-font name-mag-pair)))))
158 (define (header creator generate)
159 "<?xml version='1.0' standalone='no'?>
160 <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
161 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
164 xmlns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'>
166 <!-- Created with Sodipodi ('http://www.sodipodi.com/') -->
169 sodipodi:version='0.26'
170 xmlns='http://www.w3.org/2000/svg'
171 xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'
172 xmlns:xlink='http://www.w3.org/1999/xlink'
175 sodipodi:docbase='/tmp/'
176 sodipodi:docname='/tmp/x'>
181 <g tranform='translate(50,-250)'>
185 (define (placebox x y expr)
186 (tagify "g" (dispatch expr) `(transform .
188 "translate(" (number->string
191 (number->string (- 0 (* output-scale y)))
194 (define (lily-def key val)
195 (if (equal? key "lilypondpaperoutputscale")
197 (set! output-scale (* scale-to-unit (string->number val))))