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
112 (tagify "tspan" (make-string 1 (integer->char i))))
118 (define (filledbox breapth width depth height)
121 '(style . "fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;")
122 `(x . ,(number->string (* output-scale (- 0 breapth))))
123 `(y . ,(number->string (* output-scale (- 0 height))))
124 `(width . ,(number->string (* output-scale (+ breapth width))))
125 `(height . ,(number->string (* output-scale (+ depth height))))))
128 (define (fontify name-mag-pair expr)
130 ;; for simple sodipodi with feta20.pfb:
131 ;; (tagify "text" (dispatch expr) '(style . "fill:black;stroke:none;font-family:futa20;font-style:normal;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;"))
133 ;; Sketch' svg input filter groks this:
134 (tagify "text" (dispatch expr) '(style . "fill:black;stroke:none;font-family:LilyPond-Feta-20;font-style:normal;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;"))
139 (define (header creator generate)
140 "<?xml version='1.0' standalone='no'?>
141 <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20010904//EN'
142 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
145 xmlns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'>
147 <!-- Created with Sodipodi ('http://www.sodipodi.com/') -->
150 sodipodi:version='0.26'
151 xmlns='http://www.w3.org/2000/svg'
152 xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'
153 xmlns:xlink='http://www.w3.org/1999/xlink'
156 sodipodi:docbase='/tmp/'
157 sodipodi:docname='/tmp/x'>
162 <g tranform='translate(50,-250)'>
166 (define (placebox x y expr)
167 (tagify "g" (dispatch expr) `(transform .
169 "translate(" (number->string
172 (number->string (- 0 (* output-scale y)))
175 (define (lily-def key val)
176 (if (equal? key "lilypondpaperoutputscale")
178 (set! output-scale (* scale-to-unit (string->number val))))