]> git.donarmstrong.com Git - lilypond.git/blob - ps/lilyponddefs.ps
release: 1.3.149
[lilypond.git] / ps / lilyponddefs.ps
1 %!PS-Adobe-1.0: lilyponddefs
2 %
3 % Functions for direct PostScript output
4
5 % hmm
6 % /setgray { 1 add } bind def
7
8 /staff-line-thickness lilypondpaperstafflinethickness def
9 /staff-height lilypondpaperstaffheight def
10 /line-width lilypondpaperlinewidth def
11
12 % FIXME: why isn't this set (by default) by lily?
13 % /text-height lilypondpapertextheight def
14
15 /output-scale lilypondpaperoutputscale def
16 /paper-size { lilypondpaperpapersize } bind def
17
18 % FIXME
19 % urg, read from paper block
20 % fixed base line skip value, for single line staffs
21 /base-line-skip lilypondpaperlineheight def
22
23
24 /init-paper {
25         gsave
26         .1 setlinewidth
27         clippath pathbbox newpath
28         /vsize exch def
29         /hsize exch def  pop pop pop
30
31         %FIXME:
32         %vsize text-height sub 2 div /top-margin exch def
33         144 2 div /top-margin exch def
34         hsize line-width sub 2 div /left-margin exch def
35         grestore
36 } bind def
37
38 /place-box
39 {
40         /object exch def
41         gsave
42         %exch translate
43         translate
44         0 0 moveto
45         object
46         grestore
47 } bind def
48
49 %
50 % FIXME.  translate to middle of box.
51 %
52
53 /draw-box % breapth width depth height
54 {
55         /h exch def
56         /d exch def
57         /w exch def
58         /b exch def
59         gsave
60
61         0 setlinewidth
62         b neg d neg rmoveto
63         b w add 0 rlineto
64         0 d h add rlineto
65         b w add neg 0 rlineto
66         closepath % 0 d h add neg rlineto
67         fill
68
69         grestore
70 } bind def
71
72 /start-line
73
74         line-y top-margin sub base-line-skip lt {
75                 showpage
76                 /line-y vsize top-margin sub def
77         } if
78         gsave
79         line-x line-y translate
80 } bind def
81
82 /stop-line
83
84         /the-line exch def
85         0 0 moveto the-line clippath pathbbox
86         stroke
87         grestore
88         exch 4 -1 roll
89         sub
90         3 1 roll
91         exch sub
92         %pstack
93         %
94         % ugh: now we should have `width height' on stack,
95         % but it's probably just the width and height of last element
96         % (the last staff)
97         % How do we get all heights of all staffs in a line?
98         %
99         % output-scale div neg line-y add /line-y exch def
100         %
101         % discarding height...
102         pop
103         %
104         % discard width
105         pop
106         % use fixed base-line-skip for now
107         line-y base-line-skip output-scale mul sub /line-y exch def
108 } bind def
109
110 % FIXME: font definitions should come from LilyPond
111 %        built-in ps fonts are ugly
112 /huge-bold-font {
113         /Times-Bold findfont 20.7 scalefont setfont
114 } bind def
115
116 /Large-bold-font {
117         /Times-Bold findfont 17.3 scalefont setfont
118 } bind def
119
120 /large-bold-font {
121         /Times-Bold findfont 14.4 scalefont setfont
122 } bind def
123
124 /large-font {
125         /Times-Roman findfont 14.4 scalefont setfont
126 } bind def
127
128 /large-smallcaps-font {
129         % urg
130         /Helvetica findfont 14.4 scalefont setfont
131 } bind def
132
133 /normal-font {
134         /Times-Roman findfont 12 scalefont setfont
135 } bind def
136
137 /footnote-font {
138         /Times-Roman findfont 10 scalefont setfont
139 } bind def
140
141 /get-text-dimensions % path .. width height
142 {
143         dup true charpath pathbbox
144         newpath
145         line-x line-y moveto
146         exch 4 -1 roll
147         sub
148         3 1 roll
149         exch sub
150 } bind def
151
152 /set-centered
153 {
154         line-x line-y moveto
155         get-text-dimensions
156         neg line-y add /line-y exch def
157         neg line-width add 2 div 0 rmoveto
158         show
159 } bind def
160
161 /set-left
162 {
163         line-x line-y moveto
164         get-text-dimensions
165         neg line-y add /line-y exch def
166         pop
167         show
168 } bind def
169
170 /set-right
171 {
172         line-x line-y moveto
173         get-text-dimensions
174         neg line-y add /line-y exch def
175         neg line-width add 0 rmoveto
176         show
177 } bind def
178
179 /make-lilypond-title
180 {
181         currentdict /lilypondtitle known {
182                 huge-bold-font lilypondtitle set-centered
183                 line-y 5 sub /line-y exch def
184         } if
185         currentdict /lilypondsubtitle known {
186                 Large-bold-font lilypondsubtitle set-centered
187                 line-y 5 sub /line-y exch def
188         } if
189         currentdict /lilypondsubsubtitle known {
190                 large-bold-font lilypondsubsubtitle set-centered
191         } if
192         currentdict /lilypondcomposer known {
193                 large-smallcaps-font lilypondcomposer set-right
194         } if
195         currentdict /lilypondopus known {
196                 normal-font lilypondopus set-right
197         } if
198         currentdict /lilypondarranger known {
199                 normal-font lilypondarranger set-right
200         } if
201         currentdict /lilypondinstrument known {
202                 large-font lilypondinstrument set-centered
203         } if
204         currentdict /lilypondpiece known {
205                 large-smallcaps-font lilypondpiece set-left
206         } if
207 } bind def
208
209 /end-lilypond-output
210 {
211         /line-y top-margin def
212         footnote-font lilypondtagline set-left
213         showpage
214 } bind def
215
216 /turnOnExperimentalFeatures { } bind def
217
218
219 staff-line-thickness setlinewidth
220
221 paper-size
222
223 staff-height init-paper
224
225 /line-x left-margin def
226 /line-y vsize top-margin sub def
227
228 make-lilypond-title
229
230 % see if we're there...
231 % 10 setlinewidth 0 0 moveto 400 800 lineto stroke