]> git.donarmstrong.com Git - lilypond.git/blob - init/scm.ly
bd27dec6f49e5cf11826f70e1fa49137d83f7687
[lilypond.git] / init / scm.ly
1 % scm.ly -- implement Scheme output routines for TeX and PostScript
2 %
3 %  source file of the GNU LilyPond music typesetter
4
5 % (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
6
7 \scm "
8
9 ;;; graphical lisp element
10 (define (add-column p) (display \"adding column (in guile): \") (display p) (newline))
11
12 ;;; library funtions
13 (define
14   (numbers->string l)
15   (apply string-append 
16   (map (lambda (n) (string-append (number->string n) \" \")) l)))
17
18 (define (number->octal-string x)
19   (let* ((n (inexact->exact x))
20          (n64 (quotient n 64))
21          (n8 (quotient (- n (* n64 64)) 8)))
22         (string-append
23          (number->string n64)
24          (number->string n8)
25          (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
26
27 (define (inexact->string x radix)
28   (let ((n (inexact->exact x)))
29        (number->string n radix)))
30
31 (define 
32   (number->dim-tex x)
33   (string-append 
34    (number->string x) \"pt \"))
35
36 (define
37   (control->string c)
38   (string-append
39     (string-append (number->string (car c)) \" \")
40     (string-append (number->string (cadr c)) \" \")))
41
42 (define
43   (invoke-output o s)
44    (eval-string (string-append s \"-\" o)))
45
46 ;;; output definitions
47 (define 
48   (char o n) 
49   ((invoke-output o \"char\") n))
50
51 (define 
52   (char-ps n) 
53   (string-append 
54    \"(\\\\\" (inexact->string n 8) \") show\"))
55
56 (define 
57   (char-tex n) 
58   (string-append 
59    \"\\\\char\" (inexact->string n 10)))
60
61 (define 
62   (dashed-slur o thick dash l) 
63   ((invoke-output o \"dashed-slur\") thick dash l))
64
65 (define 
66   (dashed-slur-ps thick dash l)
67   (string-append 
68     (apply string-append (map control->string l)) 
69     (number->string thick) 
70    \" [ \"
71    (if (> 1 dash) (number->string (- (* thick dash) thick)) \"0\") \" \"
72    (number->string (* 2 thick))
73    \" ] 0 draw_dashed_slur\"))
74
75 (define 
76   (dashed-slur-tex thick dash l)
77   (string-append 
78     \"\\\\embeddedps{\"
79     (dashed-slur-ps thick dash l)
80    \"}\"))
81
82 (define 
83   (empty o) 
84   ((invoke-output o \"empty\")))
85
86 (define 
87   (empty-ps) 
88   \"\n empty\n\")
89
90 (define 
91   (empty-tex) 
92   \"%\n\\\\empty%\n\")
93
94 (define 
95   (end-output o) 
96   ((invoke-output o \"end-output\")))
97
98 (define 
99   (end-output-ps)
100   \"\nshowpage\n\")
101
102 (define 
103   (end-output-tex) 
104   \"\n\\\\EndLilyPondOutput\")
105
106 (define 
107   (experimental-on o) 
108   ((invoke-output o \"experimental-on\")))
109
110 (define
111   (experimental-on-ps) \"\")
112
113 (define
114   (experimental-on-tex) \"\\\\turnOnExperimentalFeatures\")
115
116 (define
117   (finishbar o h) (empty o))
118
119 (define
120   (font i)
121   (string-append
122    \"font\"
123    (make-string 1 (integer->char (+ (char->integer #\\A) i)))
124    ))
125
126 (define 
127   (font-def o i s) 
128   (empty o))
129 ;  ((invoke-output o \"font-def\") i s))
130
131 (define 
132   (font-def-ps i s)
133   (string-append
134    \"\n/\" (font i) \" {/\" 
135    (substring s 0 (- (string-length s) 3))
136    \" findfont 12 scalefont setfont} bind def\n\"))
137
138 (define 
139   (font-def-tex i s)
140   (string-append
141    \"\\\\font\" (font-switch-tex i) \"=\" s \"\n\"))
142
143 (define 
144   (font-switch o i) 
145   ((invoke-output o \"font-switch\") i))
146
147 (define 
148   (font-switch-ps i)
149   (string-append (font i) \" \"))
150
151 (define 
152   (font-switch-tex i)
153   (string-append
154    \"\\\\\" (font i) \"\n\"))
155
156 (define 
157   (generalmeter o num den)
158    ((invoke-output o \"generalmeter\") num den))
159
160 (define 
161   (generalmeter-ps num den)
162   (string-append num \" \" den \" generalmeter \"))
163
164 (define 
165   (generalmeter-tex num den)
166   (string-append 
167    \"\\\\generalmeter{\" num \"}{\" den \"}\"))
168
169 (define 
170   (header o creator generate) 
171   ((invoke-output o \"header\") creator generate))
172
173 (define 
174   (header-ps creator generate) 
175   (string-append
176    \"%!PS-Adobe-3.0\n\"
177    \"%%Creator: \" creator generate \"\n\"))
178
179 (define 
180   (header-tex creator generate) 
181   (string-append
182    \"%created by: \" creator generate \"\n\"))
183
184 (define 
185   (header-end o) 
186   ((invoke-output o \"header-end\")))
187
188 (define
189   (header-end-ps) \"\")
190
191 (define
192   (header-end-tex) \"\\\\turnOnPostScript\")
193
194 (define
195   (lily-def o key val)
196   ((invoke-output o \"lily-def\") key val))
197
198 (define
199   (lily-def-ps key val)
200   (string-append
201    \"/\" key \" {\" val \"} bind def\n\"))
202
203 (define
204   (lily-def-tex key val)
205   (string-append
206    \"\\\\def\\\\\" key \"{\" val \"}\n\"))
207
208 (define 
209   (maatstreep o h) 
210   ((invoke-output o \"maatstreep\") h))
211
212 (define 
213   (maatstreep-ps h)
214   (string-append
215    (number->string h) \" maatstreep \" ))
216
217 (define 
218   (maatstreep-tex h)
219   (string-append
220    \"\n\\\\maatstreep{\" (number->dim-tex h) \"}\"))
221
222 (define 
223   (pianobrace o h) (empty o))
224
225 (define 
226   (placebox o x y b) 
227   ((invoke-output o \"placebox\") x y (b o)))
228
229 (define 
230   (placebox-ps x y s) 
231   (string-append 
232    (number->string x) \" \" (number->string y) \" {\" s \"} placebox \"))
233
234 (define 
235   (placebox-tex x y s) 
236   (string-append 
237    \"\\\\placebox{\"
238    (number->dim-tex y) \"}{\" (number->dim-tex x) \"}{\" s \"}\"))
239
240 (define
241   (repeatbar o h) (empty o))
242
243 (define 
244   (rulesym o x y) 
245   ((invoke-output o \"rulesym\") x y))
246
247 (define 
248   (rulesym-ps x y) 
249   (string-append 
250    (number->string x) \" \"
251    (number->string y) \" \"
252    \"rulesym\"))
253
254 (define 
255   (rulesym-tex x y) 
256   (string-append 
257    \"\\\\rulesym{\" (number->dim-tex x) \"}{\" (number->dim-tex y) \"}\"))
258
259 (define 
260   (setitalic o s) (empty o))
261
262 (define 
263   (settext o s) (empty o))
264
265 (define 
266   (slur o l) 
267   ((invoke-output o \"slur\") l))
268
269 (define 
270   (slur-ps l)
271   (string-append 
272    (apply string-append (map control->string l)) 
273    \" draw_slur\"))
274
275 (define 
276   (slur-tex l)
277   (string-append 
278    \"\\\\embeddedps{\"
279    (slur-ps l)
280    \"}\"))
281
282 (define 
283   (stem o kern width height depth) 
284   ((invoke-output o \"stem\") kern width height depth))
285
286 (define 
287   (stem-ps kern width height depth) 
288   (string-append (numbers->string (list kern width height depth))
289                  \"draw_stem\" ))
290
291 (define 
292   (stem-tex kern width height depth) 
293   (string-append 
294    \"\\\\kern\" (number->dim-tex kern)
295    \"\\\\vrule width \" (number->dim-tex width)
296    \"depth \" (number->dim-tex depth)
297    \"height \" (number->dim-tex height) \" \"))
298
299 (define 
300   (start-line o) 
301   ((invoke-output o \"start-line\")))
302
303 (define 
304   (start-line-ps) 
305   (string-append
306    (urg-fix-font-ps)
307    \"\nstart_line {\n\"))
308
309 (define 
310   (start-line-tex) 
311   (string-append 
312    (urg-fix-font-tex)
313    \"\\\\hbox{%\n\"))
314
315 (define 
316   (stop-line o) 
317   ((invoke-output o \"stop-line\")))
318
319 (define 
320   (stop-line-ps) 
321   \"}\nstop_line\n\")
322
323 (define 
324   (stop-line-tex) 
325   \"}\\\\interscoreline\")
326
327 (define
328   (urg-fix-font-ps)
329   \"/fontA { /feta20 findfont 12 scalefont setfont} bind def fontA\n\")
330
331 (define
332   (urg-fix-font-tex)
333   \"\\\\font\\\\fontA=feta20.afm\\\\fontA\n\")
334
335 (define 
336   (urg-font-switch-ps i)
337   \"\n/feta20 findfont 12 scalefont setfont \n\")
338
339 ";
340
341